-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Usibility issue with Isolate.run wrt to over-capturing #48566
Comments
@mit-mit Since this functionality is new, should we actually back this out and not ship it in 2.17 in its current state? If not, at a minimum the docs for the functionality probably deserve a disclaimer explaining this behavior. |
Ideally, the error message would also be more informative... |
I agree with @goderbauer that the current state is sub-optimal, but I believe a way to compute a single function in an Mostly, because of how difficult it is to handle all the edge cases and clean up the resources. Even the initial implementation here had one such problem, not to mention the solution Flutter's However, it might be worth reconsider changing the signature to be more inline with what But if a solutions like the one described above by @goderbauer will have to be written to avoid over-capturing, the ease of use really feels more like a trap than a feature. |
From offline conversation, it sounds like the direction will be to prioritize #36983 which should make this problem less serious and avoid a harder to use API. |
From offline discussion between @lrhn @mit-mit @mraleph about this and related issues:
And for now we'll remove |
@lrhn landed a new iteration of the It looks like the main usecase in #36983 was resolved. @goderbauer can you take a look at this and see if you think we can move forward with alignment with Flutter APIs? |
Can you remind me what the alignment plan was for this? |
I think there was a patch at some point to make |
Shall we go ahead with that alignment, @goderbauer @dnfield ? |
Yeah, that sounds good to me. Does one of you want to send a PR? :) |
@dnfield any chance you're able to create that PR? Lasse is tied up with Dart 3 core lib changes we have to get done next week weeks. |
@goderbauer can this issue be closed now? |
Isolate.run
is difficult to use because of #36983. When the closure provided toIsolate.run
captures unnecessary stuff (because of that bug) that can't be send to an isolate, the user only sees this cryptic message:It is not at all obvious that this is because the closure provided was over-capturing.
IMO, this is a major usability problem for
Isolate.run
because it is easy to use in a way that triggers the problem (especially in async/await contexts) and the solution is not clear from the error message.Example where I ran into this: https://github.com/goderbauer/scratchpad/blob/8d82e738a4307c65651dc854ec6437002f69d6ed/isoimg/lib/main.dart#L90-L92
To make it work, one has to define a static method to avoid over-capturing: goderbauer/scratchpad@e36c311
The text was updated successfully, but these errors were encountered: