-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#52980Labels
a: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appscp: stablecherry pick this pull request to stable release candidate branchcherry pick this pull request to stable release candidate branche: OS-version specificAffects only some versions of the relevant operating systemAffects only some versions of the relevant operating systemplatform-androidAndroid applications specificallyAndroid applications specificallyplatform-views: tlhcIssues specific to the Android Texture Layer Hybrid Composition platform views backendIssues specific to the Android Texture Layer Hybrid Composition platform views backendr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamOwned by Android platform team
Description
Steps to reproduce
The issue looks very similar to #146499 but the steps are different.
This is happening with Flutter 3.22.0
Environment: Samsung Galaxy A53 5G (Android 14)
Steps:
- Install the app and launch.
- From root page (with platform view), press the back button key to move app to background.
- Launch the app again either from launcher or from icon.
Expected results
Platform view should be rendered at home page.
Actual results
Platform view turns blank at home page.
Further, after the issue is reproduced, if you switch to another app from recent apps launcher , and then switch back again to the sample app, the platform view starts to appear again.
Code sample
Sample is same as #146499:
https://github.com/flutter/flutter/files/14917706/platform_view_test.3.zip
Code sample
Dart:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
final Map<String, dynamic> creationParams = <String, dynamic>{};
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text("App"),
),
body: AndroidView(
viewType: "nativeView",
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
),
);
}
}Platform side:
class MyApplication : Application() {
private lateinit var flutterEngine : FlutterEngine
override fun onCreate() {
super.onCreate()
// Instantiate a FlutterEngine.
flutterEngine = FlutterEngine(this)
// Start executing Dart code to pre-warm the FlutterEngine.
flutterEngine.dartExecutor.executeDartEntrypoint(
DartExecutor.DartEntrypoint.createDefault()
)
// Cache the FlutterEngine to be used by FlutterActivity.
FlutterEngineCache
.getInstance()
.put("my_engine_id", flutterEngine)
}
}
class RootActivity: Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startActivity(
FlutterActivity.CachedEngineIntentBuilder(MainActivity::class.java, "my_engine_id")
.build(this)
)
finish()
}
}
class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
flutterEngine
.platformViewsController
.registry
.registerViewFactory("nativeView", NativeViewFactory())
}
}Screenshots or Video
Video demonstration
Screen_Recording_20240520_120641.mov
Flutter Doctor output
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-IN)
• Flutter version 3.22.0 on channel stable at /Users/rpant/Flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (11 days ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/rpant/Library/Android/sdk
• Platform android-34, build-tools 33.0.2
• ANDROID_HOME = /Users/rpant/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C65
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.89.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (5 available)
• SM A536E (mobile) • RZCTC0B6D9L • android-arm64 •
Android 14 (API 34)
• iPhone 15 Pro (mobile) • 99935264-E514-44AE-AC05-D0ADDC217EDB • ios •
com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 •
macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin •
macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript •
Google Chrome 125.0.6422.60
[✓] Network resources
• All expected network resources are available.
• No issues found!```
Guru-cm-here
Metadata
Metadata
Assignees
Labels
a: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appscp: stablecherry pick this pull request to stable release candidate branchcherry pick this pull request to stable release candidate branche: OS-version specificAffects only some versions of the relevant operating systemAffects only some versions of the relevant operating systemplatform-androidAndroid applications specificallyAndroid applications specificallyplatform-views: tlhcIssues specific to the Android Texture Layer Hybrid Composition platform views backendIssues specific to the Android Texture Layer Hybrid Composition platform views backendr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamOwned by Android platform team