macOS updater: the download sheet never shows after Install Update, and the window stays grey

Aperta
#952 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
macos, objective-c
Ambito
desktop

Direzione di ricerca

Read the macOS updater’s updatePresentationWindow method and trace where downloadUpdateVersion presents its progress sheet from the “A new version” completion handler. Reproduce the reported sequence with the standalone Objective-C example or packaged app, then check that the download sheet appears on the app window with its progress bar and Cancel button after the first sheet closes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The problem

On macOS, clicking Install Update in the “A new version of is available” sheet never shows the download sheet. The window stays grey until the download finishes, then the app quits and relaunches. The user sees no progress and no Cancel button, so the app looks frozen for the whole download. Sage’s update ZIP is 229 MB, so that can take minutes.

This is true in 0.11.1 and on current main (4d47c2c). It was seen on macOS 27.2.1 (26B131).

The cause

downloadUpdateVersion runs inside the completion handler of the “A new version” sheet. At that moment, the closing alert panel is still NSApp.keyWindow, still visible, and still attached to the app’s window. updatePresentationWindow returns NSApp.keyWindow first:

- (NSWindow *)updatePresentationWindow {
    NSWindow *keyWindow = NSApp.keyWindow;
    if (keyWindow.isVisible && !keyWindow.miniaturized) return keyWindow;
    ...
}

So the download sheet is attached to the closing alert, not to the app’s window. The alert then finishes closing and takes the download sheet with it. Logged from a replay of this code (trimmed):

[completion] key=_NSAlertPanel(sheet=1 visible=1 parent=main) chosen=_NSAlertPanel(...)
[t+0]   progress.window=_NSAlertPanel(sheet=1 visible=1) progress.parent=_NSAlertPanel(parent=main)
[t+1.5s] key=nil main.attachedSheet=nil progress.window=_NSAlertPanel(sheet=1 visible=0) progress.parent=_NSAlertPanel(visible=0 parent=nil)

The download keeps running. When it ends, the completion block finds downloadAlert.window.sheetParent (the hidden alert), ends the sheet there, and installs the update as usual.

Reproduction

A standalone Objective-C program reproduces it without an update feed. It copies updatePresentationWindow, presentUpdateAlert, and the sheet part of downloadUpdateVersion. Its window has a full-size content view, a transparent titlebar, and a WKWebView. It shows the “A new version” sheet and clicks Install Update with performClick:. A second later, the window is grey with no sheet. The same happens in a packaged app with a real feed.

The fix

Return the window the sheet belongs to, never a sheet:

- (NSWindow *)updatePresentationWindow {
    NSWindow *keyWindow = NSApp.keyWindow;
    while (keyWindow.sheetParent) keyWindow = keyWindow.sheetParent;
    if (keyWindow.isVisible && !keyWindow.miniaturized && !keyWindow.isSheet) return keyWindow;
    for (NSWindow *window in NSApp.orderedWindows) {
        if (window.isVisible && !window.miniaturized && !window.isSheet) return window;
    }
    for (NSWindow *window in self.windows.allValues) {
        if (window.isVisible && !window.miniaturized) return window;
    }
    return nil;
}

With the window chosen this way, AppKit queues the download sheet until the “A new version” sheet has closed, then shows it. With the sheetParent walk, the replay shows the download sheet with its bar and Cancel.

Notes

  • The fallback loop. While an alert is up, NSApp.orderedWindows lists the alert first. On macOS 27.2.1 it also lists private _NSGlassEffectWindows. Skipping sheets there keeps the fallback, used when no window is key, from making the same mistake.
  • A real progress bar. vercel-labs/native#936 asks for a determinate bar in this sheet and an update API for apps. This bug is separate, because no bar shows at all today.
  • Sage’s workaround. Until a fix ships, Sage replaces updatePresentationWindow through the Objective-C runtime, with the same sheetParent walk (wasimxyz/sage#95). It checks each method’s name and type encoding first, so a fix or rename here turns the workaround off rather than breaking it.
Lingua principale
Zig
Stelle
7.9k
Fork
335
Merge medio
10h 33m
PR unite (30g)
147

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel-labs/native

Tutte le issue di vercel-labs/native

Issue simili

Altre issue su Desktop Dev

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.