Skip to content

Problem taking a .toImage() screenshot of a widget that contains the CameraPreview. #18989

@eduardkieser

Description

@eduardkieser

Steps to Reproduce

  1. Create a widget that contains a CameraPreview.
  2. Try to take a screenshot using this method: https://docs.flutter.io/flutter/rendering/RenderRepaintBoundary/toImage.html
  3. I made a small demo app that can be found at: https://gist.github.com/eduardkieser/ffea183945d56f537d789888008cbc4e (You can move the blue square around)
  4. Short video here: https://www.youtube.com/watch?v=CWBLjCwH5c0

Expected Behaviour: That the screenshot should include the CameraPreview.
Actual behaviour: The screenshot contains painted widgets, but no Camera data.

Logs

Performing hot restart...
[+7732 ms] Refreshing active FlutterViews before restarting.
[        ] _flutter.listViews: {isolateId: isolates/301279252}
[ +405 ms] DevFS: Starting sync from LocalDirectory: 'C:\Users\Eduard\Google Drive\WorkSpaces\flutter\widget_paint_test'
[        ] Scanning project files
[        ] Scanning package files
[  +45 ms] Scanning asset files
[        ] Scanning for deleted files
[  +22 ms] Compiling dart to kernel with 0 updated files
[ +190 ms] Updating files
[ +603 ms] DevFS: Sync finished
[        ] Synced 0.0MB.
[        ] getIsolate: {isolateId: isolates/301279252}
[  +44 ms] _flutter.runInView: {viewId: _flutterView/0x725824b498, mainScript: /data/user/0/com.kieserengineering.widgetpainttest/cache/widget_paint_testEDMOVU/widget_paint_test/lib/bugExample.dart.dill, packagesFile: /data/user/0/com.kieserengineering.widgetpainttest/cache/widget_paint_testEDMOVU/widget_paint_test/.packages, assetDirectory: /data/user/0/com.kieserengineering.widgetpainttest/cache/widget_paint_testEDMOVU/widget_paint_test/build/flutter_assets}
[ +595 ms] {streamId: Isolate, event: {type: Event, kind: IsolateStart, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531814327}}
[   +3 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531814332, extensionRPC: ext.ui.window.scheduleFrame}}
[   +1 ms] getIsolate: {isolateId: isolates/513879693}
[   +2 ms] {streamId: Isolate, event: {type: Event, kind: IsolateExit, isolate: {type: @Isolate, fixedId: true, id: isolates/301279252, name: main.dart:main(), number: 301279252}, timestamp: 1530531814348}}
[        ] {streamId: Isolate, event: {type: Event, kind: IsolateRunnable, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531814611}}
[        ] Isolate is runnable.
[        ] _flutter.listViews: {isolateId: isolates/513879693}
[  +61 ms] Restart performed in 1 952ms.
[   +3 ms] Restarted app in 1 987ms.
[ +381 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815095, extensionRPC: ext.flutter.reassemble}}
[   +2 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815095, extensionRPC: ext.flutter.exit}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815095, extensionRPC: ext.flutter.frameworkPresent}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815095, extensionRPC: ext.flutter.platformOverride}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815096, extensionRPC: ext.flutter.evict}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815096, extensionRPC: ext.flutter.timeDilation}}
[   +1 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugPaint}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugPaintBaselinesEnabled}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.repaintRainbow}}
[   +2 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugDumpRenderTree}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugDumpLayerTree}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugDumpSemanticsTreeInTraversalOrder}}
[   +2 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugDumpSemanticsTreeInInverseHitTestOrder}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugDumpApp}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.showPerformanceOverlay}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugAllowBanner}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815097, extensionRPC: ext.flutter.debugWidgetInspector}}
[   +3 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815102, extensionRPC: ext.flutter.inspector.show}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815103, extensionRPC: ext.flutter.inspector.disposeAllGroups}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815103, extensionRPC: ext.flutter.inspector.disposeGroup}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815103, extensionRPC: ext.flutter.inspector.isWidgetTreeReady}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815104, extensionRPC: ext.flutter.inspector.disposeId}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815104, extensionRPC: ext.flutter.inspector.setPubRootDirectories}}
[   +2 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815104, extensionRPC: ext.flutter.inspector.setSelectionById}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815104, extensionRPC: ext.flutter.inspector.getParentChain}}
[   +3 ms] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815108, extensionRPC: ext.flutter.inspector.getProperties}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getChildren}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getChildrenSummaryTree}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getChildrenDetailsSubtree}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getRootWidget}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getRootRenderObject}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getRootWidgetSummaryTree}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getDetailsSubtree}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getSelectedRenderObject}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815109, extensionRPC: ext.flutter.inspector.getSelectedWidget}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815110, extensionRPC: ext.flutter.inspector.getSelectedSummaryWidget}}
[        ] {streamId: Isolate, event: {type: Event, kind: ServiceExtensionAdded, isolate: {type: @Isolate, fixedId: true, id: isolates/513879693, name: main.dart:main(), number: 513879693}, timestamp: 1530531815110, extensionRPC: ext.flutter.inspector.isWidgetCreationTracked}}
[        ] ext.flutter.inspector.setPubRootDirectories: {arg0: file:///C:/Users/Eduard/Google Drive/WorkSpaces/flutter/widget_paint_test, isolateId: isolates/513879693}
[ +532 ms] E/libc    ( 3950): Access denied finding property "persist.camera.cfa.packagelist"
[        ] W/widgetpainttest( 3950): type=1400 audit(0.0:102586): avc: denied { read } for name="u:object_r:camera_prop:s0" dev="tmpfs" ino=22660 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:camera_prop:s0 tclass=file permissive=0
[ +147 ms] ext.flutter.inspector.getSelectedSummaryWidget: {objectGroup: selection_214, isolateId: isolates/513879693}
[  +31 ms] ext.flutter.inspector.getSelectedWidget: {objectGroup: selection_214, isolateId: isolates/513879693}
[  +15 ms] ext.flutter.inspector.getRootWidgetSummaryTree: {objectGroup: tree_215, isolateId: isolates/513879693}
[+2738 ms] I/zygote64( 3950): Do full code cache collection, code=123KB, data=83KB
[   +1 ms] I/zygote64( 3950): After code cache collection, code=116KB, data=72KB
[+9214 ms] I/zygote64( 3950): Do partial code cache collection, code=122KB, data=77KB
[        ] I/zygote64( 3950): After code cache collection, code=122KB, data=77KB
[        ] I/zygote64( 3950): Increasing code cache capacity to 512KB

All the issues look like they are related to other files (i didn't create a separate project for the example code...

Analyzing widget_paint_test...

   info - Unused import: 'dart:async' - lib\display_window.dart:4:8
   info - Unused import: 'dart:typed_data' - lib\display_window.dart:6:8
   info - This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final) - lib\display_window.dart:10:7
   info - The value of the field '_offset' isn't used - lib\display_window.dart:41:10
   info - The method '_toggleActive' isn't used - lib\display_window.dart:113:8
   info - Unused import: 'GlobalState.dart' - lib\main.dart:2:8
   info - Avoid using braces in interpolation when not needed - lib\mlkit_minimum_test.dart:127:16
   info - Avoid using braces in interpolation when not needed - lib\mlkit_minimum_test.dart:160:34
   info - Avoid using braces in interpolation when not needed - lib\mlkit_minimum_test.dart:172:22
   info - Avoid using braces in interpolation when not needed - lib\mlkit_minimum_test.dart:176:21
   info - Avoid using braces in interpolation when not needed - lib\mlkit_minimum_test.dart:177:28
   info - Avoid using braces in interpolation when not needed - lib\mlkit_minimum_test.dart:181:29
   info - This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final) - lib\roi_window.dart:5:7
   info - The value of the field '_implementationType' isn't used - lib\roi_window.dart:34:7
   info - The value of the field '_offset' isn't used - lib\roi_window.dart:36:10
   info - Unused import: 'diagonally_movable_button.dart' - lib\stack_test.dart:2:8
   info - Unused import: 'package:mlkit/mlkit.dart' - lib\stack_test.dart:7:8
   info - Unused import: 'dart:typed_data' - lib\stack_test.dart:11:8
   info - Unused import: 'display_window.dart' - lib\stack_test.dart:13:8
   info - Avoid using braces in interpolation when not needed - lib\stack_test.dart:129:44
   info - Unused import: 'package:widget_paint_test/main.dart' - test\widget_test.dart:10:8
  error - The constructor returns type 'dynamic' that isn't of expected type 'Widget' - test\widget_test.dart:15:29
  error - Undefined class 'MyApp' - test\widget_test.dart:15:33

23 issues found. (ran in 10.7s)

C:\Users\Eduard\Google Drive\WorkSpaces\flutter\widget_paint_test>flutter doctor -v
[√] Flutter (Channel beta, v0.5.1, on Microsoft Windows [Version 10.0.16299.492], locale en-ZA)
    • Flutter version 0.5.1 at C:\Program Files\Android\flutter
    • Framework revision c7ea3ca377 (5 weeks ago), 2018-05-29 21:07:33 +0200
    • Engine revision 1ed25ca7b7
    • Dart version 2.0.0-dev.58.0.flutter-f981f09760

[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at C:\Users\Eduard\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    • All Android licenses accepted.

[√] Android Studio (version 3.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 25.0.1
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[√] IntelliJ IDEA Community Edition (version 2017.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4
    • Flutter plugin version 24.2.1
    • Dart plugin version 173.4700

[√] Connected devices (1 available)
    • ONEPLUS A5000 • 77cd7290 • android-arm64 • Android 8.1.0 (API 27)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.engineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.p: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions