Skip to content

feat(oop iframes): integrate OOP iframes with the frame manager#7556

Merged
jschfflr merged 36 commits into
mainfrom
oopiframes
Oct 28, 2021
Merged

feat(oop iframes): integrate OOP iframes with the frame manager#7556
jschfflr merged 36 commits into
mainfrom
oopiframes

Conversation

@jschfflr

@jschfflr jschfflr commented Sep 10, 2021

Copy link
Copy Markdown
Contributor

This pull request tries to add better support for OOP iframes (see #2548)

The current problem with OOP iframes is that they are moved to a different target. Because of this, the current implementation of Puppeteer pretty much ignores them.

This change extends the FrameManager to already take OOP iframes into account and hides the fact that those frames are actually in different targets.

Further work needs to be done to also make the NetworkManager aware of these and to make sure that settings like emulations etc. are also properly passed down to the new targets.

@google-cla google-cla Bot added the cla: yes label Sep 10, 2021
@jschfflr jschfflr requested a review from OrKoN September 16, 2021 10:03
@jschfflr

Copy link
Copy Markdown
Contributor Author

@OrKoN Let me know what you think about this pr and if we should incrementally add OOP iframe support or have everything in one big batch?

@OrKoN

OrKoN commented Sep 16, 2021

Copy link
Copy Markdown
Collaborator

Could you describe on a high-level what was missing for OOPIF support and how we are adding it (and what are the difficulties)?

@jschfflr

Copy link
Copy Markdown
Contributor Author

Could you describe on a high-level what was missing for OOPIF support and how we are adding it (and what are the difficulties)?

Sure, I updated the description.

Comment thread mocha-config/puppeteer-unit-tests.js Outdated
Comment thread mocha-config/puppeteer-unit-tests.js Outdated
@OrKoN

OrKoN commented Sep 16, 2021

Copy link
Copy Markdown
Collaborator

What would be the effects of landing partial support? I guess it'd break some clients so maybe it's better to have all changes in one batch?

Comment thread src/common/DOMWorld.ts
Comment thread src/common/FrameManager.ts
Comment thread src/common/FrameManager.ts Outdated
Comment thread src/common/FrameManager.ts Outdated
Comment thread src/common/Page.ts Outdated
@OrKoN

OrKoN commented Sep 16, 2021

Copy link
Copy Markdown
Collaborator

It looks good to me but I am a bit fuzzy about implications for other functionality. Is it easily possible to implement OOPIF support behind a flag? Not suggesting, but just curious if it'd be safer to allow users to opt-in and test at first.

@jschfflr

Copy link
Copy Markdown
Contributor Author

It looks good to me but I am a bit fuzzy about implications for other functionality. Is it easily possible to implement OOPIF support behind a flag? Not suggesting, but just curious if it'd be safer to allow users to opt-in and test at first.

As we currently don't support OOP iframes at all this isn't changing any existing behaviour but only adding new things. As long as we don't regress on existing behaviour, I think we should be fine without a flag.

@OrKoN

OrKoN commented Sep 16, 2021

Copy link
Copy Markdown
Collaborator

As we currently don't support OOP iframes at all this isn't changing any existing behaviour but only adding new things. As long as we don't regress on existing behaviour, I think we should be fine without a flag.

Yeah but I mean new frames might show up unexpectedly for the users and things like this. E.g., they expected frames.length === 1 and suddenly an OOPIF shows up making frames.length === 2. Do you think that won't be common?

@jschfflr jschfflr marked this pull request as ready for review September 29, 2021 09:31
@jschfflr

Copy link
Copy Markdown
Contributor Author

@OrKoN Could you take another look at this?

Comment thread src/common/FrameManager.ts Outdated
Comment thread src/common/Page.ts Outdated
@jschfflr jschfflr requested a review from OrKoN October 28, 2021 08:35
Comment thread src/common/FrameManager.ts Outdated
Comment thread src/common/FrameManager.ts

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still LGTM. Please make sure that is marked as a breaking change in the release notes.

@jschfflr jschfflr merged commit 4d9dc8c into main Oct 28, 2021
@jschfflr jschfflr deleted the oopiframes branch October 28, 2021 09:25
@jschfflr

Copy link
Copy Markdown
Contributor Author

Landed and marked as breaking change 🎉

@mattzeunert

mattzeunert commented Nov 13, 2021

Copy link
Copy Markdown
Contributor

I'll need to do more work to find a shareable repro, but in case someone else runs into this, I sometimes get this error after upgrading to v11:

Cannot read property '_updateClient' of undefined
node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:183:15

Update: no repro so far, but this is some of the target info:

attached: true
canAccessOpener: false
type: "iframe"
url: "chrome-untrusted://new-tab-page/one-google-bar?paramsencoded="

I think _onAttachedToTarget is firing 1ms before _onFrameAttached.

@cetico

cetico commented Nov 13, 2021

Copy link
Copy Markdown

@mattzeuner I am getting that error. How to fix it?

Comment thread src/common/Page.ts
})
.catch(debugError);
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there a reason why the logic under line#512 is performed only for worker targets? Is this preventing the iframe targets to execute that logic? If so, what is the purpose of it or why don't we need that for iframe targets?

@TheoOliveira

Copy link
Copy Markdown

I am still having issues with the iframe. I have a simple automation that runs Puppeteer and a seems the iframe is oop. I am using latest version. Should this help? https://pptr.dev/api/puppeteer.page.evaluateonnewdocument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants