-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Doc comment for Isolate.spawn is incorrect #35143
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
Comments
The documentation is correct, the implementation is not correct. This has been an old bug against the VM that has not been addressed (see the issues that @nex3 points to above). "In the special circumstances when two isolates share the same code and are running in the same process (e.g. isolates created via Isolate.spawn), it is also possible to send object instances (which would be copied in the process). This is currently only supported by the dartvm. For now, the dart2js compiler only supports the restricted messages described above" This dictates that isolates spawned using Isolate.spawn should share the same code. |
@a-siva - will we have the resources to fix the implementation soon? If not, should we add a note to the doc calling out the bug on the VM? As it stands with the documentation it's very confusing. |
This also came up in #31698 |
I'm working on fixing this right now. |
The comment says "Creates and spawns an isolate that shares the same code as the current isolate."
This isn't true. What it should say (at least in the case with the VM, I have not tried AOT) is "Creates and spawns an isolate that rereads the same entrypoint as the current isolate."
If I write a Dart script that overwrites itself while running and then calls
Isolate.spawn
I can see it running the new version of the file I wrote, which is not the same code as the calling isolate is running.Am I correct to assume this is a memory optimization to avoid keeping parse state that we don't need and therefore needing to reread the original file? This does incur a heavy performance penalty when running the original script from source.
The text was updated successfully, but these errors were encountered: