Repository navigation
integration_test screenshot Android - FlutterFragmentActivity - PlatformException(Could not copy the pixels, FlutterView is null) #89683
Copy link
Copy link
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsf: integration_testThe flutter/packages/integration_test pluginThe flutter/packages/integration_test pluginfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyr: 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
- flutter create test
- Change MainActivity to use
FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
- Add integration_test, test_driver as per https://github.com/flutter/flutter/tree/master/packages/integration_test
- Add screenshot steps..
await binding.convertFlutterSurfaceToImage();
// Trigger a frame.
await tester.pumpAndSettle();
await binding.takeScreenshot('screenshot-1');
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/home_test.dart
Expected results:
Takes screenshot, same as when using FlutterActivity
Actual results:
Failure in method: screenshot
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following PlatformException was thrown running a test:
PlatformException(Could not copy the pixels, FlutterView is null,
null, null)
When the exception was thrown, this was the stack:
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
<asynchronous suspension>
#2 IOCallbackManager.takeScreenshot (package:integration_test/_callback_io.dart:91:33)
<asynchronous suspension>
#3 IntegrationTestWidgetsFlutterBinding.takeScreenshot (package:integration_test/integration_test.dart:175:39)
<asynchronous suspension>
#4 main.<anonymous closure> (file:///home/tim/AndroidStudioProjects/untitled/integration_test/home_test.dart:40:5)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:176:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:817:5)
<asynchronous suspension>
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.0, on KDE neon User Edition 5.22 5.8.0-63-generic, locale en_NZ.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Android Studio
[✓] Connected device (3 available)
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsf: integration_testThe flutter/packages/integration_test pluginThe flutter/packages/integration_test pluginfound in release: 2.5Found to occur in 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyAndroid applications specificallyr: 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
Activity
darshankawar commentedon Sep 9, 2021
@hampsterx
Thanks for the report. Can you provide the entire
MainActivity.kt? I tried usingFlutterFragmentActivity()as you mentioned, but it's giving me bunch of compile errors. WithFlutterActivity(), it works properly though.Also, please check this similar /related issue for your reference: #83856
hampsterx commentedon Sep 9, 2021
My project is using
local_authfor biometrics which requires theFlutterFragmentActivityhence why I hit this issue.cheers~
darshankawar commentedon Sep 10, 2021
Thank for the file. I verified this on latest master and stable and see the same behavior. Below exception is thrown:
console error log
flutter doctor -v
BouweCeunen commentedon Dec 5, 2021
Is there already a solution for this? Also hitting the exact same issue.
hampsterx commentedon Dec 6, 2021
@jmagman @blasten @nturgut
any thoughts?
(I see a few prior PR's in this area from ya'll)
8 remaining items
jmagman commentedon Sep 21, 2022
I don't work on this 🙂
cc @camsim99
francois-robert commentedon Jun 14, 2023
Still an issue in flutter 3.10.0, is there a workaround available ?
dkobia commentedon Jun 16, 2023
Here's what seems to work for me so far:
FlutterFragmentActivitytoFlutterActivityin MainActivity.kthampsterx commentedon Jun 17, 2023
This is still the recommended way for some packages, eg
local_authand hence why this ticket was created.#43921
Seems semi related maybe..
flutter-triage-bot commentedon Jul 13, 2023
This issue is marked P1 but has had no recent status updates.
The P1 label indicates high-priority issues that are at the top of the work list. This is the highest priority level a bug can have if it isn't affecting a top-tier customer or breaking the build. Bugs marked P1 are generally actively being worked on unless the assignee is dealing with a P0 bug (or another P1 bug). Issues at this level should be resolved in a matter of months and should have monthly updates on GitHub.
Please consider where this bug really falls in our current priorities, and label it or assign it accordingly. This allows people to have a clearer picture of what work is actually planned. Thanks!
[integration_test] Allow capture of screenshots for `FlutterFragmentA…
github-actions commentedon Sep 25, 2023
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.