Skip to content

Commit 69681ab

Browse files
author
Tajudeen
committed
Add comprehensive fixes for remaining macOS blank screen issues
- Add URL validation and logging before loadURL - Add renderer process crash detection (GPU/rendering issues) - Add GPU process crash detection (hardware acceleration issues) - Enhanced error messages with file path diagnostics - Add did-frame-finish-load event listener for additional verification - Better error recovery and diagnostic information - All fixes include detailed logging for troubleshooting
1 parent 692821c commit 69681ab

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/vs/platform/windows/electron-main/windowImpl.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,8 +1168,16 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
11681168
// Indicate we are navigting now
11691169
this.readyState = ReadyState.NAVIGATING;
11701170

1171+
// Construct and validate workbench URL before loading
1172+
const workbenchFileName = `workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`;
1173+
const workbenchUri = FileAccess.asBrowserUri(`vs/code/electron-browser/workbench/${workbenchFileName}`);
1174+
const workbenchUrl = workbenchUri.toString(true);
1175+
1176+
// Log the URL being loaded for diagnostics
1177+
this.logService.trace(`window#load: Loading workbench from: ${workbenchUrl}`);
1178+
11711179
// Load URL
1172-
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-browser/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true));
1180+
this._win.loadURL(workbenchUrl);
11731181

11741182
// macOS: Comprehensive fix for blank screen issue
11751183
// The window is created with show: false to reduce flicker, but on macOS this can cause blank screens
@@ -1179,9 +1187,12 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
11791187
// 3. Page load events - ensure visibility after content loads
11801188
// 4. Timeout fallback - last resort
11811189
// 5. Error handling - detect if workbench.html failed to load
1190+
// 6. GPU/rendering crash detection
11821191
if (isMacintosh && this._win) {
11831192
// Track if window was successfully shown
11841193
let windowShown = false;
1194+
// Store workbench info for error diagnostics
1195+
const workbenchInfo = { fileName: workbenchFileName, url: workbenchUrl };
11851196

11861197
// Immediate check: Show window if it's not visible (fallback if ready-to-show hasn't fired)
11871198
const ensureWindowVisible = () => {
@@ -1215,10 +1226,30 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
12151226
this._win.webContents.once('did-fail-load', (event, errorCode, errorDescription, validatedURL) => {
12161227
this.logService.error(`window#load: Failed to load workbench on macOS - Code: ${errorCode}, Description: ${errorDescription}, URL: ${validatedURL}`);
12171228
this.logService.error('window#load: This may indicate workbench.html is missing or the file path is incorrect');
1229+
this.logService.error(`window#load: Expected file: ${workbenchInfo.fileName}`);
1230+
this.logService.error(`window#load: Constructed URI: ${workbenchInfo.url}`);
12181231
// Still try to show the window even if load failed
12191232
ensureWindowVisible();
12201233
});
12211234

1235+
// Listen for renderer process crashes (GPU/rendering issues)
1236+
this._win.webContents.once('render-process-gone', (event, details) => {
1237+
this.logService.error(`window#load: Renderer process crashed on macOS - Reason: ${details.reason}, Exit Code: ${details.exitCode}`);
1238+
if (details.reason === 'crashed' || details.reason === 'killed') {
1239+
this.logService.error('window#load: This may indicate a GPU/rendering issue. Try launching with --disable-gpu flag.');
1240+
}
1241+
// Try to show window anyway
1242+
ensureWindowVisible();
1243+
});
1244+
1245+
// Listen for GPU process crashes (hardware acceleration issues)
1246+
this._win.webContents.once('gpu-process-crashed', (event, killed) => {
1247+
this.logService.warn(`window#load: GPU process crashed on macOS - Killed: ${killed}`);
1248+
this.logService.warn('window#load: This indicates a GPU/hardware acceleration issue. The app may still work with software rendering.');
1249+
// Window should still be visible, but ensure it is
1250+
ensureWindowVisible();
1251+
});
1252+
12221253
// Immediate check (in case ready-to-show already fired or won't fire)
12231254
ensureWindowVisible();
12241255

@@ -1243,9 +1274,20 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
12431274
// Final diagnostic check
12441275
if (!windowShown) {
12451276
this.logService.error('window#load: CRITICAL - Window was never shown on macOS. This indicates a serious issue.');
1277+
this.logService.error('window#load: Possible causes:');
1278+
this.logService.error('window#load: 1. workbench.html file is missing from app bundle');
1279+
this.logService.error('window#load: 2. File path is incorrect');
1280+
this.logService.error('window#load: 3. GPU/rendering issue (try --disable-gpu)');
1281+
this.logService.error('window#load: 4. Content Security Policy blocking rendering');
12461282
}
12471283
}
12481284
}, 500);
1285+
1286+
// Additional check: Verify webContents is ready and can render
1287+
this._win.webContents.once('did-frame-finish-load', () => {
1288+
this.logService.trace('window#load: Frame finished loading, verifying window state');
1289+
ensureWindowVisible();
1290+
});
12491291
}
12501292

12511293
// Remember that we did load

0 commit comments

Comments
 (0)