From f13ff271983424d5d8bf3b04ec48bcb37f970725 Mon Sep 17 00:00:00 2001 From: Kevin Chisholm Date: Tue, 2 Jul 2024 10:22:57 -0500 Subject: [PATCH 1/6] Update Dart SDK to 60465149414572c8ca189d8f65fdb39795c4b97d --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index a988bbe890b01..66b204fa3a0bf 100644 --- a/DEPS +++ b/DEPS @@ -62,7 +62,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': '1a849f91804e73a830844a5bf546a3f7027fc36d', + 'dart_revision': '60465149414572c8ca189d8f65fdb39795c4b97d', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py From 6782119f97b1ca044b5dace116911c4bc60ea874 Mon Sep 17 00:00:00 2001 From: Kevin Chisholm Date: Tue, 2 Jul 2024 10:52:36 -0500 Subject: [PATCH 2/6] update license --- ci/licenses_golden/licenses_dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/licenses_golden/licenses_dart b/ci/licenses_golden/licenses_dart index cd2c02ce3c7b3..0bc4854a4e14e 100644 --- a/ci/licenses_golden/licenses_dart +++ b/ci/licenses_golden/licenses_dart @@ -1,4 +1,4 @@ -Signature: accf41e49999ccd363df249912f8747d +Signature: 552d859824fc2f0be0e5dbb43822a548 ==================================================================================================== LIBRARY: dart From 9b3dfe95b2ca9763851b25ec5c18422db80b526f Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Mon, 10 Jun 2024 15:58:43 +0200 Subject: [PATCH 3/6] Use dart.library.html to distinguish dart2wasm from dart2js/ddc in conditional imports (#53307) Users of packages that have specialized code for the VM (which supports FFI) use conditional imports based on `dart.library.ffi`. We don't want the VM-specific code to be used for web in dart2wasm. As a result we're going to make `dart.library.ffi` be false in conditional imports (as well as in `const bool.fromEnvironment('dart.library.ffi')`). Issue https://github.com/dart-lang/sdk/issues/55948 Issue https://github.com/flutter/flutter/issues/149984 --- lib/web_ui/lib/src/engine/renderer.dart | 2 +- lib/web_ui/test/ui/utils.dart | 3 +-- web_sdk/sdk_rewriter.dart | 2 +- web_sdk/test/sdk_rewriter_test.dart | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/web_ui/lib/src/engine/renderer.dart b/lib/web_ui/lib/src/engine/renderer.dart index fd62aaac8b6bb..246ed9b6d1ab1 100644 --- a/lib/web_ui/lib/src/engine/renderer.dart +++ b/lib/web_ui/lib/src/engine/renderer.dart @@ -7,7 +7,7 @@ import 'dart:math' as math; import 'dart:typed_data'; import 'package:ui/src/engine.dart'; -import 'package:ui/src/engine/skwasm/skwasm_stub.dart' if (dart.library.ffi) 'package:ui/src/engine/skwasm/skwasm_impl.dart'; +import 'package:ui/src/engine/skwasm/skwasm_impl.dart' if (dart.library.html) 'package:ui/src/engine/skwasm/skwasm_stub.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/ui_web/src/ui_web.dart' as ui_web; diff --git a/lib/web_ui/test/ui/utils.dart b/lib/web_ui/test/ui/utils.dart index ec7eaf4c0aed8..62e142de8a22b 100644 --- a/lib/web_ui/test/ui/utils.dart +++ b/lib/web_ui/test/ui/utils.dart @@ -5,8 +5,7 @@ import 'dart:async'; import 'package:ui/src/engine.dart'; -import 'package:ui/src/engine/skwasm/skwasm_stub.dart' - if (dart.library.ffi) 'package:ui/src/engine/skwasm/skwasm_impl.dart'; +import 'package:ui/src/engine/skwasm/skwasm_impl.dart' if (dart.library.html) 'package:ui/src/engine/skwasm/skwasm_stub.dart'; import 'package:ui/ui.dart'; import '../common/rendering.dart'; diff --git a/web_sdk/sdk_rewriter.dart b/web_sdk/sdk_rewriter.dart index 119f38239ca97..bb69a4cdaf471 100644 --- a/web_sdk/sdk_rewriter.dart +++ b/web_sdk/sdk_rewriter.dart @@ -102,7 +102,7 @@ const Set rootLibraryNames = { }; final Map extraImportsMap = { - RegExp('skwasm_(stub|impl)'): "import 'dart:_skwasm_stub' if (dart.library.ffi) 'dart:_skwasm_impl';", + RegExp('skwasm_(stub|impl)'): "import 'dart:_skwasm_impl' if (dart.library.html) 'dart:_skwasm_stub';", 'ui_web': "import 'dart:ui_web' as ui_web;", 'engine': "import 'dart:_engine';", 'web_unicode': "import 'dart:_web_unicode';", diff --git a/web_sdk/test/sdk_rewriter_test.dart b/web_sdk/test/sdk_rewriter_test.dart index 95cfe8256f9cd..cc1eae42607c8 100644 --- a/web_sdk/test/sdk_rewriter_test.dart +++ b/web_sdk/test/sdk_rewriter_test.dart @@ -165,7 +165,7 @@ void printSomething() { test('gets correct extra imports', () { // Root libraries. expect(getExtraImportsForLibrary('engine'), [ - "import 'dart:_skwasm_stub' if (dart.library.ffi) 'dart:_skwasm_impl';", + "import 'dart:_skwasm_impl' if (dart.library.html) 'dart:_skwasm_stub';", "import 'dart:ui_web' as ui_web;", "import 'dart:_web_unicode';", "import 'dart:_web_test_fonts';", From d11ae15f59bb8a2d733dbef9ea094de7394ea395 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 11 Jul 2024 16:13:19 -0700 Subject: [PATCH 4/6] Port over browser_detection.dart changes --- lib/web_ui/lib/src/engine/browser_detection.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/web_ui/lib/src/engine/browser_detection.dart b/lib/web_ui/lib/src/engine/browser_detection.dart index e248969a7c83d..82fa975a2e915 100644 --- a/lib/web_ui/lib/src/engine/browser_detection.dart +++ b/lib/web_ui/lib/src/engine/browser_detection.dart @@ -269,9 +269,7 @@ bool get isFirefox => browserEngine == BrowserEngine.firefox; bool get isEdge => domWindow.navigator.userAgent.contains('Edg/'); /// Whether we are running from a wasm module compiled with dart2wasm. -/// Note: Currently the ffi library is available from dart2wasm but not dart2js -/// or dartdevc. -bool get isWasm => const bool.fromEnvironment('dart.library.ffi'); +bool get isWasm => !const bool.fromEnvironment('dart.library.html'); /// Use in tests to simulate the detection of iOS 15. bool? debugIsIOS15; From 133e8a80d1dcb109c06810ac32888229579f3c0a Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Mon, 10 Jun 2024 14:08:35 +0200 Subject: [PATCH 5/6] Use new dart:js_interop way to externalize/internalize objects (#53304) The issue in [0] was fixed. So we no longer have to use conditional imports and dart2wasm vs dart2js specific implementations. Instead we use the new extension methods introduced due to [0], namely `Object.toExternalReference` and `ExternalDartReference.toDartObject`. [0] https://github.com/dart-lang/sdk/issues/55183 --- ci/licenses_golden/licenses_flutter | 4 ---- .../src/engine/canvaskit/native_memory.dart | 6 +++--- lib/web_ui/lib/src/engine/dom.dart | 19 ++++--------------- .../lib/src/engine/skwasm/skwasm_impl.dart | 1 - .../skwasm_impl/dart_js_conversion.dart | 16 ---------------- .../src/engine/skwasm/skwasm_impl/memory.dart | 10 +++++----- .../lib/src/engine/skwasm/skwasm_stub.dart | 1 - .../skwasm_stub/dart_js_conversion.dart | 13 ------------- .../test/canvaskit/canvaskit_api_test.dart | 2 +- 9 files changed, 13 insertions(+), 59 deletions(-) delete mode 100644 lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart delete mode 100644 lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index feb7ecc75b01c..2056e2ba89435 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -40602,7 +40602,6 @@ ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/shadow.dart + ../../../flutte ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/canvas.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/codecs.dart + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/filters.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/image.dart + ../../../flutter/LICENSE @@ -40639,7 +40638,6 @@ ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/shaders.da ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/vertices.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/renderer.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/svg.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/test_embedding.dart + ../../../flutter/LICENSE @@ -43484,7 +43482,6 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/shadow.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/canvas.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/codecs.dart -FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/filters.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/image.dart @@ -43521,7 +43518,6 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/shaders.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/vertices.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart -FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/renderer.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/svg.dart FILE: ../../../flutter/lib/web_ui/lib/src/engine/test_embedding.dart diff --git a/lib/web_ui/lib/src/engine/canvaskit/native_memory.dart b/lib/web_ui/lib/src/engine/canvaskit/native_memory.dart index c1e592d242921..8af6b3aaa5532 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/native_memory.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/native_memory.dart @@ -21,8 +21,8 @@ import 'package:ui/src/engine.dart'; /// 5. The finalizer function is called with the SkPaint as the sole argument. /// 6. We call `delete` on SkPaint. DomFinalizationRegistry _finalizationRegistry = DomFinalizationRegistry( - (JSAny boxedUniq) { - final UniqueRef uniq = boxedUniq.fromJSWrapper as UniqueRef; + (ExternalDartReference boxedUniq) { + final UniqueRef uniq = boxedUniq.toDartObject as UniqueRef; uniq.collect(); }.toJS ); @@ -34,7 +34,7 @@ NativeMemoryFinalizationRegistry nativeMemoryFinalizationRegistry = NativeMemory class NativeMemoryFinalizationRegistry { void register(Object owner, UniqueRef ref) { if (browserSupportsFinalizationRegistry) { - _finalizationRegistry.register(owner.toJSWrapper, ref.toJSWrapper); + _finalizationRegistry.register(owner.toExternalReference, ref.toExternalReference); } } } diff --git a/lib/web_ui/lib/src/engine/dom.dart b/lib/web_ui/lib/src/engine/dom.dart index 8dfa57b2a9420..5ad14fa1bdfe2 100644 --- a/lib/web_ui/lib/src/engine/dom.dart +++ b/lib/web_ui/lib/src/engine/dom.dart @@ -9,7 +9,6 @@ import 'dart:typed_data'; import 'package:js/js_util.dart' as js_util; import 'package:meta/meta.dart'; -import 'package:ui/src/engine/skwasm/skwasm_stub.dart' if (dart.library.ffi) 'package:ui/src/engine/skwasm/skwasm_impl.dart'; import 'browser_detection.dart'; @@ -38,13 +37,6 @@ import 'browser_detection.dart'; /// used carefully and only on types that are known to not contains `JSNull` and /// `JSUndefined`. extension ObjectToJSAnyExtension on Object { - // Once `Object.toJSBox` is faster (see - // https://github.com/dart-lang/sdk/issues/55183) we can remove this - // backend-specific workaround. - @pragma('wasm:prefer-inline') - @pragma('dart2js:tryInline') - JSAny get toJSWrapper => dartToJsWrapper(this); - @pragma('wasm:prefer-inline') @pragma('dart2js:tryInline') JSAny get toJSAnyShallow { @@ -61,10 +53,6 @@ extension ObjectToJSAnyExtension on Object { } extension JSAnyToObjectExtension on JSAny { - @pragma('wasm:prefer-inline') - @pragma('dart2js:tryInline') - Object get fromJSWrapper => jsWrapperToDart(this); - @pragma('wasm:prefer-inline') @pragma('dart2js:tryInline') Object get toObjectShallow { @@ -3674,13 +3662,14 @@ class DomFinalizationRegistry { extension DomFinalizationRegistryExtension on DomFinalizationRegistry { @JS('register') - external JSVoid register(JSAny target, JSAny value); + external JSVoid register( + ExternalDartReference target, ExternalDartReference value); @JS('register') - external JSVoid registerWithToken(JSAny target, JSAny value, JSAny token); + external JSVoid registerWithToken(ExternalDartReference target, ExternalDartReference value, ExternalDartReference token); @JS('unregister') - external JSVoid unregister(JSAny token); + external JSVoid unregister(ExternalDartReference token); } @JS('window.FinalizationRegistry') diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart index e36e4359c67bc..fd370c7a0fb18 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart @@ -11,7 +11,6 @@ import 'dart:ffi'; export 'skwasm_impl/canvas.dart'; export 'skwasm_impl/codecs.dart'; -export 'skwasm_impl/dart_js_conversion.dart'; export 'skwasm_impl/filters.dart'; export 'skwasm_impl/font_collection.dart'; export 'skwasm_impl/image.dart'; diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart deleted file mode 100644 index dbde1bee5cd5d..0000000000000 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/dart_js_conversion.dart +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:_wasm'; -import 'dart:js_interop'; - -@pragma('wasm:prefer-inline') -@pragma('dart2js:tryInline') -JSAny dartToJsWrapper(Object object) => - WasmAnyRef.fromObject(object).externalize().toJS; - -@pragma('wasm:prefer-inline') -@pragma('dart2js:tryInline') -Object jsWrapperToDart(JSAny jsWrapper) => - externRefForJSAny(jsWrapper).internalize()!.toObject(); diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart index c0f9a8470b3ba..ef60ac0ae7c82 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/memory.dart @@ -28,21 +28,21 @@ typedef DisposeFunction = void Function(Pointer); class SkwasmFinalizationRegistry { SkwasmFinalizationRegistry(this.dispose) - : registry = DomFinalizationRegistry(((JSNumber address) => - dispose(Pointer.fromAddress(address.toDartDouble.toInt())) + : registry = DomFinalizationRegistry(((ExternalDartReference address) => + dispose(Pointer.fromAddress(address.toDartObject as int)) ).toJS); final DomFinalizationRegistry registry; final DisposeFunction dispose; void register(SkwasmObjectWrapper wrapper) { - final JSAny jsWrapper = wrapper.toJSWrapper; + final ExternalDartReference jsWrapper = wrapper.toExternalReference; registry.registerWithToken( - jsWrapper, wrapper.handle.address.toJS, jsWrapper); + jsWrapper, wrapper.handle.address.toExternalReference, jsWrapper); } void evict(SkwasmObjectWrapper wrapper) { - final JSAny jsWrapper = wrapper.toJSWrapper; + final ExternalDartReference jsWrapper = wrapper.toExternalReference; registry.unregister(jsWrapper); dispose(wrapper.handle); } diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart index 50c1791aecc2e..382d34840e9f6 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart @@ -6,5 +6,4 @@ // ignore: unnecessary_library_directive library skwasm_stub; -export 'skwasm_stub/dart_js_conversion.dart'; export 'skwasm_stub/renderer.dart'; diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart deleted file mode 100644 index b05af5dcff599..0000000000000 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_stub/dart_js_conversion.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:js_interop'; - -@pragma('wasm:prefer-inline') -@pragma('dart2js:tryInline') -JSAny dartToJsWrapper(Object object) => object as JSAny; - -@pragma('wasm:prefer-inline') -@pragma('dart2js:tryInline') -Object jsWrapperToDart(JSAny jsWrapper) => jsWrapper; diff --git a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart index 69d9f6bf85967..4128b0d787a65 100644 --- a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart +++ b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart @@ -1929,7 +1929,7 @@ void _paragraphTests() { // So the test simply tests that a FinalizationRegistry can be constructed // and its `register` method can be called. final DomFinalizationRegistry registry = DomFinalizationRegistry((String arg) {}.toJS); - registry.register(Object().toJSWrapper, Object().toJSWrapper); + registry.register(Object().toExternalReference, Object().toExternalReference); }); } From 2bebadaf3c1ec9a2eda34ab5cf8dfef9df4fffed Mon Sep 17 00:00:00 2001 From: Christopher Fujino Date: Fri, 12 Jul 2024 13:13:39 -0700 Subject: [PATCH 6/6] delete Impeller golden tests --- ci/builders/mac_host_engine.json | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/ci/builders/mac_host_engine.json b/ci/builders/mac_host_engine.json index c12a0632a134d..1be08db10e599 100644 --- a/ci/builders/mac_host_engine.json +++ b/ci/builders/mac_host_engine.json @@ -176,20 +176,7 @@ "$flutter/osx_sdk": { "sdk_version": "15a240d" } - }, - "tests": [ - { - "language": "python3", - "name": "Impeller-golden, dart and engine tests for host_release", - "script": "flutter/testing/run_tests.py", - "parameters": [ - "--variant", - "host_release", - "--type", - "dart,dart-host,engine,impeller-golden" - ] - } - ] + } }, { "archives": [