-
Notifications
You must be signed in to change notification settings - Fork 26
Determine how to wire up isolate state #164
Comments
Also needed this:
@sigmundch per the TODO. :-) |
is angular using isolates? Or it gets pulled in as part of something else (async?) |
dart2js uses the notion of an isolate always, similar to the vm: all code starts in a root isolate. So even if it's not used explicitly, there is some bootstraping code that will set up the initial isolate before running main. |
yeah, that makes sense. I wonder if we can make it lazy in that case? |
Possibly. Depending how we define what's the lazy trigger. Would that be when you spawn a second isolate? One use-case I'm thinking about is when we have 2 separately compiled apps in the same page. I have to look deeper into it, but it's possible that we use isolates in dart2js as the mechanism to support that. |
Unless such a use case makes sense for JavaScript code too, it's something we should not try to do. That way lies interop madness :) If it is something that makes sense for JS, it would probably be best to express it as a JS->JS transpiler phase. (Which we could totally integrate into our tools. No issues there.) |
Maybe. Although to be honest, I'm not entirely clear on what we mean by isolate. I definitely don't want to create abstracts that don't make sense in JS (our old DOM isolates come to mind, plus the general way Dart code was isolated from the JS world). Also don't want users to pay for abstractions they aren't using. On the other hand, we definitely want to expose Web Workers and IFrames. (though we probably get them mostly for free) |
@jmesserly We appear to hit this in the context of async, zones, and stack traces. More generally, we may want to rethink the model of multiple isolates and the DOM. Previously, we kind of took the Dartium notion that we already had separate JS and Dart isolates and ran with it. |
makes sense. yeah, Zones are super awesome. I wonder if we can reuse https://github.com/angular/zone.js ... the nice thing is it's opt in (e.g. add it to the page if zones are needed), so you don't pay for it if you don't use it |
A related issue which I'll just include here: spawnFunction effectively assumes all code is delivered in a single script - see isolate_helper.dart, computeThisScript. This won't work as is in DDC. |
Another related issue: js_helper.dart, convertDartClosureToJS wraps a Dart closure to record the source isolate. Not sure we need that either. |
removing angular label as (I think) a decent workaround is landed. |
What are the next steps here? Should subject should be something like "refactor private/isolate_helper.dart to only support worker isolates, not DOM isolates" ... ? |
I think there a few issues here to sort out: (1) What do we need to support the Dart event loop on a DOM thread? I believe we currently rely on this code to ensure that certain tasks run before we yield back to the browser's own event loop. (2) Do we really need to support multiple DOM isolates in the same frame? In general, I think this is a bad idea. This is only partially supported in Dartium. (3) Does spawnFunction make sense in the browser? If so, how do we support it? This is at least somewhat related to the module question - how do we tell the worker what code to load? dart2js assumes that the current script tag's src attribute contains all code. |
Awesome - thanks! Closing this one. |
The dart2js isolate library code relies on some trampoline code at startup to set isolate globalState.
I'm doing the following right now, but it'd be nice not to need this.
The text was updated successfully, but these errors were encountered: