Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: async view removal from onDetachedFromWindow #244

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented Sep 21, 2023

📜 Description

Remove eventView asynchronously.

💡 Motivation and Context

It seems that before opening a universal link and before onDetachedFromWindow Android takes a snapshot of view hierarchy. Then in onDetachedFromWindow we are removing a View and later Android calls dispatchDetachedFromWindow for each view from snapshot. But since we've already removed a view it tries to call a method on null object reference and we are getting an expected NPE.

In this PR I've reworked an approach (to one that was suggested in the thread of the issue). And I remove a view asynchronously. It shouldn't add more new issues, but it'll prevent NPE in the case described above, because we'll remove a view after dispatchDetachedFromWindow has been called.

Also I've added deep links/universal links to both examples app (paper, fabric). In order to open an app from a link I had to:

  • long press on app icon
  • press App Info
  • press on "Open by default"
  • add a link (should be suggested automatically)

Later I'll try to cover this scenario by e2e tests.

Closes #242

📢 Changelog

Android

  • call this.removeKeyboardCallbacks() as Handler(Looper.getMainLooper()).post { this.removeKeyboardCallbacks() }

🤔 How Has This Been Tested?

Tested on Pixel 7 Pro.

📸 Screenshots (if appropriate):

npe-trimmed.mp4

📝 Checklist

  • CI successfully passed

@kirillzyusko kirillzyusko added 🤖 android Android specific 🎯 crash Library triggers a crash of the app labels Sep 21, 2023
@kirillzyusko kirillzyusko self-assigned this Sep 21, 2023
@github-actions
Copy link
Contributor

📊 Package size report

Current size Target Size Difference
73473 bytes 73323 bytes 150 bytes 📈

@kirillzyusko kirillzyusko marked this pull request as ready for review September 21, 2023 13:58
@kirillzyusko kirillzyusko merged commit 9430657 into main Sep 21, 2023
11 checks passed
@kirillzyusko kirillzyusko deleted the fix/242-async-view-removal-on-detached branch September 21, 2023 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Android specific 🎯 crash Library triggers a crash of the app
Projects
None yet
1 participant