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

Wakelock for shorts is broken on android #451

Open
mulundapm opened this issue Sep 26, 2024 · 10 comments
Open

Wakelock for shorts is broken on android #451

mulundapm opened this issue Sep 26, 2024 · 10 comments
Assignees

Comments

@mulundapm
Copy link
Contributor

mulundapm commented Sep 26, 2024

For shorts that are opened from sections in homepage

@sifferhans
Copy link
Contributor

#465

@mulundapm
Copy link
Contributor Author

Short reloads in the middle of the short and wakelock is disabled after that. This happen often on the first short on launch.

@sifferhans
Copy link
Contributor

sifferhans commented Oct 10, 2024

The current logic checks each render if the active route is the short_scroll_view screen

  • if the current route is the short_scroll_view, enable wake-lock
  • if the current route is not the short_scroll_view, and the previous route was, disable wake-lock.
    This is to make sure we disable wake-lock when navigating away from shorts screen

The bug happens when you navigate from the shorts screen on the homepage, to the shorts screen tab; you technically navigate away from a shorts screen, so it disables wake-lock

There is basically a race condition as both shorts screens enable/disable wake-lock at the same time

The solution here is probably to share some state or something

@sifferhans
Copy link
Contributor

I ended up using a simple counter to keep track of screens requiring the wakelock to be enabled

@sifferhans
Copy link
Contributor

Should be tested in version 5.6.37

@KillerX
Copy link
Member

KillerX commented Oct 15, 2024

Not fixed for me on 5.6.37+2300197

@sifferhans
Copy link
Contributor

@KillerX Do you have reproduction steps to trigger the bug?

@KillerX
Copy link
Member

KillerX commented Oct 18, 2024

Just reproduced in the most straingforward manner:

Open app, Scroll down, Open short 🤷

@sifferhans
Copy link
Contributor

sifferhans commented Oct 18, 2024

The quick "flash" we see before the wakelock turns off seems to be because the short is buffering. Need to validate that to be 100% sure, but we only show the loading spinner either when the video initializes or buffers.

If that is the case, the buffering somehow disables the wakelock

@sifferhans
Copy link
Contributor

sifferhans commented Oct 21, 2024

The stretched image appearing could be because the player stops, but the current MediaItem is not removed from the player.
I can reproduce the stretched state by calling the stop method on the player:

shortController.player.stop(reset: false)

It could also be caused by this bug: androidx/media#1237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants