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]: Crash when adding child view #41974
Comments
Hello @t57ser. Thanks for reporting this and helping to make Electron better! Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use. Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests. Now adding the
blocked/need-repro
|
Hey @t57ser, I appreciate the report and I know it might be tricky to make an isolated repro case for this one. If you happen to be able to share any code that can repro the issue, that may help us better understand what's going on - the stack traces alone unfortunately don't give us much to go on here. If a repro is too hard to make, could you please attach a crash dump to help us get more information? That might give us just a bit more than the stack trace screenshot. You can collect them by adding the following snippet to your main process code, before app.whenReady:
Then reproduce the crash, zip up the crash dumps directory and attach it here. |
It seems like this was an issue on my side.
in order to get the parent and detach the view. I later changed this to
This is wrong though as it does not get the parent. |
I think I know how to reproduce it:
Attach the same view to 2 different windows and it crashes |
@t57ser thanks! agree it should never crash - will investigate soon :) |
@t57ser couldn't repro with the following: sample
const { app, BrowserWindow, WebContentsView } = require('electron')
function createWindow () {
const win1 = new BrowserWindow({ title: 'win1' })
const win2 = new BrowserWindow({ title: 'win2' })
const view1 = new WebContentsView()
win1.contentView.addChildView(view1)
setTimeout(() => {
win2.contentView.addChildView(view1)
}, 5000)
view1.webContents.loadURL('https://electronjs.org')
view1.setBounds({ x: 0, y: 0, width: 400, height: 400 })
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
}) what happens instead is the webcontentsview is detached from win1 and attached to win2. |
@codebytere This seems to crash for me each time:
|
@t57ser confirmed, thanks! looks like https://source.chromium.org/chromium/chromium/src/+/main:ui/views/view.cc;l=3072?q=AddChildViewAt is the root here |
Preflight Checklist
Electron Version
30.0.0
What operating system are you using?
Windows
Operating System Version
10.0.19042
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
No crash
Actual Behavior
Electron crashes with:
/c/Program Files/nodejs/npm: line 64: 11105 Segmentation fault "$NODE_EXE" "$NPM_CLI_JS" "$@"
I am not sure what exactly causes this, but it happened when I switched the implementation from browserView to webContentsView
Testcase Gist URL
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: