Repository navigation
fix(frame): don't miss a load state fired while the wait is being set up - #3400
Closed
feiyun0112 wants to merge 1 commit into
Closed
feiyun0112 wants to merge 1 commit into
feiyun0112 wants to merge 1 commit into
Conversation
`WaitForLoadStateAsync` inspected `_loadStates` and only then subscribed to the `LoadState` event. `OnLoadState` is dispatched on the protocol thread, so a state recorded between those two steps was added to `_loadStates` but its event was never observed by the waiter, which then only ever ended with a timeout. This is what made `WaitForURLAsync(WaitUntil = Load)` intermittently time out on a page that was already fully loaded. Subscribe first and inspect the recorded state afterwards, so that an event fired concurrently is either caught by the handler or already visible in `_loadStates`. `_loadStates` is now guarded by a lock, since it is written on the protocol thread and read on the caller's thread. `WaitForNavigationAsync` had the same check-then-subscribe pair; both now share a single helper. fixes microsoft#3399
Collaborator
|
Closing in favor of #3453. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WaitForLoadStateAsyncinspected_loadStatesand only then subscribed to theLoadStateevent.OnLoadStateis dispatched on the protocol thread, so a state recorded between those two steps was added to_loadStatesbut its event was never observed by the waiter, which then only ever ended with a timeout. This is what madeWaitForURLAsync(WaitUntil = Load)intermittently time out on a page that was already fully loaded.Subscribe first and inspect the recorded state afterwards, so that an event fired concurrently is either caught by the handler or already visible in
_loadStates._loadStatesis now guarded by a lock, since it is written on the protocol thread and read on the caller's thread.WaitForNavigationAsynchad the same check-then-subscribe pair; both now share a single helper.fixes #3399