-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
In the latest versions of Flutter, textures no longer get rendered from the video anymore (if it's paused) after a native view comes up over the app. This didn't happen in the stable 1.12 release, but is happening in the v1.18.0 dev release, and I verified it still happens in the newest 1.18.0-8.0.pre release as well.
I think this is since Flutter started using Metal on iOS.
The following code can be used to reproduce it.
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: VideoHomePage()
);
}
}
class VideoHomePage extends StatefulWidget {
@override
_VideoHomePageState createState() => _VideoHomePageState();
}
class _VideoHomePageState extends State<VideoHomePage> {
VideoPlayerController _videoPlayerController;
@override
void initState() {
super.initState();
// use any video you have
_videoPlayerController = VideoPlayerController.asset("videos/video.mp4");
_videoPlayerController.play();
_videoPlayerController.initialize();
}
@override
void dispose() {
_videoPlayerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Material(
type: MaterialType.transparency,
elevation: 0,
child: FittedBox(
fit: BoxFit.fitWidth,
child: Container(
// these are the dimensions of my video
width: 818.0,
height: 864.0,
child: VideoPlayer(_videoPlayerController)
),
),
);
}
}
Pull down the iOS notification bar while the video plays and close it again. Notice the video will continue rendering if it's playing.
Once the video completes, do the same, and notice that the video disappears.
This used to work properly in previous versions of Flutter, including v1.12.13+hotfix.9
My flutter doctor:
985aeb8ceee6:all danny.valente$ flutter doctor --verbose
[✓] Flutter (Channel dev, v1.18.0, on Mac OS X 10.14.6 18G4032, locale en-US)
• Flutter version 1.18.0 at /Users/danny.valente/Library/flutter/1.18.0-dev.3.0-dev
• Framework revision de1e572 (3 weeks ago), 2020-04-06 16:15:07 -0700
• Engine revision df257e5
• Dart version 2.8.0 (build 2.8.0-dev.20.0 1210d27678)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/danny.valente/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C505
! CocoaPods 1.7.5 out of date (1.8.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade:
sudo gem install cocoapods
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)