forked from Blendman974/faceclaw
Fix some iOS crashes; show the ring connection setting
This commit is contained in:
1 parent
e12ea8ee4c
commit
7e59f4a58d
6 files changed
+103
-15
No files matched your search
@@ -20,17 +20,25 @@ export class SurfaceCompositor {
|
||||
this.surfaces.add(id)
|
||||
}
|
||||
removeSurface(id: string): void { this.native.removeId(id); this.surfaces.delete(id) }
|
||||
setSurfaceVisible(id: string, visible: boolean): void { this.native.visibleIdVisible(id, visible) }
|
||||
setSurfaceDepth(id: string, depth: number): void { this.native.depthIdDepth(id, depth) }
|
||||
hasSurface(id: string): boolean { return this.surfaces.has(id) }
|
||||
// Keep lifecycle errors catchable in JS; an undeclared Kotlin exception
|
||||
// crossing the Objective-C boundary terminates the process.
|
||||
private requireSurface(id: string): void {
|
||||
if (!this.surfaces.has(id)) throw new Error(`Unknown surface: ${id}`)
|
||||
}
|
||||
setSurfaceVisible(id: string, visible: boolean): void { this.requireSurface(id); this.native.visibleIdVisible(id, visible) }
|
||||
setSurfaceDepth(id: string, depth: number): void {
|
||||
this.requireSurface(id)
|
||||
if (!Number.isInteger(depth) || depth < -128 || depth > 127) throw new Error(`Invalid surface depth ${depth} for ${id}`)
|
||||
this.native.depthIdDepth(id, depth)
|
||||
}
|
||||
setUnderlayDim(belowZOrder: number, factor: number): void {
|
||||
if (!Number.isFinite(factor)) throw new Error('Invalid dim factor')
|
||||
this.native.dimBelowFactor(belowZOrder, factor)
|
||||
}
|
||||
setScreenBlanked(blanked: boolean): void { this.native.blankBlanked(blanked) }
|
||||
submitSurfaceFrame(id: string, pixels: Uint8Array, rect: SurfaceRect, draws: ArrayBuffer | null = null): void {
|
||||
// Keep lifecycle errors catchable in JS; an undeclared Kotlin exception
|
||||
// crossing the Objective-C boundary terminates the process.
|
||||
if (!this.surfaces.has(id)) throw new Error(`Unknown surface: ${id}`)
|
||||
this.requireSurface(id)
|
||||
if (![rect.x, rect.y, rect.width, rect.height].every(Number.isInteger)
|
||||
|| rect.width <= 0 || rect.height <= 0 || pixels.length !== rect.width * rect.height) throw new Error('Invalid frame buffer or rectangle')
|
||||
this.native.submitDrawsIdDataXYWidthHeightDraws(id, toData(pixels), rect.x, rect.y, rect.width, rect.height,
|
||||
|
||||
@@ -524,7 +524,10 @@ export class FaceclawCommunicatorBridge {
|
||||
id, Math.round(options.x), Math.round(options.y), Math.round(options.width), Math.round(options.height),
|
||||
Math.round(options.zOrder), transparency,
|
||||
);
|
||||
if (configured !== false) this.nativeSurfaces.add(id);
|
||||
// Kotlin logged why; reject so callers don't treat the surface as live (as on Android,
|
||||
// where the compositor's exception reaches JS).
|
||||
if (configured === false) throw new Error(`Could not configure surface ${id}`);
|
||||
this.nativeSurfaces.add(id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -85,12 +85,25 @@ export class PreviewDisplayTarget implements DisplayTarget {
|
||||
this.composited();
|
||||
}
|
||||
|
||||
/**
|
||||
* As on the live bridge (FaceclawCommunicatorBridge.hasNativeSurface): a call that lands
|
||||
* after its window closed, or on a target that replaced the one it was configured on, is
|
||||
* dropped rather than failing the caller.
|
||||
*/
|
||||
private hasSurface(id: string, what: string): boolean {
|
||||
if (this.compositor.hasSurface(id)) return true;
|
||||
console.log(`[ios-preview] ${what} for unknown surface ${id} dropped`);
|
||||
return false;
|
||||
}
|
||||
|
||||
async setSurfaceVisible(id: string, visible: boolean): Promise<void> {
|
||||
if (!this.hasSurface(id, "setSurfaceVisible")) return;
|
||||
this.compositor.setSurfaceVisible(id, Boolean(visible));
|
||||
this.composited();
|
||||
}
|
||||
|
||||
async setSurfaceDepth(id: string, depth: number): Promise<void> {
|
||||
if (!this.hasSurface(id, "setSurfaceDepth")) return;
|
||||
this.compositor.setSurfaceDepth(id, Math.round(depth));
|
||||
}
|
||||
|
||||
@@ -113,6 +126,7 @@ export class PreviewDisplayTarget implements DisplayTarget {
|
||||
_frameId = 0,
|
||||
glyphs: ArrayBuffer | null = null,
|
||||
): Promise<void> {
|
||||
if (!this.hasSurface(surfaceId, "frame")) return;
|
||||
this.compositor.submitSurfaceFrame(surfaceId, pixels8bpp,
|
||||
{ x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) }, glyphs);
|
||||
this.composited();
|
||||
|
||||
@@ -236,7 +236,8 @@ function settingsSections(): SettingsSection[] {
|
||||
if (!global.isIOS) return sections;
|
||||
const deferred = new Set(["Watch"]);
|
||||
return sections.map(section => {
|
||||
if (section.label === "Developer") return { ...section, items: [toggleSettingMenuItem(showBleBandwidthSetting)] };
|
||||
if (section.label === "Developer") return { ...section, items: [enumSettingMenuItem(ringConnectionModeSetting),
|
||||
toggleSettingMenuItem(showBleBandwidthSetting)] };
|
||||
// No downloadable on-device models: iOS's on-device option is Apple's recognizer.
|
||||
if (section.label === "Voice") return { label: "Voice", items: [enumSettingMenuItem(wakeWordActionSetting),
|
||||
enumSettingMenuItem(voiceProviderSetting)] };
|
||||
|
||||
Reference in new issue
Block a user