Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MakerealAsyncZone run microtasks and timers in the correct zone.#162731

Merged
auto-submit[bot] merged 2 commits intoflutter:masterfrom
lrhn:fix-real-async-zone
Mar 26, 2025
Merged

MakerealAsyncZone run microtasks and timers in the correct zone.#162731
auto-submit[bot] merged 2 commits intoflutter:masterfrom
lrhn:fix-real-async-zone

Conversation

@lrhn
Copy link
Contributor

@lrhnlrhn commentedFeb 5, 2025
edited
Loading

Current implementation runs timers and microtask callbacks in the root zone. That assumes that the top-levelscheduleMicrotask orTimer constructors have been used, which have so far wrapped the callback withrunCallbackGuarded before calling the zone implementation.
That means that doingzone.scheduleMicrotask directly would not ensure that the microtask was run in the correct zone. If arun handler throws, it wouldn't be caught.

This change makes therealAsyncZone do whatever the root zone would do if itsZoneDelegate got called with the intended zone and arguments. That should be consistent with the current behavior, and be compatible with incoming bug-fixes to the platformZone behavior.

Prepares Flutter for landinghttps://dart-review.googlesource.com/c/sdk/+/406961
which is currently blocked (so this indirectlyfixesdart-lang/sdk#59913).

There are no new tests, the goal is that all existing tests keep running, and that they keep doing so when the Dart CL lands. Currently that CL only breaks one test, thedev/automated_tests/test_smoke_test/fail_test_on_exception_after_test.dart test which threw the error-after-test in the root zone instead of the test zone. This change fixes that.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel inDiscord (don't just cc them here, they won't see it!).

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 theTree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, soall reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actionsgithub-actionsbot added a: tests"flutter test", flutter_test, or one of our tests frameworkflutter/packages/flutter repository. See also f: labels. labelsFeb 5, 2025
specification: ZoneSpecification(
scheduleMicrotask: (Zone self, ZoneDelegate parent, Zone zone, void Function() f) {
Zone.root.scheduleMicrotask(f);
_rootDelegate.scheduleMicrotask(zone,f);
Copy link
ContributorAuthor

@lrhnlrhnFeb 6, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This could have just doneZone.root.scheduleMicrotask(zone.bindCallbackGuarded(f)), but that's not necessarily the same as whatrootDelegate.scheduleMicrotask(zone, f) does.
ThebindCallbackGuarded does an extraZone.registerCalback, and an extraZone.run on top of what the root zone'sscheduleMicrotask would already do.

Using the root zone's delegate ensures that it does exactly the same as ifzone had been a direct child of the root zone, just bypassing the intermediate zones in order to get "real" async operations.
It's a "more correct" approach to bypassing the surrounding zone's overloads of microtasks and timers, while still using its intendedregisterMicrotask andrun behaviores.

@stuartmorgan-g
Copy link
Contributor

test-exempt: unblocks future roll

@lrhn
Copy link
ContributorAuthor

lrhn commentedFeb 6, 2025
edited
Loading

Come to think of it, I should be able to add a test that distinguishes the new behavior from the old if I call theZone.createTimer directly. (Until the Dart CL lands, using theTimer constructor will work the same in both cases.)

Done. Test added.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Clickhere to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visitWriting a golden file test forpackage:flutter.

Reviewers: Read theTree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request#162731 at shafaa51aa

@flutter-dashboardflutter-dashboardbot added the will affect goldensChanges to golden files labelFeb 6, 2025
@lrhn
Copy link
ContributorAuthor

lrhn commentedFeb 6, 2025
edited
Loading

Rebase on current master, hope it fixes golden file tests.

@lrhnlrhnforce-pushed thefix-real-async-zone branch 3 times, most recently fromec49c95 tob8d544dCompareFebruary 13, 2025 13:28
@lrhn
Copy link
ContributorAuthor

lrhn commentedFeb 13, 2025
edited
Loading

I'm not sure this actually affects goldens (and the triage link is dead).

What is the next step needed to land this? (This question still applies!)

@lrhnlrhnforce-pushed thefix-real-async-zone branch 2 times, most recently from3654429 toe2d301eCompareFebruary 18, 2025 13:57
@justinmcjustinmc removed the will affect goldensChanges to golden files labelFeb 18, 2025
@justinmc
Copy link
Contributor

Looks like the goldens check is good now? Removing the label.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Clickhere to view.

For more guidance, visitWriting a golden file test forpackage:flutter.

Reviewers: Read theTree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request#162731 at shaadb9107

@flutter-dashboardflutter-dashboardbot added the will affect goldensChanges to golden files labelFeb 19, 2025
Current implementation runs timers and microtask callbacks in the root zone.That assumes that the top-level `scheduleMicrotask` or `Timer` constructorshave been used, which have so far wrapped the callback with `runCallbackGuarded`before calling the zone implementation.That means that doing `zone.scheduleMicrotask` directly would not ensurethat the microtask was run in the correct zone. If a `run` handler throws,it wouldn't be caught.This change makes the `realAsyncZone` do whatever the root zone woulddo if its `ZoneDelegate` got called with the intended zone and arguments.That should be consistent with the current behavior, and be compatiblewith changes to the platform `Zone` behavior.
@lrhn
Copy link
ContributorAuthor

lrhn commentedMar 6, 2025
edited
Loading

PTAL. I believe the goldens mark is a false positive.
See#164982 which is the same change without the rebases.

Copy link
Contributor

@justinmcjustinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM from my point of view but I am not familiar with these async zones in the tests. Looks like the goldens check is passing now though.

@lrhn
Copy link
ContributorAuthor

Thanks. I'll need someone to land the change too. (If it's someone is familiar with the zones, they can look at it too.)

Copy link
Contributor

@jonahwilliamsjonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestApr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestApr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestApr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestApr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMay 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMay 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMay 21, 2025
zhangyuang pushed a commit to zhangyuang/flutter-fork that referenced this pull requestJun 9, 2025
…lutter#162731)Current implementation runs timers and microtask callbacks in the rootzone. That assumes that the top-level `scheduleMicrotask` or `Timer`constructors have been used, which have so far wrapped the callback with`runCallbackGuarded` before calling the zone implementation.That means that doing `zone.scheduleMicrotask` directly would not ensurethat the microtask was run in the correct zone. If a `run` handlerthrows, it wouldn't be caught.This change makes the `realAsyncZone` do whatever the root zone would doif its `ZoneDelegate` got called with the intended zone and arguments.That should be consistent with the current behavior, and be compatiblewith incoming bug-fixes to the platform `Zone` behavior.Prepares Flutter for landinghttps://dart-review.googlesource.com/c/sdk/+/406961which is currently blocked (so this indirectlyfixesdart-lang/sdk#59913).There are no new tests, the goal is that all existing tests keeprunning, and that they keep doing so when the Dart CL lands. Currentlythat CL only breaks one test, the`dev/automated_tests/test_smoke_test/fail_test_on_exception_after_test.dart`test which threw the error-after-test in the root zone instead of thetest zone. This change fixes that.
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull requestAug 14, 2025
…lutter#162731)Current implementation runs timers and microtask callbacks in the rootzone. That assumes that the top-level `scheduleMicrotask` or `Timer`constructors have been used, which have so far wrapped the callback with`runCallbackGuarded` before calling the zone implementation.That means that doing `zone.scheduleMicrotask` directly would not ensurethat the microtask was run in the correct zone. If a `run` handlerthrows, it wouldn't be caught.This change makes the `realAsyncZone` do whatever the root zone would doif its `ZoneDelegate` got called with the intended zone and arguments.That should be consistent with the current behavior, and be compatiblewith incoming bug-fixes to the platform `Zone` behavior.Prepares Flutter for landinghttps://dart-review.googlesource.com/c/sdk/+/406961which is currently blocked (so this indirectlyfixesdart-lang/sdk#59913).There are no new tests, the goal is that all existing tests keeprunning, and that they keep doing so when the Dart CL lands. Currentlythat CL only breaks one test, the`dev/automated_tests/test_smoke_test/fail_test_on_exception_after_test.dart`test which threw the error-after-test in the root zone instead of thetest zone. This change fixes that.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@justinmcjustinmcjustinmc approved these changes

+1 more reviewer

@jonahwilliamsjonahwilliamsjonahwilliams approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

a: tests"flutter test", flutter_test, or one of our testsframeworkflutter/packages/flutter repository. See also f: labels.will affect goldensChanges to golden files

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Errors are escaping the error zone when thrown from wrapped register* callbacks.

4 participants

@lrhn@stuartmorgan-g@justinmc@jonahwilliams

Comments


[8]ページ先頭

©2009-2026 Movatter.jp