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

[Bug]: BrowserView broken since v13.5.0 #31424

Closed
3 tasks done
exander77 opened this issue Oct 14, 2021 · 14 comments
Closed
3 tasks done

[Bug]: BrowserView broken since v13.5.0 #31424

exander77 opened this issue Oct 14, 2021 · 14 comments
Labels
13-x-y 14-x-y 15-x-y 16-x-y bug 🪲 bug/regression ↩️ A new version of Electron broke something component/BrowserView platform/linux stale status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@exander77
Copy link

exander77 commented Oct 14, 2021

Preflight Checklist

Electron Version

13.5.0

What operating system are you using?

Ubuntu

Operating System Version

20.04

What arch are you using?

x64

Last Known Working Electron version

13.4.0

Expected Behavior

const win = new BrowserWindow({ width: 800, height: 600 })

const view = new BrowserView()
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
view.webContents.loadURL('https://electronjs.org')

Example from documentation should open BrowserWindow with BrowserView with electronjs.org website.

Actual Behavior

Everything stays blank.

Testcase Gist URL

No response

Additional Information

https://newbedev.com/electron/api/browser-view

Broken up to current v15.1.2.

Possibly related to: #31047

No response

@exander77
Copy link
Author

I am using ElectronJS for around a month and a half, but I can't seem to get the hang of the problems with the project. I can't seem to select the appropriate version as for example silent print to a specific printer does not work in any supported version. And for example this issue. BrowserView is recommended over WebView, yet it does not work consistently, predictively or at all, see: https://www.electronjs.org/docs/latest/tutorial/web-embeds

@clavin clavin added 13-x-y 14-x-y 15-x-y 16-x-y bug/regression ↩️ A new version of Electron broke something component/BrowserView platform/linux status/confirmed A maintainer reproduced the bug or agreed with the feature labels Oct 14, 2021
@clavin
Copy link
Member

clavin commented Oct 14, 2021

Thanks for the report! I was able to reproduce this on Ubuntu 20.04. Here's a bit more information I dug up:

This seems to have broken between versions v14.0.0-nightly.20210413 and v14.0.0-nightly.20210426. The PR that broke it was also backported to the 13-x-y line which broke between versions v13.4.0 and v13.5.0.

I confirmed that #31047 did not cause this bug.

I actually narrowed it down to #30887, which is a backport of #29600, which causes this bug.

@exander77
Copy link
Author

Great work narrowing it to actual PR. Btw, one in 100 attempts or so, the BrowserView actually rendered for me. That's when I started digging that maybe my code is actually ok.

@stjava
Copy link

stjava commented Oct 20, 2021

i have this problem too

@SpacingBat3
Copy link

SpacingBat3 commented Nov 24, 2021

Great work narrowing it to actual PR. Btw, one in 100 attempts or so, the BrowserView actually rendered for me. That's when I started digging that maybe my code is actually ok.

From my tests, BrowserView is unable to set its bounds unless there's some timeout for the window to appear – that could be why it does work in some cases when BrowserView is ready to be able to change its bounds. I'm still not certainly sure what exactly could cause this bug, but as the workaround the one could just set the bounds of the BrowserView after some timeout to increase its chance to load properly.

For an example, a patch for the BrowserView example code in Electron Fiddle could be like:

24c24
<   view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
---
>   view.webContents.on("did-finish-load", () => view.setBounds({ x: 0, y: 0, width: 300, height: 300 }))

This will make the view to set its bounds after the page loads.

@estepona
Copy link

Great work narrowing it to actual PR. Btw, one in 100 attempts or so, the BrowserView actually rendered for me. That's when I started digging that maybe my code is actually ok.

From my tests, BrowserView is unable to set its bounds unless there's some timeout for the window to appear – that could be why it does work in some cases when BrowserView is ready to be able to change its bounds. I'm still not certainly sure what exactly could cause this bug, but as the workaround the one could just set the bounds of the BrowserView after some timeout to increase its chance to load properly.

For an example, a patch for the BrowserView example code in Electron Fiddle could be like:

24c24
<   view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
---
>   view.webContents.on("did-finish-load", () => view.setBounds({ x: 0, y: 0, width: 300, height: 300 }))

This will make the view to set its bounds after the page loads.

I can confirm the original issue persists in electron v19.0.10. electron.org works fine, but google.com wouldn't work. The above answer solves the problem for me.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 29, 2022
@SebastienWae
Copy link

bump!

This issue is still affecting me on Linux, but I can't reproduce it on macos.

@github-actions github-actions bot removed the stale label Nov 6, 2022
@Hinaser
Copy link

Hinaser commented Dec 31, 2022

I mitigated this issue by defering page load as follows.

const win = new BrowserWindow({ width: 800, height: 600 })

const view = new BrowserView()
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
// Move 'loadURL' execution to another event loop context.
setTimeout(() => view.webContents.loadURL('https://electronjs.org'), 0);

@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 2023

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Apr 1, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2023
@akshay-aravind
Copy link

I am getting this issue with the latest electron version.

@j0hnm4r5
Copy link

j0hnm4r5 commented Jul 28, 2023

I too am still getting this issue in v25.3.2, on Ubuntu 20.04. The setInterval trick does not seem to work, at least for me.

@safinaskar
Copy link

Original bug ( #31424 (comment) ) still reproducible with Node 18.13, Electron 26.2, recent Debian Linux sid and with wikipedia.org as test page.

Workaround in #31424 (comment) still works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
13-x-y 14-x-y 15-x-y 16-x-y bug 🪲 bug/regression ↩️ A new version of Electron broke something component/BrowserView platform/linux stale status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

No branches or pull requests

10 participants