You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: loadURL after did-start-loading crashes electron #19847
Not sure if this is related. If I'm not wrong since electron v5 an error will be thrown if new url triggered for loading before the previous one got loaded. Here is the respective code
This kinda makes sense, Chromium does not expect a new navigation to clear out pending navigations while a navigationentry is dispatching an event. Wrapping this in a setTimeout(() => loadUrl(), 0) should stop it crashing.
On Electron's side we should probably detect this and wait a tick or something 🤷♂
Actually, this is a bigger problem.. I have two additions to two SPA Mirror projects.. MagicMirror and smart-mirror. both extensions load images, one on the main html page (thru DHTML or Angular expressions), and one on a separate thread, above the main page, using Javascript (not in the dom) both are driven off timer tick, and loadUrl in a setTimeout timer handler
IF one extension attempts to loadUrl ITS content and the other is waiting (loadUrl started, and before webContents.on('did-finish-load'), ) then the renderer will crash, or hang. the addition that does the windows ABOVE the index.html page can be driving multiple windows concurrently (images tied to calendar entries). I spent a few months finding and fixing my concurrent calls into electron, but now have added this other thing that displays background images on the page.
in my calendar based code I have a serialization flag, that prevents me having two loadUrls active at the same time.
I started my calendar app in 2016 and I am seeing the same issues now on 6.0.12.. neither mirror app runs on electron above 6.1.x
if the electron code is not re-entrant, then it either needs a queue of loadUrl requests, or an exception if already busy.
I notice that the window that dies is the main html page, not the javascript created windows over the html page
i have had to resort to on('crashed') to workaround the problem, restarting the app.. I'd make an override class if I could. as one loadUrl is coming from angular when an img element is surfaced.
So I see three possible paths for addressing this crash:
Delay the did-start-loading event until after the critical section completes. Though I'm not sure what method/event to hook in Chromium that would give us "after the critical section", or even if there is one. Possibly did-start-navigation?
Detect when loadURL is called during the critical section, and queue the call until the critical section ends. Again, not quite sure how to detect the end of the critical section, but maybe for this one we could just wait until the next tick.
Have loadURL throw if it's called during the critical section, instead of crashing the whole app. Document this in the docs for did-start-loading and anywhere else that's "inside the critical section".
I'm not sure what all the possible events are that can happen "inside the critical section" where calling loadURL will crash, but I've noticed at least did-start-loading and frame-created can be emitted during that time.
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!
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!
Activity
vladimiry commentedon Oct 24, 2019
Not sure if this is related. If I'm not wrong since electron v5 an error will be thrown if new url triggered for loading before the previous one got loaded. Here is the respective code
electron/lib/browser/navigation-controller.js
Line 99 in 0e0d4fe
MarshallOfSound commentedon Oct 24, 2019
This kinda makes sense, Chromium does not expect a new navigation to clear out pending navigations while a navigationentry is dispatching an event. Wrapping this in a
setTimeout(() => loadUrl(), 0)should stop it crashing.On Electron's side we should probably detect this and wait a tick or something 🤷♂
sdetweil commentedon Nov 29, 2019
Actually, this is a bigger problem.. I have two additions to two SPA Mirror projects.. MagicMirror and smart-mirror. both extensions load images, one on the main html page (thru DHTML or Angular expressions), and one on a separate thread, above the main page, using Javascript (not in the dom) both are driven off timer tick, and loadUrl in a setTimeout timer handler
IF one extension attempts to loadUrl ITS content and the other is waiting (loadUrl started, and before webContents.on('did-finish-load'), ) then the renderer will crash, or hang. the addition that does the windows ABOVE the index.html page can be driving multiple windows concurrently (images tied to calendar entries). I spent a few months finding and fixing my concurrent calls into electron, but now have added this other thing that displays background images on the page.
in my calendar based code I have a serialization flag, that prevents me having two loadUrls active at the same time.
I started my calendar app in 2016 and I am seeing the same issues now on 6.0.12.. neither mirror app runs on electron above 6.1.x
if the electron code is not re-entrant, then it either needs a queue of loadUrl requests, or an exception if already busy.
I notice that the window that dies is the main html page, not the javascript created windows over the html page
sdetweil commentedon Dec 1, 2019
i have had to resort to on('crashed') to workaround the problem, restarting the app.. I'd make an override class if I could. as one loadUrl is coming from angular when an img element is surfaced.
zbot473 commentedon Mar 31, 2020
Getting this on Win10 on v8.2.0
electron-triage commentedon Mar 8, 2021
The Electron version reported on this issue is no longer supported. See our supported versions documentation.
If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.
Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.
14 remaining items
nornagon commentedon Oct 31, 2022
It looks like the underlying functions that
LoadURLcalls are explicitly non-reentrant—see https://bugs.chromium.org/p/chromium/issues/detail?id=347742 and https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/navigation_controller_impl.cc;l=2611-2614;drc=2c82547348818858d793ae04f3ad950e3f2567b4—and thedid-start-loadingevent is emitted during the non-reentrant "critical section".So I see three possible paths for addressing this crash:
did-start-loadingevent until after the critical section completes. Though I'm not sure what method/event to hook in Chromium that would give us "after the critical section", or even if there is one. Possiblydid-start-navigation?loadURLis called during the critical section, and queue the call until the critical section ends. Again, not quite sure how to detect the end of the critical section, but maybe for this one we could just wait until the next tick.loadURLthrow if it's called during the critical section, instead of crashing the whole app. Document this in the docs fordid-start-loadingand anywhere else that's "inside the critical section".I'm not sure what all the possible events are that can happen "inside the critical section" where calling
loadURLwill crash, but I've noticed at leastdid-start-loadingandframe-createdcan be emitted during that time.github-actions commentedon Jan 30, 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!
pushkin- commentedon Jan 30, 2023
repros in v22
[-]loadURL after did-start-loading crashes electron[/-][+][Bug]: loadURL after did-start-loading crashes electron[/+]github-actions commentedon Jul 2, 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!
pushkin- commentedon Jul 3, 2023
bump