Skip to content

Commit a5da9c4

Browse files
author
Tajudeen
committed
Fix Windows installer CreateProcess error and improve macOS blank screen handling
- Fix InnoSetup build error: Replace WizardNotSilent() with not WizardSilent() - Add ExecutableExists() function to verify executable before launching - Add build-time verification to check executable exists before creating installer - Add post-install verification and better error logging - Improve macOS blank screen fix with async page load event handling - Add retry logic and multiple fallbacks for window visibility
1 parent abaf637 commit a5da9c4

File tree

3 files changed

+86
-5
lines changed

3 files changed

+86
-5
lines changed

build/gulpfile.vscode.win32.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ function buildWin32Setup(arch, target) {
7575
const outputPath = setupDir(arch, target);
7676
fs.mkdirSync(outputPath, { recursive: true });
7777

78+
// CRITICAL: Verify executable exists before creating installer
79+
const expectedExePath = path.join(sourcePath, `${product.nameShort}.exe`);
80+
if (!fs.existsSync(expectedExePath)) {
81+
const errorMsg = `ERROR: Executable not found at expected path: ${expectedExePath}\n` +
82+
`This will cause "CreateProcess failed; code 2" error during installation.\n` +
83+
`Please verify the Windows build completed successfully and the executable was created.`;
84+
console.error(errorMsg);
85+
return cb(new Error(errorMsg));
86+
}
87+
console.log(`✓ Executable verified: ${expectedExePath}`);
88+
7889
const originalProductJsonPath = path.join(sourcePath, 'resources/app/product.json');
7990
const productJsonPath = path.join(outputPath, 'product.json');
8091
const productJson = JSON.parse(fs.readFileSync(originalProductJsonPath, 'utf8'));

build/win32/code.iss

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#NameLong}"; File
110110
; Automatically install Visual C++ Redistributables if not already installed (silent, no user interaction)
111111
Filename: "powershell.exe"; Parameters: "-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ""$url='https://aka.ms/vs/17/release/vc_redist.x64.exe'; $out='{tmp}\vc_redist.x64.exe'; if (-not (Test-Path $out)) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing }; Start-Process -FilePath $out -ArgumentList '/install','/quiet','/norestart' -Wait -NoNewWindow"""; StatusMsg: "Installing Visual C++ Redistributables..."; Check: not IsVCRedistInstalled() and (Arch = "x64"); Flags: runhidden waituntilterminated
112112
Filename: "powershell.exe"; Parameters: "-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ""$url='https://aka.ms/vs/17/release/vc_redist.arm64.exe'; $out='{tmp}\vc_redist.arm64.exe'; if (-not (Test-Path $out)) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing }; Start-Process -FilePath $out -ArgumentList '/install','/quiet','/norestart' -Wait -NoNewWindow"""; StatusMsg: "Installing Visual C++ Redistributables..."; Check: not IsVCRedistInstalled() and (Arch = "arm64"); Flags: runhidden waituntilterminated
113-
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Tasks: runcode; Flags: nowait postinstall; Check: ShouldRunAfterUpdate()
114-
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Flags: nowait postinstall; Check: WizardNotSilent()
113+
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Tasks: runcode; Flags: nowait postinstall; Check: ShouldRunAfterUpdate() and ExecutableExists()
114+
Filename: "{app}\{#ExeBasename}.exe"; Description: "{cm:LaunchProgram,{#NameLong}}"; Flags: nowait postinstall; Check: not WizardSilent() and ExecutableExists()
115115

116116
[Registry]
117117
#if "user" == InstallTarget
@@ -1458,6 +1458,27 @@ begin
14581458
Result := True;
14591459
end;
14601460
1461+
// Verify that the executable file exists before trying to launch it
1462+
// This prevents "CreateProcess failed; code 2" errors
1463+
function ExecutableExists(): Boolean;
1464+
var
1465+
ExePath: String;
1466+
begin
1467+
ExePath := ExpandConstant('{app}\{#ExeBasename}.exe');
1468+
Result := FileExists(ExePath);
1469+
if not Result then
1470+
begin
1471+
Log('Warning: Executable not found at: ' + ExePath);
1472+
// Try alternative locations or wait a bit for file system to sync
1473+
Sleep(100);
1474+
Result := FileExists(ExePath);
1475+
if Result then
1476+
Log('Executable found after retry')
1477+
else
1478+
Log('Executable still not found after retry');
1479+
end;
1480+
end;
1481+
14611482
function IsWindows11OrLater(): Boolean;
14621483
begin
14631484
Result := (GetWindowsVersion >= $0A0055F0);
@@ -1556,9 +1577,27 @@ procedure CurStepChanged(CurStep: TSetupStep);
15561577
var
15571578
UpdateResultCode: Integer;
15581579
StartServiceResultCode: Integer;
1580+
ExePath: String;
15591581
begin
15601582
if CurStep = ssPostInstall then
15611583
begin
1584+
// Verify executable exists after installation
1585+
ExePath := ExpandConstant('{app}\{#ExeBasename}.exe');
1586+
if not FileExists(ExePath) then
1587+
begin
1588+
Log('ERROR: Executable not found after installation at: ' + ExePath);
1589+
Log('This will cause "CreateProcess failed; code 2" error when trying to launch.');
1590+
// Try to find the actual executable name
1591+
// This is a fallback in case the executable has a different name
1592+
if FileExists(ExpandConstant('{app}\{#ApplicationName}.exe')) then
1593+
Log('Found alternative executable: {#ApplicationName}.exe')
1594+
else
1595+
Log('No alternative executable found either.');
1596+
end
1597+
else
1598+
begin
1599+
Log('Executable verified at: ' + ExePath);
1600+
end;
15621601
#ifdef AppxPackageName
15631602
// Remove the old context menu registry keys for insiders
15641603
if QualityIsInsiders() and WizardIsTaskSelected('addcontextmenufiles') then begin

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,9 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
11351135
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-browser/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true));
11361136

11371137
// Fix for macOS blank screen: Ensure window is visible and has valid bounds
1138+
// This fix runs immediately and also after the page loads to handle timing issues
11381139
if (isMacintosh && this._win) {
1139-
// Force window to be shown if it's not visible
1140+
// Immediate fix: Force window to be shown if it's not visible
11401141
if (!this._win.isVisible()) {
11411142
this._win.showInactive();
11421143
}
@@ -1151,8 +1152,38 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
11511152
this._win.setSize(1024, 768);
11521153
this._win.center();
11531154
}
1154-
// Ensure window is focused to prevent blank screen
1155-
this._win.focus();
1155+
1156+
// Additional fix: Ensure window is visible after page loads (handles async loadURL timing)
1157+
// Use both 'did-finish-load' and 'dom-ready' events to catch all cases
1158+
const ensureWindowVisible = () => {
1159+
if (this._win && !this._win.isDestroyed()) {
1160+
if (!this._win.isVisible()) {
1161+
this._win.showInactive();
1162+
}
1163+
if (this._win.isMinimized()) {
1164+
this._win.restore();
1165+
}
1166+
// Re-check bounds after page load
1167+
const currentBounds = this._win.getBounds();
1168+
if (currentBounds && (currentBounds.width === 0 || currentBounds.height === 0)) {
1169+
this._win.setSize(1024, 768);
1170+
this._win.center();
1171+
}
1172+
// Ensure window is focused to prevent blank screen
1173+
this._win.focus();
1174+
}
1175+
};
1176+
1177+
// Listen for page load events to ensure window is visible
1178+
this._win.webContents.once('did-finish-load', ensureWindowVisible);
1179+
this._win.webContents.once('dom-ready', ensureWindowVisible);
1180+
1181+
// Also ensure visibility after a short delay as a fallback
1182+
setTimeout(() => {
1183+
if (this._win && !this._win.isDestroyed()) {
1184+
ensureWindowVisible();
1185+
}
1186+
}, 100);
11561187
}
11571188

11581189
// Remember that we did load

0 commit comments

Comments
 (0)