element-android icon indicating copy to clipboard operation
element-android copied to clipboard

Open room from permalink does not work when app is in background

Open Florian14 opened this issue 4 years ago • 0 comments

Steps to reproduce

  1. Create and copy a permalink from a room timeline event
  2. Optionally go back to return to Element home screen
  3. Pass the app in background by taping on the phone home button
  4. Paste and open the permalink in a browser
  5. Open it with Element if requested
  6. 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

Florian14 avatar Sep 14 '21 10:09 Florian14