Skip to content

Commit 48cde60

Browse files
committed
In loadURL, wait for the page to finish loading before proceeding to avoid GUEST_VIEW_MANAGER_CALL error. And when waiting times out, force navigation to stop before proceeding
1 parent 091b816 commit 48cde60

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/renderer/src/view_models/BaseViewModel.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ export class BaseViewModel {
287287
await new Promise(resolve => setTimeout(resolve, 200));
288288
if (Date.now() - startTime >= timeout) {
289289
this.log("waitForLoadingToFinish", "timeout reached while waiting for loading to finish");
290+
// Force stop any navigation before returning
291+
this.getWebview()?.stop();
290292
return;
291293
}
292294
} while (this.getWebview()?.isLoading());
@@ -446,8 +448,7 @@ export class BaseViewModel {
446448
this.log("loadBlank");
447449
const webview = this.getWebview();
448450
if (webview) {
449-
// Note: We need to wait for the page to finish loading before and after this to prevent
450-
// Error: Error invoking remote method 'ELECTRON_GUEST_VIEW_MANAGER_CALL'
451+
// Note: We need to wait for the page to finish loading before and after to prevent GUEST_VIEW_MANAGER_CALL
451452
// https://github.com/electron/electron/issues/24171#issuecomment-953053293
452453
await this.waitForLoadingToFinish();
453454
await webview.loadURL("about:blank")
@@ -458,6 +459,10 @@ export class BaseViewModel {
458459
async loadURL(url: string) {
459460
const webview = this.getWebview();
460461
if (webview) {
462+
// Note: We need to wait for the page to finish loading before and after to prevent GUEST_VIEW_MANAGER_CALL
463+
// https://github.com/electron/electron/issues/24171#issuecomment-953053293
464+
await this.waitForLoadingToFinish();
465+
461466
let tries = 0;
462467
// eslint-disable-next-line no-constant-condition
463468
while (true) {
@@ -492,6 +497,7 @@ export class BaseViewModel {
492497
} else {
493498
this.log("loadURL", "webview is null");
494499
}
500+
495501
await this.waitForLoadingToFinish();
496502
}
497503

0 commit comments

Comments
 (0)