Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to take screenshot on flutter web #268

Open
linchen2chris opened this issue Oct 17, 2022 · 4 comments
Open

failed to take screenshot on flutter web #268

linchen2chris opened this issue Oct 17, 2022 · 4 comments

Comments

@linchen2chris
Copy link

linchen2chris commented Oct 17, 2022

Failed to take screenshot
Unexpected null value.
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49 throw
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 528:63 nullCheck
lib/_engine/engine/canvaskit/layer.dart 584:34 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 494:5 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 357:9 preroll
lib/_engine/engine/canvaskit/layer.dart 125:12 prerollChildren
lib/_engine/engine/canvaskit/layer.dart 114:19 preroll
lib/_engine/engine/canvaskit/layer_tree.dart 67:15 flatten
lib/_engine/engine/canvaskit/layer_scene_builder.dart 19:42 toImage
packages/flutter/src/rendering/layer.dart 1282:25 toImage
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter/src/rendering/layer.dart 1266:27 toImage
packages/flutter_gherkin/src/flutter/adapters/widget_tester_app_driver_adapter.dart 89:25 takeScreenshotUsingRenderElement
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_gherkin/src/flutter/adapters/widget_tester_app_driver_adapter.dart 75:53 takeScreenshotUsingRenderElement
packages/flutter_gherkin/src/flutter/adapters/widget_tester_app_driver_adapter.dart 111:20 screenshot
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_gherkin/src/flutter/adapters/widget_tester_app_driver_adapter.dart 99:31 screenshot
packages/flutter_gherkin/src/flutter/hooks/attach_screenshot_on_failed_step_hook.dart 26:31 _takeScreenshot
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_gherkin/src/flutter/hooks/attach_screenshot_on_failed_step_hook.dart 25:33 [_takeScreenshot]
packages/flutter_gherkin/src/flutter/hooks/attach_screenshot_on_failed_step_hook.dart 17:38 onAfterStep
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_gherkin/src/flutter/hooks/attach_screenshot_on_failed_step_hook.dart 8:27 onAfterStep
packages/gherkin/src/hooks/aggregated_hook.dart 87:28
packages/gherkin/src/hooks/aggregated_hook.dart 94:21 _invokeHooks
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/gherkin/src/hooks/aggregated_hook.dart 89:28 [_invokeHooks]
packages/gherkin/src/hooks/aggregated_hook.dart 87:7 onAfterStep
packages/flutter_gherkin/src/flutter/runners/gherkin_integration_test_runner.dart 478:16 _onAfterStepRun
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_gherkin/src/flutter/runners/gherkin_integration_test_runner.dart 473:31 [_onAfterStepRun]
packages/flutter_gherkin/src/flutter/runners/gherkin_integration_test_runner.dart 386:11 runStep
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_gherkin/src/flutter/runners/gherkin_integration_test_runner.dart 321:29 runStep
gherkin_suite_test.g.dart 44:28
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
gherkin_suite_test.g.dart 42:20
packages/flutter_gherkin/src/flutter/runners/gherkin_integration_test_runner.dart 224:45

@linchen2chris
Copy link
Author

flutter: 3.0.5
flutter_gherkin: 3.0.0-rc.17

@jonsamwell
Copy link
Owner

@linchen2chris are you able to provide a sample which reproduces this?

@linchen2chris
Copy link
Author

linchen2chris commented Oct 18, 2022

hi @jonsamwell thanks for your reply, afraid not, it only happen in our huge flutter web app.
the error occurs in 3.0.0rc17 wich screenshot function: takeScreenshotUsingRenderElement

I try 3.0.0rc16 which take screenshot function is

if (kIsWeb) {
      return binding.takeScreenshot(name);
    } else {
      if (Platform.isAndroid) {

and use driver

import 'dart:io';
import 'package:integration_test/integration_test_driver_extended.dart'
    as integration_test_driver;

Future<void> main() => integration_test_driver.integrationDriver(
      onScreenshot: (String screenshotName, List<int> screenshotBytes) async {
        final File image = await File('screenshots/$screenshotName.png')
            .create(recursive: true);
        image.writeAsBytesSync(screenshotBytes);
        return true;
      },
    );

then screenshot images will be generated in screenshot/ folder, but reports has not embeded image data

@linchen2chris
Copy link
Author

Hi @jonsamwell the example_with_integration_test also take screenshot in web release mode. takeScreenshotUsingRenderElement only works for debug mode. you could give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants