-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(breakpoint-observer): fix the breakpoint observer emit count and accuracy #15964
Merged
andrewseguin
merged 1 commit into
angular:master
from
TrevorKarjanis:fix-breakpoint-emissions
Jun 26, 2019
Merged
fix(breakpoint-observer): fix the breakpoint observer emit count and accuracy #15964
andrewseguin
merged 1 commit into
angular:master
from
TrevorKarjanis:fix-breakpoint-emissions
Jun 26, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72128f5
to
4ba5ead
Compare
TrevorKarjanis
commented
May 21, 2019
…accuracy The breakpoint observer emits multiple and incorrect states when more than one query changes. Debounce the observer emissions to eliminate the incorrect states and emit once. References angular#10925
4ba5ead
to
68b85ed
Compare
josephperrott
requested changes
Jun 3, 2019
josephperrott
approved these changes
Jun 3, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
cla: yes
PR author has agreed to Google's Contributor License Agreement
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
target: patch
This PR is targeted for the next patch release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The breakpoint observer emits multiple and incorrect states when more than one query changes.
Debounce the observer emissions to eliminate the incorrect states and emit once.
References #10925 #15868
I have reproduced this in Chrome, Firefox, Safari, Edge, and IE. It occurs because the media query API fires an event when a query match changes. The breakpoint observer emits once for each event, updating the state of one query each time. Therefore, the observer may emit multiple times for one change and the reported intermediary states can be incorrect. I have reproduced up to five emissions for a single change.
https://stackblitz.com/edit/angular-6pmabc
PR #11007 attempted to resolve this issue. However, the issue still reproduces. My understanding is that the AsapScheduler uses a microtask which fails to debounce the media query events. Using the AsyncScheduler resolves the issue. AsyncScheduler uses a timer, setInterval, that may technically be slower on the first bounce but is more efficient across multiple.