Open room from permalink does not work when app is in background
Steps to reproduce
- Create and copy a permalink from a room timeline event
- Optionally go back to return to Element home screen
- Pass the app in background by taping on the phone home button
- Paste and open the permalink in a browser
- Open it with Element if requested
- A BottomSheet dialog appears, displaying the room name with a button to open it
What happened?
What did you expect?
Click on the button should open the room and scroll to the related permalink event
What happened?
Sometimes, nothing is happening, the bottom sheet is closed and we stay in the current screen
My observation
By debugging the code and making some searches. I observed that the listener passed to the MatrixToBottomSheet class is null when I click on the button. I think that's due to the WeakReference that's hold the listener.
This blog post confirms my idea:
the only objects that worth be keeping inside WeakReferences are objects that are kept by SDK somewhere: Activities, Fragments, Views. Do not store local methods objects in WeakReferences.
To resolve it, I think we should remove the reference of the listener manually instead.
https://user-images.githubusercontent.com/11990514/133239018-3acfd2e6-1a38-4c5c-a95b-a715a3d511e0.mov
Your phone model
Emulator Pixel 4, Samsung Galaxy A10s
Operating system version
Android 11.0, 10.0
Application version and app store
No response
Homeserver
matrix.org
Have you submitted a rageshake?
No