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

[Unified player] Heavy work on Main Thread during seeking on almost all videos #4286

Closed
vkay94 opened this issue Sep 17, 2020 · 12 comments
Closed
Labels
bug Issue is related to a bug GUI Issue is related to the graphical user interface player Issues related to any player (main, popup and background)

Comments

@vkay94
Copy link
Contributor

vkay94 commented Sep 17, 2020

Version

530f745 2020-09-08

Steps to reproduce the bug

  1. Open any video (99% videos have this bug)
  2. Show the controller and change the position multiple times by dragging/tapping on the seekbar
  3. Wait ...

Expected behavior

The video should load shortly and start the playback and response to other actions.

Actual behaviour

The seekbar doesn't update the position for a long time. During this time the UI doesn't react to gestures ("freeze"). After a while the app crashes.

Screenshots/Screen recordings

Video demonstration: https://streamable.com/9gf4tv
The first video is the expected behavior, the second video shows the bug.

What's the reason?

During debugging I saw in the logcat that the device tries to seek to all positions which were tapped, so the doesn't discard "unneeded" positions (positions which are older than the current).

@vkay94 vkay94 added the bug Issue is related to a bug label Sep 17, 2020
@Stypox Stypox added player Issues related to any player (main, popup and background) GUI Issue is related to the graphical user interface labels Sep 17, 2020
@vkay94
Copy link
Contributor Author

vkay94 commented Sep 17, 2020

I might have found a workaround for this ... kind of. It's not as smooth as the first video then (keep in mind that the video is recorded, on the device it's more fluid), but definitely faster responsive.

Just remove / comment out these lines:


I don't see a reason for recreating the whole notification when the video is sought. This has a high impact on the main thread if it's occurs too often.

@Stypox
Copy link
Member

Stypox commented Sep 17, 2020

@vkay94 please check if the apk provided in #3178 works well

@vkay94
Copy link
Contributor Author

vkay94 commented Sep 17, 2020

@Stypox It's slightly faster on the video which works well but on the others it's still freezing the UI/seekbar.

@avently
Copy link
Contributor

avently commented Sep 17, 2020

It's slightly faster on the video which works well but on the others it's still freezing the UI/seekbar

Are you sure that the delay is caused by @Stypox's notifications? Please, try to measure using logcat timestamps or Android Profiler

@vkay94
Copy link
Contributor Author

vkay94 commented Sep 17, 2020

@avently I think so. Probably not the actual recreation as I looked into the code of the pr (forceRefresh-parameter) but it has an impact. Maybe it's the source. I don't know :(

image

What I did during recording:

Edit: Or it's more likely the changeState() method which is called often. I'm not that good at analyzing it in this view :')

@avently
Copy link
Contributor

avently commented Sep 17, 2020

@Stypox probably in case of buffering we can drop updating a notification, what do you think? It's not important event and can happen often

@Stypox
Copy link
Member

Stypox commented Sep 19, 2020

probably in case of buffering we can drop updating a notification, what do you think?

Unfortunately we can't drop it completely, since a notification button changes icon alongside the buffering state, but maybe we could implement a check that prevents useless updates if the state in reality did not change. I'll not include this in #3178 though, since it is not critical and not a new bug (it has always existed). I will get to it later.

@vkay94
Copy link
Contributor Author

vkay94 commented Sep 20, 2020

@Stypox @avently I figured out something this moment. This specific lag seems unrelated to the notifications since disabling improves the experience but doesn't eliminate it completely.

The reason seems to lie in the extractor or more likely on the client handling of the channels data (specific data from the channel which is added to StreamInfo or similar).
For the channel Studio Yuraki (https://www.youtube.com/channel/UCMTPj3w6L0hol6KHu9DHzQA) for example all videos don't have this bug whereas all videos from the Apple channel have this bug. There are more channels where this applies too.
So you can remove this issue from the To Do in Notification @Stypox ;)

I try to look into it but it could take some time since I haven't got much time currently.

@Stypox
Copy link
Member

Stypox commented Sep 20, 2020

@vkay94 then it's probably a codec-related issue, since the extractor only runs once (when showing info) and provides the stream url to play.

@vkay94
Copy link
Contributor Author

vkay94 commented Sep 21, 2020

@Stypox I checked the codecs some days ago and they were identical. But I found the problem (it's so dumb):
The problem lies in handling of the extractor data as expected. The thumbnail url which is loaded by the Notification isn't unified in this call:

private void initThumbnail(final String url) {

The extractor passes full imageurls; some of them are maxresdefault (1280x720), others are hqdefault (336x188). So when the Imageloader loads twice this max res image in every notification reset there is huge work on the main thread.

I modified the handling by unifying it to hqdefault and it works fine now for every video. So you should build a similar check into your PR, it will improve it for sure.

@vkay94 vkay94 mentioned this issue Sep 21, 2020
4 tasks
@Stypox
Copy link
Member

Stypox commented Sep 21, 2020

@vkay94 unfortunately that's not the way to go, since we need the high res thumbnails to show them in the video details page. @wb9688 and @B0pol were planning to add an Image class, which would provide thumbmails at different resolutions, only then this issue can be solved. Thank you for the investigation!

@vkay94
Copy link
Contributor Author

vkay94 commented Sep 21, 2020

This image class sounds great, it'd be handy for the list items (history etc) too which are updated more often in the unified player builds than before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug GUI Issue is related to the graphical user interface player Issues related to any player (main, popup and background)
Projects
None yet
Development

No branches or pull requests

3 participants