Repository navigation
Closed
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolee: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issueteam-engineOwned by Engine teamOwned by Engine team
Description
Steps to reproduce
using the sample code to setup a new flutter project.
and then add this code in AndroidManifest.xml Application section
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="true" />Expected results
the video should be playing
Actual results
Running these code on Android Api 30+ simulators can crush the app
Running these code on Android Api 31+ simulators also crushes the simulator
Running these code on my Android Api 33+ real device does not crush, but no picture shows up, only the sound is available
I also tested MediaPlayer with TextureView in pure kotlin and the result seems fine
Code sample
Code sample
main.dartimport 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const platform =
MethodChannel('com.example.flutter_video_example/channel');
int? _textureId;
@override
void initState() {
super.initState();
platform.setMethodCallHandler((MethodCall call) async {
if (call.method == 'textureReady') {
setState(() {
_textureId = call.arguments;
});
print('textureReady $_textureId');
}
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Video Player Example')),
body: _textureId != null
? AspectRatio(
aspectRatio: 16 / 9,
child: Texture(textureId: _textureId!),
)
: Container(),
),
);
}
}MainActivity.kt
package com.example.flutter_video_example
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import android.media.MediaPlayer
import android.view.Surface
import android.graphics.SurfaceTexture
import io.flutter.plugin.common.MethodChannel
class MainActivity: FlutterActivity() {
private lateinit var channel: MethodChannel
private lateinit var surfaceTexture: SurfaceTexture
private lateinit var surface: Surface
private lateinit var mediaPlayer: MediaPlayer
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.example.flutter_video_example/channel")
val textureEntry = flutterEngine.renderer.createSurfaceTexture()
surfaceTexture = textureEntry.surfaceTexture()
surface = Surface(surfaceTexture)
val textureId = textureEntry.id()
channel.invokeMethod("textureReady", textureId)
mediaPlayer = MediaPlayer().apply {
setSurface(surface)
setDataSource("https://download.samplelib.com/mp4/sample-5s.mp4")
prepareAsync()
setOnPreparedListener {
//surfaceTexture.setDefaultBufferSize(videoWidth, videoHeight)
start()
isLooping = true
}
}
}
}Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.3, on macOS 14.3.1 23D60 darwin-arm64, locale
en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.87.1)
[✓] Connected device (2 available)
[✓] Network resourcesReacted by kyjcoope
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolee: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issueteam-engineOwned by Engine teamOwned by Engine team
Activity
[-]Using Android SurfaceTexture and Flutter Texture Widget together may cause problems.[/-][+]Using Android SurfaceTexture and Flutter Texture Widget together with Impeller enabled may cause problems.[/+]huycozy commentedon Mar 13, 2024
Hi @xxoo
Does your Android Api 30+ and 31+ simulators support Vulkan? When the crash occurs, can you share the entire error output?
For the issue that the video doesn't render, looks like you hit #141636.
xxoo commentedon Mar 13, 2024
hi @huycozy
This is the log
I didn't see any valuable information in the console when the crush happened.
But now I'm sure it is related to vuklan. Because I just installed Vulkan Hardware Capability Viewer in the simulator. Then the same kind of crush happened.
And when I add this line to AndroidManifest.xml, the crush is gone, but the video doesn't look quite right.
Screen.Recording.2024-03-13.at.21.58.08.mov
huycozy commentedon Mar 14, 2024
You can open
androidmodule in Android Studio and then openLogcattab to see if there is any error log.I'm unsure about emulator configuration for this. I checked this issue on a physical device
Pixel 7, Android 14which supports Vulkan. There is no crash but the video is not rendered as mentioned above.xxoo commentedon Mar 14, 2024
This is on api 34 simulator, the os crashed
This is on api 30 simulator, the app crashed
huycozy commentedon Mar 15, 2024
Thanks for the update. I don't have such emulators but the error trace may have information to investigate further.
jonahwilliams commentedon Mar 18, 2024
Android surface textures and certain platform views do not yet work with Impeller. The work to fix this can be tracked here: #139702
github-actions commentedon Apr 2, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.