Understanding OOPIF-based <webview>

392 views
Skip to first unread message

Cheng Zhao

unread,
Aug 1, 2018, 3:52:11 AM8/1/18
to chromium-dev, laz...@chromium.org, mc...@chromium.org, Lucas Gadani, ekar...@chromium.org
Hi chromium-dev,

(I'm cc-ing a few people here since you have done related changes, please forgive me if I'm cc-ing the wrong person.)

I'm migrating Electron's webview implementation to use OOPIF, and I have problems understanding the OOPIF-based guest view.

As far as I understand, the OOPIF-based guest view is created in following steps:

1. Create an iframe in renderer.
2. Once the iframe is attached, create a guest WebContents in browser.
3. The browser notifies the renderer of guestInstanceId.
4. The renderer receives guestInstanceId and sends iframe's frame ID to browser.
5. The browser calls AttachToOuterWebContentsFrame API on guest WebContents to attach to the iframe.

After following the steps in Electron, I could not make iframe render the content of guest WebContents. I assume I'm missing some critical steps here, can someone familiar with related code help me understand the implementation?

Thanks,
Cheng

Lucas Gadani

unread,
Aug 1, 2018, 12:02:15 PM8/1/18
to Cheng Zhao, chromium-dev, laz...@chromium.org, mc...@chromium.org, ekar...@chromium.org
This looks correct, can you make sure that the WebContents you are creating in the browser is created with a WebContentsViewChildFrame? WebContentsImpl::Init should go here: https://chromium.googlesource.com/chromium/src/+/0a316dcf98b0cb9d21c7d7f47b7c83612568cf99/content/browser/web_contents/web_contents_impl.cc#1942

Lucas Gadani

unread,
Aug 1, 2018, 2:50:51 PM8/1/18
to Ehsan Karamad, zcb...@gmail.com, chromi...@chromium.org, laz...@chromium.org, mc...@chromium.org, ekar...@chromium.org
I've added that to AttachToOuterWebContentsFrame just in order to be able to support creating inner WebContentses in tests without having to instantiate GuestViews (which aren't available in content/ and content_browsertests). Normal creation flow of GuestViews should already have a WebContentsViewChildFrame at that point.

On Wed, Aug 1, 2018 at 1:03 PM Ehsan Karamad <ekar...@google.com> wrote:
I am not familiar which the source code of Electron, but does it embed most of content/, i.e., follows all the navigation steps in content layer. Also maybe make sure the RenderWidget is visible and compositing is wired up.

Lucas, we seem to be creating WebContentsViewChildFrame both in WebContents::Init and in AttachToOuterWebContentsFrame. Do you what I am missing here?

Thanks,

Ehsan

Cheng Zhao

unread,
Aug 2, 2018, 6:22:18 AM8/2/18
to Lucas Gadani, Ehsan Karamad, chromi...@chromium.org, laz...@chromium.org, mc...@chromium.org, ekar...@chromium.org
Thank you for all your help!

I have finally identified the problem, it happened because in Electron the renderer process restarts for every navigation, but in recent versions of Chromium swapping the renderer process for webview would make it stop working.

While I totally understand that it is not allowed to swap processes for guest view, do you know where to start if I want to patch Chromium to fix the behavior?

Thanks,
Cheng
Reply all
Reply to author
Forward
0 new messages