-
Notifications
You must be signed in to change notification settings - Fork 42
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 panic on iframe attach #1406
Merged
Merged
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
When working with iframes, there are some cases where the frame that contains the iframe doesn't have a windowID. Trying to retrieve one will result in an error. Changing windowID to a pointer will enable us to either have one or not.
When we create a new FrameSession for a frame associated with a frame, we don't want to retrieve the windowID as it could cause chromium to error and therefore the browser module to panic. Instead we will avoid calling out to retrieve the windowID in those cases.
Now we can avoid the call to retrieve windowID and work with it if the windowID is nil. This change will avoid panics when working with certain iframes that do not contain UI elements, and therefore chromium doesn't track a windowID for it.
inancgumus
reviewed
Aug 20, 2024
inancgumus
reviewed
Aug 20, 2024
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.
Glad we're fixing this. I have a question.
This makes it more explicit as to what is going on when windowID has not been retrieved and not used later on. This change also means we can revert windowID back to a non-pointer field.
5 tasks
inancgumus
approved these changes
Aug 21, 2024
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.
Nice! 🎉
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.
What?
This PR fixes an issue where the browser module would panic when navigating to certain website with iframes on them. The error is
panic: GoError: attaching iframe: attaching iframe target ID 153A0D279584840F49FB1E718A8297AB to session ID DA84F3DFA9B0CA220314557F25BC8B37: getting browser window ID: No web contents for the given target id (-32000)
Why?
The reason for this is when the browser comes to attach an iframe, some iframes do not have any UI elements, which sets a state within chromium such that no windowID can be returned when one is requested for. This causes a panic here. To avoid this issue we have to avoid performing the CDP calls that could cause errors when attaching a new iframe (retrieving a windowID and set the window bounds). PW does the same.
Test
Test procedure
You can test against the following page:
First we need to replicate the issue, so set the current branch to
main
, and run the following test script (multiple times) until you get the same error as mentioned above:Now test the same script against the fix branch. The same error shouldn't appear again.
Checklist
Related PR(s)/Issue(s)
Updates: #1224