Skip to content

integration_test screenshot Android - FlutterFragmentActivity - PlatformException(Could not copy the pixels, FlutterView is null)  #89683

@hampsterx

Description

@hampsterx

Steps to Reproduce

  1. flutter create test
  2. Change MainActivity to use FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {

    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }
}
  1. Add integration_test, test_driver as per https://github.com/flutter/flutter/tree/master/packages/integration_test
  2. 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!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsf: integration_testThe flutter/packages/integration_test pluginfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions