@satinhq/kit 0.1.0-beta.0 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/dist/acknowledgements/inventory.json +1 -1
- package/dist/app/deployment.js +8 -2
- package/dist/app/installCheck.js +4 -3
- package/dist/app/launchWatchdog.js +6 -1
- package/dist/docs/swiftui-reference.md +2 -2
- package/dist/glass/GlassMaterialRoot.d.ts +3 -1
- package/dist/glass/GlassMaterialRoot.js +2 -2
- package/dist/glass/GlassPresentation.d.ts +1 -0
- package/dist/glass/GlassPresentation.js +4 -1
- package/dist/glass/MaterialEffectRoot.js +5 -1
- package/dist/glass/TabBar.js +7 -0
- package/dist/glass/errors.d.ts +3 -1
- package/dist/glass/errors.js +49 -3
- package/dist/glass/fallback/canvasOwnership.d.ts +7 -0
- package/dist/glass/fallback/canvasOwnership.js +23 -0
- package/dist/glass/fallback/material.js +3 -2
- package/dist/glass/fallback/regions.d.ts +1 -0
- package/dist/glass/fallback/regions.js +9 -12
- package/dist/glass/fallback/runtime.d.ts +2 -0
- package/dist/glass/fallback/runtime.js +15 -4
- package/dist/glass/lens/tabGlyphColours.d.ts +2 -2
- package/dist/glass/lens/tabGlyphColours.js +5 -4
- package/dist/glass/liquidContext.d.ts +1 -0
- package/dist/glass/webgpu/client.d.ts +3 -0
- package/dist/glass/webgpu/client.js +57 -9
- package/dist/glass/webgpu/errorCode.js +3 -2
- package/dist/glass/webgpu/layers.d.ts +5 -1
- package/dist/glass/webgpu/layers.js +61 -6
- package/dist/glass/webgpu/minimize.js +20 -2
- package/dist/glass/webgpu/production.js +9 -1
- package/dist/glass/webgpu/productionPrepare.js +2 -1
- package/dist/glass/webgpu/sourcePixels.d.ts +4 -4
- package/dist/glass/webgpu/sourcePixels.js +48 -8
- package/dist/root/SatinRoot.js +9 -5
- package/dist/styles.css +6 -6
- package/dist/sw/renderServiceWorker.js +12 -3
- package/package.json +2 -1
|
@@ -30,6 +30,7 @@ export class WebGPUClient {
|
|
|
30
30
|
}
|
|
31
31
|
adapterDeadline;
|
|
32
32
|
failed;
|
|
33
|
+
startingTransport = false;
|
|
33
34
|
frames = new PageFrameHost();
|
|
34
35
|
webgpu = false;
|
|
35
36
|
currentAppearance = () => readDarkAppearance() ? 'dark' : 'light';
|
|
@@ -68,7 +69,26 @@ export class WebGPUClient {
|
|
|
68
69
|
})), motionPreparationEnabled);
|
|
69
70
|
glassTiming('client-start');
|
|
70
71
|
try {
|
|
71
|
-
|
|
72
|
+
for (let attempt = 0;; attempt++) {
|
|
73
|
+
this.startingTransport = true;
|
|
74
|
+
try {
|
|
75
|
+
await this.initialize(canvas, resolution, worker, webgpu, appearance, execution);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const code = glassFailureCode('renderer initialization', error);
|
|
80
|
+
const retryable = this.startingTransport &&
|
|
81
|
+
['worker-startup', 'readiness-timeout', 'device-request'].includes(code);
|
|
82
|
+
if (!retryable || attempt === 2)
|
|
83
|
+
throw error;
|
|
84
|
+
this.close();
|
|
85
|
+
this.failed = undefined;
|
|
86
|
+
await new Promise(resolve => setTimeout(resolve, 250 * 2 ** attempt));
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
this.startingTransport = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
72
92
|
}
|
|
73
93
|
catch (error) {
|
|
74
94
|
reportGlassError(glassFailureCode('renderer initialization', error), error, 'renderer initialization');
|
|
@@ -153,7 +173,7 @@ export class WebGPUClient {
|
|
|
153
173
|
return;
|
|
154
174
|
}
|
|
155
175
|
if (glassError) {
|
|
156
|
-
reportGlassError(glassError.code, glassError.message, glassError.stage, glassError.reason);
|
|
176
|
+
reportGlassError(glassError.code, glassError.message, glassError.stage, glassError.reason, this.startingTransport ? { recovering: true } : undefined);
|
|
157
177
|
return;
|
|
158
178
|
}
|
|
159
179
|
const request = this.pending.get(id);
|
|
@@ -174,12 +194,18 @@ export class WebGPUClient {
|
|
|
174
194
|
};
|
|
175
195
|
}
|
|
176
196
|
else {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
197
|
+
let transport;
|
|
198
|
+
try {
|
|
199
|
+
transport = new Worker(new URL('./entry.worker.js', import.meta.url), {
|
|
200
|
+
type: 'module',
|
|
201
|
+
name: 'satin-glass-webgpu',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
throw new Error(`Worker startup: ${String(error)}`, { cause: error });
|
|
206
|
+
}
|
|
181
207
|
transport.onmessage = receive;
|
|
182
|
-
transport.onerror = event => this.failTransport(new Error(event.message || 'Glass worker failed'), 'worker startup/runtime');
|
|
208
|
+
transport.onerror = event => this.failTransport(new Error(`Worker startup/runtime: ${event.message || 'Glass worker failed'}`), 'worker startup/runtime');
|
|
183
209
|
transport.onmessageerror = () => this.failTransport(Error('Glass worker message could not be deserialized'), 'worker transport');
|
|
184
210
|
this.transport = {
|
|
185
211
|
postMessage: (data, transfer = []) => transport.postMessage(data, transfer),
|
|
@@ -205,7 +231,7 @@ export class WebGPUClient {
|
|
|
205
231
|
}
|
|
206
232
|
catch (error) {
|
|
207
233
|
this.failed = error instanceof Error ? error : Error(String(error));
|
|
208
|
-
|
|
234
|
+
// init owns the bounded startup retry and terminal report.
|
|
209
235
|
this.transport?.terminate();
|
|
210
236
|
for (const pending of this.pending.values())
|
|
211
237
|
pending.reject(this.failed);
|
|
@@ -216,6 +242,7 @@ export class WebGPUClient {
|
|
|
216
242
|
clearTimeout(timeout);
|
|
217
243
|
}
|
|
218
244
|
}
|
|
245
|
+
this.startingTransport = false;
|
|
219
246
|
const offscreen = this.local ? canvas : canvas.transferControlToOffscreen();
|
|
220
247
|
await this.request({
|
|
221
248
|
type: 'init',
|
|
@@ -233,7 +260,8 @@ export class WebGPUClient {
|
|
|
233
260
|
failTransport(error, stage) {
|
|
234
261
|
this.adapterDeadline?.cancel();
|
|
235
262
|
this.failed = error;
|
|
236
|
-
|
|
263
|
+
if (!this.startingTransport)
|
|
264
|
+
reportGlassError(glassFailureCode(stage, error), error, stage);
|
|
237
265
|
for (const pending of this.pending.values())
|
|
238
266
|
pending.reject(error);
|
|
239
267
|
this.pending.clear();
|
|
@@ -324,6 +352,26 @@ export class WebGPUClient {
|
|
|
324
352
|
this.bindLifecycle();
|
|
325
353
|
this.visibility();
|
|
326
354
|
}
|
|
355
|
+
/** Dispose a failed transport before constructing its replacement. */
|
|
356
|
+
close() {
|
|
357
|
+
this.frames.cancel();
|
|
358
|
+
this.adapterDeadline?.cancel();
|
|
359
|
+
this.adapterDeadline = undefined;
|
|
360
|
+
document.removeEventListener('visibilitychange', this.visibility, true);
|
|
361
|
+
window.removeEventListener('pagehide', this.visibility, true);
|
|
362
|
+
window.removeEventListener('pageshow', this.visibility);
|
|
363
|
+
window.removeEventListener('focus', this.focus);
|
|
364
|
+
document.removeEventListener('visibilitychange', this.adapterVisibility, true);
|
|
365
|
+
window.removeEventListener('pagehide', this.adapterVisibility, true);
|
|
366
|
+
window.removeEventListener('pageshow', this.adapterVisibility);
|
|
367
|
+
window.removeEventListener('focus', this.adapterVisibility);
|
|
368
|
+
this.transport?.terminate();
|
|
369
|
+
this.transport = undefined;
|
|
370
|
+
this.local = undefined;
|
|
371
|
+
for (const pending of this.pending.values())
|
|
372
|
+
pending.reject(Error('Glass transport retired'));
|
|
373
|
+
this.pending.clear();
|
|
374
|
+
}
|
|
327
375
|
park() {
|
|
328
376
|
this.frames.cancel();
|
|
329
377
|
document.removeEventListener('visibilitychange', this.visibility, true);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** Classification retains the raw message; it never chooses a replacement. */
|
|
2
2
|
export function glassFailureCode(stage, cause) {
|
|
3
3
|
const message = cause instanceof Error ? `${cause.name}: ${cause.message}` : String(cause), text = stage + ' ' + message;
|
|
4
|
+
// Preserve the failed transport owner when a worker reports its own device loss.
|
|
5
|
+
if (/worker.*(?:startup|runtime|transport|rejection)/i.test(text))
|
|
6
|
+
return 'worker-startup';
|
|
4
7
|
if (/device\.lost|device.?lost/i.test(text))
|
|
5
8
|
return 'device-lost';
|
|
6
9
|
if (/out.?of.?memory/i.test(text))
|
|
@@ -19,8 +22,6 @@ export function glassFailureCode(stage, cause) {
|
|
|
19
22
|
return 'context-configure';
|
|
20
23
|
if (/readiness|2\.5 seconds|2500 ms/i.test(text))
|
|
21
24
|
return 'readiness-timeout';
|
|
22
|
-
if (/worker.*(?:startup|runtime|transport|rejection)/i.test(text))
|
|
23
|
-
return 'worker-startup';
|
|
24
25
|
if (/unsupported|invalid glass|Unknown.*(?:layer|region)|exceeds.*supported/i.test(text))
|
|
25
26
|
return 'unsupported-configuration';
|
|
26
27
|
return 'presentation';
|
|
@@ -22,7 +22,9 @@ export declare class LayerDevice {
|
|
|
22
22
|
private stopped;
|
|
23
23
|
private adapterPending;
|
|
24
24
|
private recovering;
|
|
25
|
-
private
|
|
25
|
+
private recoveryBlockedUntil;
|
|
26
|
+
private recoveryTimer?;
|
|
27
|
+
private recoveryFailures;
|
|
26
28
|
private forcedNullAdapters;
|
|
27
29
|
private lastLoss?;
|
|
28
30
|
readonly stats: {
|
|
@@ -43,6 +45,8 @@ export declare class LayerDevice {
|
|
|
43
45
|
stop(): void;
|
|
44
46
|
/** Foreground signals wake the single acquisition already in flight. */
|
|
45
47
|
retryAdapter(): Promise<GPUDevice> | undefined;
|
|
48
|
+
private scheduleRecovery;
|
|
49
|
+
private waitUntilVisible;
|
|
46
50
|
forceNullAdaptersForTest(attempts: number): void;
|
|
47
51
|
private requestAdapter;
|
|
48
52
|
private acquire;
|
|
@@ -34,7 +34,9 @@ export class LayerDevice {
|
|
|
34
34
|
stopped = false;
|
|
35
35
|
adapterPending = false;
|
|
36
36
|
recovering = false;
|
|
37
|
-
|
|
37
|
+
recoveryBlockedUntil = 0;
|
|
38
|
+
recoveryTimer;
|
|
39
|
+
recoveryFailures = 0;
|
|
38
40
|
forcedNullAdapters = 0;
|
|
39
41
|
lastLoss;
|
|
40
42
|
stats = {
|
|
@@ -57,8 +59,10 @@ export class LayerDevice {
|
|
|
57
59
|
async ready() {
|
|
58
60
|
if (this.device)
|
|
59
61
|
return this.device;
|
|
60
|
-
if (this.
|
|
61
|
-
|
|
62
|
+
if (Date.now() < this.recoveryBlockedUntil) {
|
|
63
|
+
this.scheduleRecovery();
|
|
64
|
+
throw Error('Glass device recovery is cooling down');
|
|
65
|
+
}
|
|
62
66
|
if (this.starting)
|
|
63
67
|
return this.starting;
|
|
64
68
|
this.starting = this.acquire();
|
|
@@ -79,8 +83,13 @@ export class LayerDevice {
|
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
failedDevice?.destroy();
|
|
82
|
-
if (!this.stopped)
|
|
86
|
+
if (!this.stopped) {
|
|
83
87
|
this.reportError(this.recovering ? 'device recreation' : 'device acquisition', error);
|
|
88
|
+
if (this.recovering) {
|
|
89
|
+
this.recoveryFailures++;
|
|
90
|
+
this.scheduleRecovery();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
84
93
|
throw error;
|
|
85
94
|
}
|
|
86
95
|
finally {
|
|
@@ -91,21 +100,53 @@ export class LayerDevice {
|
|
|
91
100
|
setAdapterVisible(visible) {
|
|
92
101
|
this.adapterVisible = visible;
|
|
93
102
|
this.retryWake?.();
|
|
103
|
+
if (!visible) {
|
|
104
|
+
clearTimeout(this.recoveryTimer);
|
|
105
|
+
this.recoveryTimer = undefined;
|
|
106
|
+
}
|
|
107
|
+
else if (this.recovering && !this.starting && !this.device)
|
|
108
|
+
this.scheduleRecovery();
|
|
94
109
|
}
|
|
95
110
|
stop() {
|
|
96
111
|
this.stopped = true;
|
|
112
|
+
clearTimeout(this.recoveryTimer);
|
|
97
113
|
this.retryWake?.();
|
|
98
114
|
}
|
|
99
115
|
/** Foreground signals wake the single acquisition already in flight. */
|
|
100
116
|
retryAdapter() {
|
|
101
|
-
if (this.device || this.
|
|
117
|
+
if (this.device || this.stopped || !this.adapterVisible)
|
|
118
|
+
return;
|
|
119
|
+
if (Date.now() < this.recoveryBlockedUntil) {
|
|
120
|
+
this.scheduleRecovery();
|
|
102
121
|
return;
|
|
122
|
+
}
|
|
103
123
|
if (this.starting) {
|
|
104
124
|
this.retryWake?.();
|
|
105
125
|
return;
|
|
106
126
|
}
|
|
107
127
|
return this.ready();
|
|
108
128
|
}
|
|
129
|
+
scheduleRecovery() {
|
|
130
|
+
if (this.stopped || !this.adapterVisible || this.recoveryTimer)
|
|
131
|
+
return;
|
|
132
|
+
const delay = Math.max(this.recoveryBlockedUntil - Date.now(), Math.min(1000 * 2 ** this.recoveryFailures, 30_000));
|
|
133
|
+
this.recoveryTimer = setTimeout(() => {
|
|
134
|
+
this.recoveryTimer = undefined;
|
|
135
|
+
void this.retryAdapter()?.catch(() => {
|
|
136
|
+
/* ready records and schedules the next attempt. */
|
|
137
|
+
});
|
|
138
|
+
}, delay);
|
|
139
|
+
}
|
|
140
|
+
async waitUntilVisible() {
|
|
141
|
+
while (!this.adapterVisible && !this.stopped) {
|
|
142
|
+
await new Promise(resolve => {
|
|
143
|
+
this.retryWake = resolve;
|
|
144
|
+
});
|
|
145
|
+
this.retryWake = undefined;
|
|
146
|
+
}
|
|
147
|
+
if (this.stopped)
|
|
148
|
+
throw Error('Glass renderer stopped during adapter acquisition');
|
|
149
|
+
}
|
|
109
150
|
forceNullAdaptersForTest(attempts) {
|
|
110
151
|
if (!Number.isInteger(attempts) || attempts < 0 || attempts > 100)
|
|
111
152
|
throw Error('Null-adapter attempts must be an integer between 0 and 100');
|
|
@@ -167,6 +208,15 @@ export class LayerDevice {
|
|
|
167
208
|
})).catch(error => {
|
|
168
209
|
throw Error(`requestDevice rejected: ${String(error)}`);
|
|
169
210
|
});
|
|
211
|
+
// requestDevice may resolve after a quick re-background. Do not rebuild or
|
|
212
|
+
// announce readiness against a suspended presentation generation.
|
|
213
|
+
try {
|
|
214
|
+
await this.waitUntilVisible();
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
device.destroy();
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
170
220
|
this.device = device;
|
|
171
221
|
this.faults.length = 0;
|
|
172
222
|
registerGPUReporter(device, (stage, error) => {
|
|
@@ -207,11 +257,13 @@ export class LayerDevice {
|
|
|
207
257
|
}
|
|
208
258
|
if (invalidationError) {
|
|
209
259
|
this.reportError('device recreation', invalidationError);
|
|
260
|
+
this.scheduleRecovery();
|
|
210
261
|
return;
|
|
211
262
|
}
|
|
212
263
|
// WebKit can report destroyed for an unexpected loss as well.
|
|
213
264
|
if (this.lossTimes.length > 3) {
|
|
214
|
-
this.
|
|
265
|
+
this.recoveryBlockedUntil = this.lossTimes[0] + 60_000;
|
|
266
|
+
this.scheduleRecovery();
|
|
215
267
|
this.reportError('device recreation', 'Glass device repeatedly lost during recovery');
|
|
216
268
|
return;
|
|
217
269
|
}
|
|
@@ -227,6 +279,9 @@ export class LayerDevice {
|
|
|
227
279
|
for (const listener of this.listeners)
|
|
228
280
|
listener(device);
|
|
229
281
|
this.stats.restores++;
|
|
282
|
+
this.recoveryFailures = 0;
|
|
283
|
+
clearTimeout(this.recoveryTimer);
|
|
284
|
+
this.recoveryTimer = undefined;
|
|
230
285
|
this.recovering = false;
|
|
231
286
|
if (lagTraceEnabled())
|
|
232
287
|
glassTiming('device-restored');
|
|
@@ -374,8 +374,26 @@ export class WorkerMinimize {
|
|
|
374
374
|
},
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
if (atRest(f))
|
|
378
|
-
|
|
377
|
+
if (atRest(f)) {
|
|
378
|
+
// A retargeted track includes its pre-onset frames. They must use the current
|
|
379
|
+
// slot too; returning the captured spec preserves the old expanded width.
|
|
380
|
+
return {
|
|
381
|
+
...spec,
|
|
382
|
+
frameWidth: geometry.dockWidth,
|
|
383
|
+
frameHeight: geometry.dockHeight,
|
|
384
|
+
shape: {
|
|
385
|
+
...spec.shape,
|
|
386
|
+
first: {
|
|
387
|
+
...spec.shape.first,
|
|
388
|
+
centerX: geometry.dockWidth / 2,
|
|
389
|
+
centerY: geometry.dockHeight / 2,
|
|
390
|
+
halfWidth: geometry.dockWidth / 2,
|
|
391
|
+
halfHeight: geometry.dockHeight / 2,
|
|
392
|
+
radius: geometry.dockRadius,
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
}
|
|
379
397
|
const g = this.options.geometry, p = minimizePlacement(f.progress, g.dockWidth, g.dockHeight, g.tabBarMinimizedOffsetX), height = g.dockHeight + (48 - g.dockHeight) * f.heightProgress, y = 7 * f.heightProgress, pill = spec.tabSelection?.capsule;
|
|
380
398
|
const bar = {
|
|
381
399
|
centerX: p.x + p.width / 2,
|
|
@@ -304,6 +304,12 @@ export class ProductionGlassRuntime {
|
|
|
304
304
|
static async create(options) {
|
|
305
305
|
if (this.shared) {
|
|
306
306
|
const runtime = await this.shared;
|
|
307
|
+
if (runtime.client.status().failed) {
|
|
308
|
+
runtime.teardown();
|
|
309
|
+
runtime.client.close();
|
|
310
|
+
this.shared = undefined;
|
|
311
|
+
return this.create(options);
|
|
312
|
+
}
|
|
307
313
|
runtime.rebind(options);
|
|
308
314
|
await runtime.prepare();
|
|
309
315
|
return runtime;
|
|
@@ -317,7 +323,9 @@ export class ProductionGlassRuntime {
|
|
|
317
323
|
catch (error) {
|
|
318
324
|
// A rejected create never reaches the React owner's cleanup. Retire its
|
|
319
325
|
// listeners and captures here before a release app mounts CSS material.
|
|
320
|
-
runtime.
|
|
326
|
+
runtime.teardown();
|
|
327
|
+
runtime.client.close();
|
|
328
|
+
this.shared = undefined;
|
|
321
329
|
throw error;
|
|
322
330
|
}
|
|
323
331
|
})();
|
|
@@ -736,7 +736,8 @@ function applyTabGlyphContext(dock, elements, context, geometry, appearance) {
|
|
|
736
736
|
const sample = context.sample(dock.frameX + 10.5 + ((dock.frameWidth - 20) / tabs.length) * (i + 0.5), dock.frameY + dock.frameHeight / 2 + elements.scroller.scrollTop, TAB_CONTEXT_RADIUS, elements.scroller.scrollTop, elements.scroller.scrollTop + geometry.height);
|
|
737
737
|
if (!sample)
|
|
738
738
|
return;
|
|
739
|
-
|
|
739
|
+
const tint = getComputedStyle(tab).getPropertyValue('--satin-tab-tint').trim();
|
|
740
|
+
for (const [property, value] of Object.entries(tabGlyphContextStyle(appearance, sample.rgb, tint)))
|
|
740
741
|
tab.style.setProperty(property, value);
|
|
741
742
|
});
|
|
742
743
|
}
|
|
@@ -19,13 +19,12 @@ export declare class SourcePixels {
|
|
|
19
19
|
private worker?;
|
|
20
20
|
private next;
|
|
21
21
|
private failure?;
|
|
22
|
+
private retrying?;
|
|
22
23
|
private pending;
|
|
23
24
|
private create;
|
|
24
25
|
constructor(create?: () => Transport);
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* it (`ProductionGlassRuntime.replaceFailedSourcePixels`), so a failure is reported once per
|
|
28
|
-
* attempt and never retried in a loop. Canvas readbacks do not use the worker and still work. */
|
|
26
|
+
/** Exhausted upload failures let the production owner replace this source stager.
|
|
27
|
+
* Canvas readbacks remain available because they do not use the worker. */
|
|
29
28
|
get failed(): boolean;
|
|
30
29
|
private fail;
|
|
31
30
|
/** Stage `image`'s premultiplied bytes for its upload (`takeSourcePixels`). When `capture` is a
|
|
@@ -39,4 +38,5 @@ export declare class SourcePixels {
|
|
|
39
38
|
* in WebKit (157 ms for a 1320 x 5091 capture in the Catalyst host), more than half of the
|
|
40
39
|
* stage. Measured for captures up to 1320 x 6495; the cause inside WebKit was not sampled. */
|
|
41
40
|
prepare(image: ImageBitmap, capture?: ImageBitmapSource): Promise<void>;
|
|
41
|
+
private prepareOnce;
|
|
42
42
|
}
|
|
@@ -32,6 +32,7 @@ export class SourcePixels {
|
|
|
32
32
|
worker;
|
|
33
33
|
next = 0;
|
|
34
34
|
failure;
|
|
35
|
+
retrying;
|
|
35
36
|
pending = new Map();
|
|
36
37
|
create;
|
|
37
38
|
constructor(create = () => new Worker(new URL('./sourcePixels.worker.js', import.meta.url), {
|
|
@@ -40,10 +41,8 @@ export class SourcePixels {
|
|
|
40
41
|
})) {
|
|
41
42
|
this.create = create;
|
|
42
43
|
}
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* it (`ProductionGlassRuntime.replaceFailedSourcePixels`), so a failure is reported once per
|
|
46
|
-
* attempt and never retried in a loop. Canvas readbacks do not use the worker and still work. */
|
|
44
|
+
/** Exhausted upload failures let the production owner replace this source stager.
|
|
45
|
+
* Canvas readbacks remain available because they do not use the worker. */
|
|
47
46
|
get failed() {
|
|
48
47
|
return !!this.failure;
|
|
49
48
|
}
|
|
@@ -51,7 +50,9 @@ export class SourcePixels {
|
|
|
51
50
|
this.failure = error;
|
|
52
51
|
this.worker?.terminate();
|
|
53
52
|
this.worker = undefined;
|
|
54
|
-
reportGlassError('worker-startup', error, 'source upload worker'
|
|
53
|
+
reportGlassError('worker-startup', error, 'source upload worker', undefined, {
|
|
54
|
+
recovering: true,
|
|
55
|
+
});
|
|
55
56
|
for (const job of this.pending.values()) {
|
|
56
57
|
clearTimeout(job.timer);
|
|
57
58
|
job.reject(error);
|
|
@@ -69,6 +70,30 @@ export class SourcePixels {
|
|
|
69
70
|
* in WebKit (157 ms for a 1320 x 5091 capture in the Catalyst host), more than half of the
|
|
70
71
|
* stage. Measured for captures up to 1320 x 6495; the cause inside WebKit was not sampled. */
|
|
71
72
|
async prepare(image, capture = image) {
|
|
73
|
+
for (let attempt = 0;; attempt++) {
|
|
74
|
+
try {
|
|
75
|
+
if (this.retrying)
|
|
76
|
+
await this.retrying;
|
|
77
|
+
return await this.prepareOnce(image, capture);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!this.failure)
|
|
81
|
+
throw error;
|
|
82
|
+
if (attempt === 2) {
|
|
83
|
+
reportGlassError('worker-startup', error, 'source upload worker');
|
|
84
|
+
throw new Error(`Source upload worker startup failed: ${String(error)}`, { cause: error });
|
|
85
|
+
}
|
|
86
|
+
// Concurrent uploads share one restart. Each retry clones from the retained
|
|
87
|
+
// source, never from the bitmap already transferred to the failed worker.
|
|
88
|
+
this.retrying ??= new Promise(resolve => setTimeout(resolve, 250 * 2 ** attempt)).then(() => {
|
|
89
|
+
this.failure = undefined;
|
|
90
|
+
this.retrying = undefined;
|
|
91
|
+
});
|
|
92
|
+
await this.retrying;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async prepareOnce(image, capture) {
|
|
72
97
|
const readbackStarted = glassNow();
|
|
73
98
|
const pixels = canvasPixels(capture);
|
|
74
99
|
if (pixels) {
|
|
@@ -83,8 +108,17 @@ export class SourcePixels {
|
|
|
83
108
|
if (this.failure)
|
|
84
109
|
throw this.failure;
|
|
85
110
|
if (!this.worker) {
|
|
86
|
-
|
|
111
|
+
try {
|
|
112
|
+
this.worker = this.create();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.fail(error instanceof Error ? error : Error(String(error)));
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
const worker = this.worker;
|
|
87
119
|
this.worker.onmessage = event => {
|
|
120
|
+
if (this.worker !== worker)
|
|
121
|
+
return;
|
|
88
122
|
const data = event.data;
|
|
89
123
|
if (data.id === 0 && data.error) {
|
|
90
124
|
this.fail(Error(data.error));
|
|
@@ -109,8 +143,14 @@ export class SourcePixels {
|
|
|
109
143
|
prepared.set(job.image, new Uint8Array(data.buffer));
|
|
110
144
|
job.resolve();
|
|
111
145
|
};
|
|
112
|
-
this.worker.onerror = event =>
|
|
113
|
-
|
|
146
|
+
this.worker.onerror = event => {
|
|
147
|
+
if (this.worker === worker)
|
|
148
|
+
this.fail(Error(event.message || 'Source upload worker failed'));
|
|
149
|
+
};
|
|
150
|
+
this.worker.onmessageerror = () => {
|
|
151
|
+
if (this.worker === worker)
|
|
152
|
+
this.fail(Error('Source upload worker reply could not be decoded'));
|
|
153
|
+
};
|
|
114
154
|
}
|
|
115
155
|
const started = glassNow(), clone = await createImageBitmap(capture);
|
|
116
156
|
if (this.failure) {
|
package/dist/root/SatinRoot.js
CHANGED
|
@@ -159,6 +159,7 @@ export function SatinRoot({ background: legacyBackground, app: suppliedApp, offl
|
|
|
159
159
|
const downloadedBytes = useRef(0);
|
|
160
160
|
const [launchAttempt, setLaunchAttempt] = useState(0);
|
|
161
161
|
const [glassReady, setGlassReady] = useState(false);
|
|
162
|
+
const [bundlePrepared, setBundlePrepared] = useState(import.meta.env.DEV || !app);
|
|
162
163
|
const [glassError, setGlassError] = useState(null);
|
|
163
164
|
const [glassFailed, setGlassFailed] = useState(false);
|
|
164
165
|
useLayoutEffect(() => {
|
|
@@ -235,10 +236,13 @@ export function SatinRoot({ background: legacyBackground, app: suppliedApp, offl
|
|
|
235
236
|
downloadActivity.current = performance.now();
|
|
236
237
|
downloadedBytes.current = progress.loaded;
|
|
237
238
|
}
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
// First-install bytes describe a real download in every profile.
|
|
240
|
+
// Applied-update confirmation remains a separate successor phase.
|
|
241
|
+
setLaunchProgress(progress);
|
|
242
|
+
}).then(ready => {
|
|
243
|
+
if (!cancelled && ready)
|
|
244
|
+
setBundlePrepared(true);
|
|
245
|
+
return ready;
|
|
242
246
|
}),
|
|
243
247
|
prepareLaunchContent(rootRef.current, contentPreparation.signal),
|
|
244
248
|
]);
|
|
@@ -489,7 +493,7 @@ export function SatinRoot({ background: legacyBackground, app: suppliedApp, offl
|
|
|
489
493
|
return;
|
|
490
494
|
return startDevFidelityAssertions(initialHistoryLength.current);
|
|
491
495
|
}, []);
|
|
492
|
-
return (_jsx(RuntimeContext, { value: runtime, children: _jsxs(MediaPlayerRoot, { onActivityChange: onMediaActivityChange, children: [_jsx("div", { ...props, ref: rootRef, className: className, "data-satin-role": "chrome", "data-satin-root": "true", "data-satin-launch": launch, "data-satin-presentation": presentationPending ? 'preparing' : 'ready', inert: launch !== 'ready' || presentationPending, "data-satin-layout-horizontal": nextLayout.layoutClass.horizontal, "data-satin-layout-vertical": nextLayout.layoutClass.vertical, style: geometryStyles, children: _jsx(AdaptiveTabsContext, { value: tabs, children: _jsx("div", { "data-satin-status-band-source": "scene", children: _jsxs(GlassMaterialRoot, { displacement: glassDisplacement, onLaunchReady: setGlassReady, children: [DeveloperMenu && app && launch === 'ready' ? (_jsx(Suspense, { fallback: null, children: _jsx(DeveloperMenu, {}) })) : null, app ? (_jsx(OrientationGuard, { app: app, width: metrics.safeFrame.width, height: metrics.safeFrame.height, children: _jsx(ReachabilityProvider, { profile: app, offlinePresentation: offlinePresentation, children: children }) })) : (children)] }) }) }) }), launch === 'failed'
|
|
496
|
+
return (_jsx(RuntimeContext, { value: runtime, children: _jsxs(MediaPlayerRoot, { onActivityChange: onMediaActivityChange, children: [_jsx("div", { ...props, ref: rootRef, className: className, "data-satin-role": "chrome", "data-satin-root": "true", "data-satin-launch": launch, "data-satin-presentation": presentationPending ? 'preparing' : 'ready', inert: launch !== 'ready' || presentationPending, "data-satin-layout-horizontal": nextLayout.layoutClass.horizontal, "data-satin-layout-vertical": nextLayout.layoutClass.vertical, style: geometryStyles, children: _jsx(AdaptiveTabsContext, { value: tabs, children: _jsx("div", { "data-satin-status-band-source": "scene", children: _jsxs(GlassMaterialRoot, { displacement: glassDisplacement, prepared: bundlePrepared, onLaunchReady: setGlassReady, children: [DeveloperMenu && app && launch === 'ready' ? (_jsx(Suspense, { fallback: null, children: _jsx(DeveloperMenu, {}) })) : null, app ? (_jsx(OrientationGuard, { app: app, width: metrics.safeFrame.width, height: metrics.safeFrame.height, children: _jsx(ReachabilityProvider, { profile: app, offlinePresentation: offlinePresentation, children: children }) })) : (children)] }) }) }) }), launch === 'failed'
|
|
493
497
|
? createPortal(_jsxs("div", { "data-satin-role": "chrome", "data-satin-launch-error": "true", "data-satin-glass-error": glassError ? true : undefined, role: "alert", style: { zIndex: launchErrorLayer }, children: [!glassError ? (_jsx("img", { className: "satin-launch-error-icon", src: document.querySelector('#satin-launch-screen .satin-launch-icon img')?.src ??
|
|
494
498
|
app?.launchScreen?.icon ??
|
|
495
499
|
app?.icons[0]?.src, alt: "" })) : null, _jsxs("div", { className: "satin-launch-error-message", children: [_jsx("h1", { children: glassError ? 'Glass Renderer Failed' : 'Unable to Open App' }), glassError ? (_jsx("pre", { style: { whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }, children: `${glassError.code} · ${glassError.stage}\n${glassError.message}${glassError.reason ? `\n${glassError.reason}` : ''}` })) : (_jsx("p", { children: preparationError })), _jsx("button", { type: "button", onClick: async () => {
|
package/dist/styles.css
CHANGED
|
@@ -349,7 +349,7 @@ body[data-satin-document='true'],
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
[data-satin-tab-item='true'][data-satin-tab-selected='true'] {
|
|
352
|
-
color: rgb(0 122 255);
|
|
352
|
+
color: var(--satin-tab-tint, rgb(0 122 255));
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
[data-satin-tab-icon='true'] {
|
|
@@ -387,7 +387,7 @@ body[data-satin-document='true'],
|
|
|
387
387
|
}
|
|
388
388
|
:where(html[data-satin-appearance='dark'])
|
|
389
389
|
[data-satin-tab-item='true'][data-satin-tab-selected='true'] {
|
|
390
|
-
color: rgb(64 156 255);
|
|
390
|
+
color: var(--satin-tab-tint, rgb(64 156 255));
|
|
391
391
|
}
|
|
392
392
|
:where(html[data-satin-appearance='dark']) [data-satin-tab-selection='true'] {
|
|
393
393
|
background: rgb(98 99 107 / 34%);
|
|
@@ -1129,7 +1129,7 @@ body[data-satin-document='true'],
|
|
|
1129
1129
|
color: inherit;
|
|
1130
1130
|
}
|
|
1131
1131
|
[data-satin-tab-placement='top'] [data-satin-tab-selected='true'] {
|
|
1132
|
-
color: var(--satin-sidebar-light-tabTint);
|
|
1132
|
+
color: var(--satin-tab-tint, var(--satin-sidebar-light-tabTint));
|
|
1133
1133
|
background: var(--satin-sidebar-light-tabSelection);
|
|
1134
1134
|
}
|
|
1135
1135
|
[data-satin-tab-placement='top'] [data-satin-tab-label] {
|
|
@@ -1162,7 +1162,7 @@ body[data-satin-document='true'],
|
|
|
1162
1162
|
:where(html[data-satin-appearance='dark'])
|
|
1163
1163
|
[data-satin-tab-placement='top']
|
|
1164
1164
|
[data-satin-tab-selected='true'] {
|
|
1165
|
-
color: var(--satin-sidebar-dark-tabTint);
|
|
1165
|
+
color: var(--satin-tab-tint, var(--satin-sidebar-dark-tabTint));
|
|
1166
1166
|
background: var(--satin-sidebar-dark-tabSelection);
|
|
1167
1167
|
}
|
|
1168
1168
|
|
|
@@ -2261,7 +2261,7 @@ body[data-satin-document='true'],
|
|
|
2261
2261
|
white-space: nowrap;
|
|
2262
2262
|
}
|
|
2263
2263
|
[data-satin-tab-layout='top'] .satin-lens-tab-item.satin-lens-is-selected small {
|
|
2264
|
-
color: var(--satin-sidebar-light-tabTint);
|
|
2264
|
+
color: var(--satin-tab-tint, var(--satin-sidebar-light-tabTint));
|
|
2265
2265
|
font-weight: var(--satin-sidebar-tabSelectedFontWeight);
|
|
2266
2266
|
}
|
|
2267
2267
|
:where(html[data-satin-appearance='dark'])
|
|
@@ -2274,7 +2274,7 @@ body[data-satin-document='true'],
|
|
|
2274
2274
|
[data-satin-tab-layout='top']
|
|
2275
2275
|
.satin-lens-tab-item.satin-lens-is-selected
|
|
2276
2276
|
small {
|
|
2277
|
-
color: var(--satin-sidebar-dark-tabTint);
|
|
2277
|
+
color: var(--satin-tab-tint, var(--satin-sidebar-dark-tabTint));
|
|
2278
2278
|
}
|
|
2279
2279
|
[data-satin-tab-layout='compact'] .satin-lens-tab-items .satin-lens-tab-icon {
|
|
2280
2280
|
width: 24px;
|
|
@@ -39,7 +39,8 @@ self.addEventListener('install', (event) => {
|
|
|
39
39
|
await reportProgress()
|
|
40
40
|
const activeDownloads = new Set()
|
|
41
41
|
let failureReport
|
|
42
|
-
const download = async (entry) => {
|
|
42
|
+
const download = async (entry, attempt = 0) => {
|
|
43
|
+
let received = 0
|
|
43
44
|
let networkFailure = true
|
|
44
45
|
let stalled = false
|
|
45
46
|
const controller = new AbortController()
|
|
@@ -76,7 +77,7 @@ self.addEventListener('install', (event) => {
|
|
|
76
77
|
progress.activity++
|
|
77
78
|
await reportProgress()
|
|
78
79
|
if (installFailure) throw new Error('Installation cancelled')
|
|
79
|
-
networkFailure =
|
|
80
|
+
networkFailure = response.status >= 500 || response.status === 408 || response.status === 429
|
|
80
81
|
if (!response.ok || response.type === 'opaque') throw new Error('HTTP ' + response.status)
|
|
81
82
|
if (response.redirected) throw new Error('Precache resource redirected')
|
|
82
83
|
const mime = (response.headers.get('content-type') || '').split(';')[0].trim().toLowerCase()
|
|
@@ -86,7 +87,6 @@ self.addEventListener('install', (event) => {
|
|
|
86
87
|
networkFailure = true
|
|
87
88
|
reader = response.body?.getReader()
|
|
88
89
|
const chunks = []
|
|
89
|
-
let received = 0
|
|
90
90
|
if (reader) {
|
|
91
91
|
while (true) {
|
|
92
92
|
const { done, value } = await Promise.race([reader.read(), idleFailure])
|
|
@@ -112,6 +112,15 @@ self.addEventListener('install', (event) => {
|
|
|
112
112
|
if (installFailure) throw new Error('Installation cancelled')
|
|
113
113
|
await cache.put(request, new Response(blob, { status: response.status, statusText: response.statusText, headers: response.headers }))
|
|
114
114
|
} catch (error) {
|
|
115
|
+
if (!installFailure && (networkFailure || stalled) && attempt < 2) {
|
|
116
|
+
clearTimeout(idleTimer)
|
|
117
|
+
activeDownloads.delete(cancelDownload)
|
|
118
|
+
// Retransmitted bytes are not extra installed bytes.
|
|
119
|
+
progress.loaded -= received
|
|
120
|
+
await new Promise(resolve => setTimeout(resolve, 250 * 2 ** attempt))
|
|
121
|
+
if (installFailure) throw error
|
|
122
|
+
return download(entry, attempt + 1)
|
|
123
|
+
}
|
|
115
124
|
if (!installFailure) {
|
|
116
125
|
installFailure = { type: 'SATIN_INSTALL_FAILURE', buildId: BUILD_ID, url: entry.url,
|
|
117
126
|
reason: error instanceof Error ? error.message : String(error), networkFailure, stalled }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@satinhq/kit",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Opinionated single-target framework for agent-generated personal iOS Home Screen apps.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"bin": {
|
|
108
108
|
"satin": "./bin/satin.mjs"
|
|
109
109
|
},
|
|
110
|
+
"homepage": "https://satin.build",
|
|
110
111
|
"scripts": {
|
|
111
112
|
"build": "node scripts/build.mjs",
|
|
112
113
|
"typecheck": "tsc -p tsconfig.json --pretty false",
|