Fix: When AppLifecycleIntegration is closed, it should remove observer using UI thread #1459
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Fix: When AppLifecycleIntegration is closed, it should remove observer using UI thread
💡 Motivation and Context
2021-05-04 16:20:05.210 27271-27444/xxx E/Sentry: Error while closing the Hub.
java.lang.IllegalStateException: Method removeObserver must be called on the main thread
at androidx.lifecycle.LifecycleRegistry.enforceMainThreadIfNeeded(LifecycleRegistry.java:317)
at androidx.lifecycle.LifecycleRegistry.removeObserver(LifecycleRegistry.java:219)
at io.sentry.android.core.AppLifecycleIntegration.close(AppLifecycleIntegration.java:94)
at io.sentry.core.Hub.close(Hub.java:246)
at io.sentry.core.Sentry.close(Sentry.java:216)
at io.sentry.core.HubAdapter.close(HubAdapter.java:57)
at io.sentry.core.ShutdownHookIntegration.lambda$register$0(ShutdownHookIntegration.java:25)
at io.sentry.core.-$$Lambda$ShutdownHookIntegration$92gaGRLn-MU5DyRe0eDeeyrGh5g.run(Unknown Source:2)
at java.lang.Thread.run(Thread.java:764)
💚 How did you test it?
📝 Checklist
🔮 Next steps