Skip to content

attach-screenshot on manual Android init #2185

Description

@marandaneto

Description

If you enable the flag using the manifest config it works.
If you flip the flag using the Manual init of the Android SDK, it does not.
The reason is that we don't call registerActivityLifecycleCallbacks because isAttachScreenshot returns false when the event processor is created, the user configuration is triggered only after and later is too late.
Ideally we'd fix this logic https://github.com/getsentry/sentry-java/blob/main/sentry-android-core/src/main/java/io/sentry/android/core/ScreenshotEventProcessor.java#L50-L64=
We could technically install the lifecycle callback anyway and check when the very first process is called and call unregisterActivityLifecycleCallbacks if isAttachScreenshot is still disabled, there's a bit of overhead but I don't see any other solution right now.

Another way would be that Event processors have an install method similar to Integrations that are only called when the SDK is fully inited, but that would require more changes.

Found this issue by debugging getsentry/sentry-react-native#2362

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIssue type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions