Skip to content

createImageFromTextureSource throws on wasm with transferred ownership #183166

@curt-weber

Description

@curt-weber

Steps to reproduce

  1. create project with code sample below and add web to pubspec: web: ^1.1.1
  2. run with flutter run -d chrome --wasm

Expected results

Decode with and without ownership transfer

Actual results

error: Bad state: DataCloneError: Failed to execute 'postMessage' on 'Worker': Value at index 0 does not have a transferable type.

Had to switch to master to get details, stable just showed JavaScriptError

Code sample

Code sample
import 'dart:js_interop';
import 'dart:ui_web';
import 'package:flutter/widgets.dart';
import 'package:web/web.dart';

Future<void> main() async {
  runApp(const SizedBox.expand());
  final element = HTMLImageElement()
    ..crossOrigin = 'anonymous'
    ..src = 'https://picsum.photos/200/300';
  await element.decode().toDart;
  final image = await createImageFromTextureSource(
    element,
    height: element.height,
    transferOwnership: true, // TODO throws on wasm
    width: element.width,
  );
  print('${image.width}x${image.height}');
}

Screenshots or Video

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.42.0-1.0.pre-361, on Microsoft Windows [Version 10.0.26200.7840], locale en-US)
[√] Windows Version (Windows 11 or higher, 25H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.13.6)
[√] Connected device (3 available)
[√] Network resources

• No issues found!

Metadata

Metadata

Labels

P1High-priority issues at the top of the work liste: wasmIssues related to the wasm build of Flutter Web.engineflutter/engine related. See also e: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions