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

Extend deferred library imports to web workers #48813

Open
TheOneWithTheBraid opened this issue Apr 5, 2022 · 2 comments
Open

Extend deferred library imports to web workers #48813

TheOneWithTheBraid opened this issue Apr 5, 2022 · 2 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-enhancement A request for a change that isn't a bug web-dart2js web-dev-compiler

Comments

@TheOneWithTheBraid
Copy link

As of now, deferred library imports can tremendously speed up the initial load of web apps as well as the startup time of Flutter applications; they create much more modular binaries and allow to tweak performance of applications.

I would like to propose a similar approach for web worker support on web.

here, I could imagine of different approachs:

  • either expose isolates to web too by implementing them to compile like deferred libraries do - into file.dart.js_N.part.js (recommended)
  • compile to BLOB data URL (bad approach)

Alternatively, it an approach with a Isolate-like API does not work, a web worker specific interface could e.g. look like:

a) (recommended)

import 'package:js/js.dart';

@JSWorker('myworker.dart')
final worker = Worker('myworker.dart.js');

b) (bad approach)

import 'myworker.dart' deferred as worker using Worker;

This option would introduce a new import syntax extension exposing a using statement followed by some helper. That sounds like a bad alternative.

I would kindly ask to discuss the provided ideas on useful web worker support, as the current way to go is neither user, nor developer friendly.

@lrhn
Copy link
Member

lrhn commented Apr 15, 2022

I don't think adding new language features that only works on the web is going to fly.
As such, I'll move it to the SDK repository, and mark it as a request for the web compilation pipeline.

@lrhn lrhn transferred this issue from dart-lang/language Apr 15, 2022
@lrhn lrhn added type-enhancement A request for a change that isn't a bug area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Apr 15, 2022
@TheOneWithTheBraid
Copy link
Author

Couldn't Isolate.spawnUri be implemented comparably easily for web?

The provided library could be simply compiled into a standalone Dart file while having the compiler adding a corresponding communication channel using the onreceivemessage attribute from the WorkerGlobalScope?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-enhancement A request for a change that isn't a bug web-dart2js web-dev-compiler
Projects
None yet
Development

No branches or pull requests

3 participants