-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[web] Avoid using js_util.{jsify,dartify}()
in dart2wasm for converting to JS wrappers
#51375
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Something fishy going on with the imports - possibly due to this |
Not sure why some things fail here and not sure whether it's worthwhile to debug. Web/Interop team seems open to my suggestion on dart-lang/sdk#55183 / dart-lang/sdk#55187 - if a new API gets added, we can replace this PR by calling the new API. |
…ting to JS wrappers The `js_util.jsify()` related code shows up in CPU profile of wonderous. => Any `SkwasmObjectWrapper` object invokes this logic in the constructor and dispose method. This PR * makes `DomFinalizationRegistryExtension` accept JSAny types instead of Dart types and internally converting => Callsites can call more precise `<>.toJS*` extension methods => Avoids extra type checks on the objects * avoids making `toJSAnyShallow` delegate to `toJSAnyDeep` in wasm => `toJSAnyDeep` uses `js_util.jsify()` which is slow => We cannot use `Object.toJSBox` due to it being slower to create JS boxes as it semantically does something different atm (see issue below) => Instead use conditional import of `dart:_wasm` which provides the necessary primitives => Similar for going from JS to Dart. * Avoid calling converting from Dart object to JSAny more than needed (we did the operation twice for each registration and once for unregistration) Issue dart-lang/sdk#55183 change condition move
…rapper & use only in finalization code
It appears some existing flutter web engine code uses the So I've kept the old implementation and added a |
@eyebrowsoffire I've made the PR now only affect finalizer code (which I saw on cpu profile), ( thereby not affecting other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks, @eyebrowsoffire ! |
…for converting to JS wrappers (flutter/engine#51375)
…145365) flutter/engine@89df726...0ee413e 2024-03-18 [email protected] A native Android unit-testing harness. (flutter/engine#51479) 2024-03-18 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Fuchsia] only download fuchsia deps when necessary (#51439)" (flutter/engine#51500) 2024-03-18 [email protected] [web] Avoid using `js_util.{jsify,dartify}()` in dart2wasm for converting to JS wrappers (flutter/engine#51375) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
The
js_util.jsify()
related code shows up in CPU profile of wonderous.=> Any
SkwasmObjectWrapper
object invokes this logic in the constructor and dispose method.This PR
makes
DomFinalizationRegistryExtension
acceptJSAny
types instead of Dart types and internally converting=> Callsites can call more precise
<>.toJS*
extension methods=> Will avoids extra type checks on the objects when we can call
Object.toJSBox
directlyavoids making
toJSAnyShallow
delegate totoJSAnyDeep
in wasm=>
toJSAnyDeep
usesjs_util.jsify()
which is slow=> We cannot use
Object.toJSBox
due to it being slower to create JS boxes as it semantically does something different atm (see issue below)=> Instead use conditional import of
dart:_wasm
which provides the necessary primitives=> Similar for going from JS to Dart.
Avoid calling converting from Dart object to
JSAny
more than needed (we did the operation twice for each registration and once for unregistration)Issue dart-lang/sdk#55183