youtube_player_flutter icon indicating copy to clipboard operation
youtube_player_flutter copied to clipboard

[BUG] Performance issue on Android when using full screen mode

Open freewheelnat opened this issue 3 years ago • 3 comments

Describe the bug Performance issue on Android when using full screen mode.

We have observed 3 issues:

  • sometimes, the video in full screen isn't full screen. It feels like an animation has stopped maybe. See screenshot
  • sometimes, when existing full screen, the video space on the initial screen is just completely blank.
  • sometimes, it freezes for a short while during the transition to/from full screen.

To Reproduce Switch between normal mode and full screen mode on Android device several times.

Expected behavior The video is full screen when selecting full screen. The video is showing when exiting full screen

Screenshot BrokenVideoInFullScreen

Technical Details: Issue observed frequently on following devices:

  • Pixel 4, Android 12
  • Xiaomi Mi A2 Android 10

Issue observed rarely on following device:

  • Xiaomi Mi 10T, Android 10

Code youtube_player_iframe: ^2.2.2

class VideoPlayerViewYouTubeImpl extends StatefulWidget {
 const VideoPlayerViewYouTubeImpl({
   Key? key,
   required this.videoId,
   required this.errorView,
   required this.loadingView,
 }) : super(key: key);

 final String videoId;
 final Widget errorView;
 final Widget loadingView;

 @override
 _VideoPlayerViewYouTubeImplState createState() =>
     _VideoPlayerViewYouTubeImplState();
}

class _VideoPlayerViewYouTubeImplState
   extends State<VideoPlayerViewYouTubeImpl> {
 late YoutubePlayerController _controller;

 @override
 void initState() {
   super.initState();
   _controller = YoutubePlayerController(
     initialVideoId: widget.videoId,
     params: const YoutubePlayerParams(
       showFullscreenButton: true,
       privacyEnhanced: true,
       strictRelatedVideos: true,
       useHybridComposition: false,
     ),
   );
   _controller.onEnterFullscreen = () {
     SystemChrome.setPreferredOrientations([
       DeviceOrientation.landscapeLeft,
       DeviceOrientation.landscapeRight,
     ]);
   };
 }

 @override
 void dispose() {
   _controller.close();
   super.dispose();
 }

 @override
 Widget build(BuildContext context) {
   const player = YoutubePlayerIFrame(gestureRecognizers: {});
   return YoutubePlayerControllerProvider(
     // Passing controller to widgets below.
     controller: _controller,
     child: Scaffold(
       body: Stack(
         children: [
           player,
           Positioned.fill(
             child: YoutubeValueBuilder(
               controller: _controller,
               builder: (context, value) {
                 if (value.hasError) {
                   return widget.errorView;
                 } else {
                   return AnimatedCrossFade(
                     firstChild: const SizedBox.shrink(),
                     secondChild: widget.loadingView,
                     crossFadeState: value.isReady
                         ? CrossFadeState.showFirst
                         : CrossFadeState.showSecond,
                     duration: const Duration(milliseconds: 300),
                   );
                 }
               },
             ),
           ),
         ],
       ),
     ),
   );
 }
}

freewheelnat avatar Jan 14 '22 12:01 freewheelnat

yes this happened on my android device too, enter fullscreen several time then the video player show like the picture below My device : Nokia 7.2 Android: 11

  • This happened on fullscreen landscape mode,

1643218357312

ducNN93 avatar Jan 26 '22 17:01 ducNN93

+1 Same behavior here

jsanz1209 avatar Feb 17 '22 09:02 jsanz1209

Sam behavior here.

alexaung avatar Mar 14 '22 12:03 alexaung