Skip to content

Commit 5868aae

Browse files
author
Tajudeen
committed
macOS: Add blank screen prevention fix
- Ensures window is visible and has valid bounds on macOS - Prevents blank screen issues by validating window state - Automatically fixes invalid window dimensions (0x0) - Forces window focus to ensure proper rendering
1 parent dab9952 commit 5868aae

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,27 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
11341134
// Load URL
11351135
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-browser/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true));
11361136

1137+
// Fix for macOS blank screen: Ensure window is visible and has valid bounds
1138+
if (isMacintosh && this._win) {
1139+
// Force window to be shown if it's not visible
1140+
if (!this._win.isVisible()) {
1141+
this._win.showInactive();
1142+
}
1143+
// Ensure window is not minimized
1144+
if (this._win.isMinimized()) {
1145+
this._win.restore();
1146+
}
1147+
// Validate and fix window bounds if invalid (0x0 or off-screen)
1148+
const bounds = this._win.getBounds();
1149+
if (bounds && (bounds.width === 0 || bounds.height === 0)) {
1150+
// Reset to default size if invalid
1151+
this._win.setSize(1024, 768);
1152+
this._win.center();
1153+
}
1154+
// Ensure window is focused to prevent blank screen
1155+
this._win.focus();
1156+
}
1157+
11371158
// Remember that we did load
11381159
const wasLoaded = this.wasLoaded;
11391160
this.wasLoaded = true;

0 commit comments

Comments
 (0)