Screenshot capture failing intermittently #19450
Labels
area-essentials
Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info
platform/android 🤖
t/bug
Something isn't working
Milestone
Description
In the sentry-dotnet I'm adding a feature to capture screenshots when some event is logged. In the test Android application screen capture fails intermittently with the following error:
NullReferenceException: The current Activity can not be detected. Ensure that you have called Init in your Activity or Application class.
I added
Platform.Init(this, savedInstanceState);
as well asMicrosoft.Maui.ApplicationModel.ActivityStateManager.Default.Init(this, savedInstanceState);
to theMainActivity
but still get the error.The code to capture screen:
Steps to Reproduce
Run Sentry.Maui.Device.TestApp from the linked repository. Run tests from
Sentry.Maui.Tests
collection and observe thatCaptureException_WhenAttachScreenshots_ContainsScreenshotAttachmentAsync
test will sometimes fail.If you put a breakpoint inside
ScreenshotAttachmentContent.GetStream
in the catch clause you will see the following exception:Link to public reproduction project repository
https://github.com/getsentry/sentry-dotnet/tree/feat/Maui-Screenshot
Version with bug
7.0.101
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Happens on Android 27, 31 and 32, haven't tested others.
Did you find any workaround?
No
Relevant log output
No response
The text was updated successfully, but these errors were encountered: