Skip to content
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

Transfering webview content using guestinstance does not work if first webview is immediately unmounted #12251

Closed
mjbvz opened this issue Mar 13, 2018 · 4 comments

Comments

@mjbvz
Copy link

mjbvz commented Mar 13, 2018

  • Electron version: 1.8.3
  • Operating system: MacOS 10.13.3

Expected behavior

For code that attempts to move a webview's contents to a new webview before the first webview is about to be unmounted from the dom:

const originalWebview = document.getElementById('webview1')

setTimeout(() => {
    const newWebview = document.createElement('webview');
    newWebview.guestinstance = originalWebview.guestinstance
    document.body.appendChild(newWebview);
    document.body.removeChild(originalWebview);
}, 1000);

After the timeout, the second webview should have the content of the first webview

Actual behavior

The second webview does not receive the content

How to reproduce

Repo

git clone https://github.com/mjbvz/electron-webview-guestinstance-on-unmount
cd electron-webview-guestinstance-on-unmount
npm install
npm start
@mjbvz
Copy link
Author

mjbvz commented Mar 13, 2018

Seems timing related. After adding a 2ms delay before calling removeChild, the issue only happens 50% of the time. With a 100ms delay, the issue never seems to happen

Any idea if there is a workaround?

@danielweck
Copy link

I wonder if this is related to:
brave/muon#510
See workaround for inspiration regarding the guestinstance API:
brave/browser-laptop@9c4d2f7

@mhuggins
Copy link

mhuggins commented Jun 3, 2018

+1. I ran into this and originally tracked it under #13144, which has some additional information. It also has a demo application that reproduces the issue.

If I wrap the removeChild call with a setTimeout of 1000 ms before removing the original webview from the DOM, then everything works as expected. This isn't realistic though since I'm using react, and this is happening in the context of componentWillUnmount, which won't wait for a delay before continuing.

@zcbenz
Copy link
Contributor

zcbenz commented Aug 16, 2018

We have to drop this feature as a result of Chromium's architecture change of webview, it was a design decision that we could not work around on Electron's side. See #14120 for more.

If anyone is interested in fixing this issue on 1.x and 2.x, we are happy to accept patches.

@zcbenz zcbenz closed this as completed Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants