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

Reload nested iframe in webview causes memory leak in electron@5.0.0 #18019

Closed
3 tasks done
KochiyaOcean opened this issue Apr 28, 2019 · 7 comments
Closed
3 tasks done

Comments

@KochiyaOcean
Copy link

KochiyaOcean commented Apr 28, 2019

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 5.0.0
  • Operating System:
    • Windows 10 1809
  • Last Known Working Electron version::
    • 4.x.x

Expected Behavior

If reload a nested iframe inside webview, the old iframe will be removed from memory.

Actual Behavior

The old iframe is still existed in memory and still working (e.g, still playing videos)

To Reproduce

Clone an reproduce example.

$ git clone https://github.com/KochiyaOcean/electron-bugs.git -b webview-nested-iframe-memory-leak
$ electron .

Play youtube video in the webview.

Run $('webview').executeJavaScript("document.querySelector('iframe').src = document.querySelector('iframe').src") in devtools.

The iframe is reloaded, but the former iframe is still existed. The video in former iframe is still playing, and the memory of former iframe is not recycled.

Which means:

BrowserWindow
  └── Webview
      └── iframe0
          └── iframe1 <= reload this one
              └── iframe2 <= and this one is not destroyed

Screenshots

image

Additional Information

There is another problem seems related: If disable webview's webSecurity option, the CORS policy of nested iframe inside the webview will still keep working, which should be also disabled.

BrowserWindow
  └── Webview <= disable webSecurity
      └── iframe0 <= CORS policy disabled
          └── iframe1 <= CORS policy still working
              └── iframe2 <= Cant'be controlled by upper iframe if it doesn't share same origin with upper iframe
@Nick-lab
Copy link

Nick-lab commented Apr 29, 2019

you probably dont want to be disabling webSecurity in you app in the first place what exactly are you trying to accomplish with nested iframes like that anyway? maybe you should look into single page application frameworks such as angular or ionic to manage paging in your app. This is much more secure and you gain alot of control over your app this way.

[edit]: This is also a chromium issue not electrons problem

@KochiyaOcean
Copy link
Author

@Nick-lab Thanks for advice, but in my situation I've to use nested iframes because the webpage is from another website that not controlled by me.

@KochiyaOcean
Copy link
Author

This problem still occurs in 5.0.1 and 6.0.0-beta.1

@KochiyaOcean
Copy link
Author

Seems fixed in 6.0.0-beta.2

@KochiyaOcean
Copy link
Author

Not fixed in 5.0.2

@peteringram0
Copy link

Also seeing this issue. Is there a plan to fix this is v5? if not do we know when 6x is planned for release? Thanks

@KochiyaOcean
Copy link
Author

Seems fixed by #18976 in electron@5.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.x
Unsorted Issues
Development

No branches or pull requests

4 participants