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

refactor(core): Update coalescing to just use patched timers in root … #55366

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Apr 16, 2024

…zone

Rather than attempting to use the native timing functions, this commit simplifies the logic significantly by using the global timer functions as they are, either patched or unpatched. When Zone is defined, we run the timers in the root zone. This has more predictable behavior and timing than (a) using both patched and unpatched versions of timers in different places (b) trying to get an unpatched timer and failing due to environment specifics and patches that aren't ZoneJS.

@atscott atscott added target: patch This PR is targeted for the next patch release requires: TGP This PR requires a passing TGP before merging is allowed labels Apr 16, 2024
if (this.zoneIsDefined) {
// https://github.com/angular/angular/blob/c9abe775d07d075b171a187844d09e57f9685f3b/packages/core/src/zone/ng_zone.ts#L387-L395
const task = Zone.root.scheduleEventTask('fakeTopEventTask', () => {
if (this.zoneIsDefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we have a util for this style of wrapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could though I'm not exactly sure what the util would do. This and zone coalescing are the only two places where Zone.root.run are called and ng_zone definitely doesn't need to check if Zone is defined first.

@pkozlowski-opensource pkozlowski-opensource added the area: core Issues related to the framework runtime label Apr 16, 2024
@ngbot ngbot bot added this to the Backlog milestone Apr 16, 2024
…zone

Rather than attempting to use the native timing functions, this commit
simplifies the logic significantly by using the global timer functions
as they are, either patched or unpatched. When Zone is defined, we run
the timers in the root zone. This has more predictable behavior and
timing than (a) using both patched and unpatched versions of timers in
different places (b) trying to get an unpatched timer and failing due to
environment specifics and patches that aren't ZoneJS.
@atscott
Copy link
Contributor Author

atscott commented Apr 17, 2024

Green TGP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime requires: TGP This PR requires a passing TGP before merging is allowed target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants