electron: webview setting baseURLForDataURL crashes Electron
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:
- 7.0.0
- Operating System:
- Arch Linux
- Last Known Working Electron version:
- 6.0.10
Expected Behavior
Opening a webview
with a preset source as in:
<webview src="https://github.com"></webview>
<script>
webview.loadURL(
`data:text/html;charset=utf-8;base64,
PGgxPkhBTExPPC9oMT4=
`, { baseURLForDataURL: `file://home/` })
// the base64 string is just <h1>HALLO</h1>
</script>
loads the github URL and then reloads the webview with HALLO
.
Actual Behavior
Electron crashes
To Reproduce
See this repo: https://github.com/burningTyger/webview-bug
Screenshots
Additional Information
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 39 (4 by maintainers)
Commits related to this issue
- upgrade @electron * TODO (switch back to upstream "node-spellchecker") https://github.com/atom/node-spellchecker/issues/127 * TODO (blocker) https://github.com/electron/electron/issues/20700 * TODO (... — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- upgrade @electron 6 => 8: workaround for baseURLForDataURL use * ref https://github.com/electron/electron/issues/20700 — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- upgrade @electron 6 => 8: workaround for baseURLForDataURL use * ref https://github.com/electron/electron/issues/20700 — committed to vladimiry/ElectronMail by vladimiry 5 years ago
@Juice10 thanks for the repro! I’ve narrowed it down a little bit and opened #28765 to track that crash.
Can confirm the workaround with electron v8.0.0 Modified version of my previous attempt:
It now works fine. Thank you guys!
@burningTyger Here’s the code I tried and it works by using the file protocol hack.
Just copy paste it in your
index.js
file and obviously you would need your own css file and path. Put somebackground-color: #000
to testThis is still broken in electron 10 please say this will be fixed at some point as it would be really useful to have it working correctly
It does work with webviews, here https://github.com/vladimiry-playground/electron-quick-start-baseURLForDataURL
A little work around. If you register your own file protocol (@see https://electronjs.org/docs/api/protocol) and use that as the baseURLForDataURL the crashing stops and you can access your files.
{baseURLForDataURL: 'atom:/'}
Of course this doesn’t solve the crashing problem. 😕 It effects both the BrowserWindow and BrowserView
@nornagon I set up a Electron Fiddler of the portion of this problem that doesn’t use a custom protocol and thus doesn’t overlap with #28407 but still crashes: https://gist.github.com/7c979306285b7b8a4588261663ce5a8b
Maybe we could re-open this issue for that use case?
This bug is also not unique to linux despite the tags on this issue. I’m experiencing it on mac with electron 7.1.3. I also tried going back to v6 which as mentioned by @evanrolfe, does not cause a crash but instead causes an ERR_FAILED loading error which results in a blank webview.
@sofianguy I also tested this issue with platfom/mac and electron 8 beta and it also fails. Maybe the tags can be added as well?
It’s not the webview only specific. It crashed even if you call
window.webContents.loadURL
on a regular window in the case ifbaseURLForDataURL
is specified.A quite severe issue. @sofianguy hope it gets moved
Unsorted Issues
=>Fixed for Next Release
soon 😃