PierfrancescoSoffritti / android-youtube-player

YouTube Player library for Android and Chromecast, stable and customizable.
https://pierfrancescosoffritti.github.io/android-youtube-player/
MIT License
3.42k stars 759 forks source link

YouTube video is flickering, but plays OK after pausing and resuming #910

Closed milan-fabian closed 1 year ago

milan-fabian commented 1 year ago

Bug Report

Description of the Bug

I am using this library in a Digital Signage app to play YouTube videos and I received a bug report from one user that a video flickers on their device. I haven't managed to reproduce this bug on any of my devices yet, but I am curious whether anybody has any pointer to what could cause this problem.

Environment details

Android Version: 9

Android System WebView version: 108.0.5359.128

Tested devices:

Youtube Player Library Version: 11.0.1

Steps to reproduce the bug

  1. Download and install Slideshow app (https://slideshow.digital/how-to-get-it/) on Xiaomi Mi Box 4
  2. Display YouTube video on the screen using the app

Expected behavior

The YouTube video plays flicker-free

Actual behavior

The YouTube video flickers and there are following messages in the logcat:

18:43:30.848  4890  5015 E chromium: [ERROR:image_reader_gl_owner.cc(296)] no buffers currently available in the reader queue
18:43:30.848  4890  5015 E chromium: [ERROR:video_image_reader_image_backing.cc(210)] Failed to get the hardware buffer.

The recording of the behavior is here: https://www.youtube.com/watch?v=-tbXBv9BEQ8

After manually pausing and resuming the video (using YouTubePlayer.pause() and YouTubePlayer.play()) the video is flicker-free and playback is OK.

Serkali-sudo commented 1 year ago

Try enabling or disabling hardware acceleration.

milan-fabian commented 1 year ago

@Serkali-sudo do you mean enable/disable hardware acceleration in the entire app, or is there a way to enable/disable hardware acceleration just for YouTubePlayerView?

Serkali-sudo commented 1 year ago

YouTubePlayerView is actually webview and there is a way to enable/disable hardware acceleration for webview spesifically. If enabling or disabling hardware acceleration in the entire app causes problems other parts of the app you can try to enable/disable YouTubePlayerView's hardware acceleration spesifically but you are gonna have edit the library to do that.

milan-fabian commented 1 year ago

I accessed WebViewYouTubePlayer via reflection and tried:

If you have any other suggestion to try, I would be really grateful.

Serkali-sudo commented 1 year ago

i have more ideas but not sure if they will work but if you want to try them anyways:

  1. Try to clear cache of the "Android System Webview" app and if Chrome app is installed you can try to switch webview engine to Chrome's webview
  2. There may be conflicts with other apps that running on background try closing them
  3. Try to open this demo : https://developers.google.com/youtube/youtube_player_demo on a system webview powered browser(eg: Via Browser ) if flickering happens there too then it is probably hardware gpu issue.
  4. After quick search on the web i found this issue that is similar to what you are experiencing : https://bugs.chromium.org/p/chromium/issues/detail?id=1109016
PierfrancescoSoffritti commented 1 year ago

I am closing the issue for now because of inactivity.

If this is still a problem can you provide:

  1. Stack traces
  2. Information about the device on which the error happens (model, api version)
  3. If possible, the app on which the issue happens. Either code or apk is fine.