Skip to content

Picture.toImage fails for --web-renderer html #110599

@polina-c

Description

@polina-c

Steps to repro:

  1. Create new flutter app with 'flutter create'
  2. Create method 'exerciseGraphics':
import 'dart:ui' as ui;

Future<void> exerciseGraphics() async {
  final image = await _createImage();
  print('${image.runtimeType}');
}

Future<ui.Image> _createImage() => _createPicture().toImage(10, 10);

ui.Picture _createPicture() {
  final ui.PictureRecorder recorder = ui.PictureRecorder();
  final ui.Canvas canvas = ui.Canvas(recorder);
  const ui.Rect rect = ui.Rect.fromLTWH(0.0, 0.0, 100.0, 100.0);
  canvas.clipRect(rect);
  return recorder.endRecording();
}
  1. Invoke it in incrementCounter:
void _incrementCounter() async {
    await exerciseGraphics();
    setState(() {
      _counter++;
    });
  }
  1. Run application with html renderer:
flutter run -d chrome --web-renderer html
  1. Click the button '+' and get the error in console:
Error: [object Event]
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 299:10  createErrorWithStack
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 341:28            _throw
dart-sdk/lib/core/errors.dart 116:5                                           throwWithStackTrace
dart-sdk/lib/async/zone.dart 1385:11                                          callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>
  1. Check the code works for canvas renderer:
flutter run -d chrome

See the full example at: https://github.com/polina-c/spikes/tree/master/graphics

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: imagesLoading, displaying, rendering imagesc: renderingUI glitches reported at the engine/skia or impeller rendering levele: web_htmlHTML rendering backend for Webengineflutter/engine related. See also e: labels.platform-webWeb applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions