Fix Piper memory pressure on iOS
Build and publish frontend / publish (push) Successful in 49s

This commit is contained in:
Ein Anderssono
2026-10-17 16:38:16 +02:00
parent b956527c72
commit c9b14e0726
6 changed files with 64 additions and 6 deletions
+13 -4
View File
@@ -14,10 +14,19 @@ test('ONNX Runtime base URL rejects an invalid worker origin', async () => {
assert.throws(() => createOnnxWasmPaths('undefined'), TypeError);
});
test('ONNX Runtime uses one thread and a bounded startup timeout', async () => {
test('Piper and ONNX Runtime stay on one thread even though Piper overwrites ONNX settings', async () => {
const {configureOnnxRuntime} = await import('../piper-onnx-config.mjs');
const navigatorObject = {hardwareConcurrency: 8};
const previousNavigator = globalThis.navigator;
Object.defineProperty(globalThis, 'navigator', {configurable: true, value: navigatorObject});
const runtime = {env: {wasm: {numThreads: 0, initTimeout: 0}}};
configureOnnxRuntime(runtime);
assert.equal(runtime.env.wasm.numThreads, 1);
assert.equal(runtime.env.wasm.initTimeout, 60000);
try {
configureOnnxRuntime(runtime);
assert.equal(navigatorObject.hardwareConcurrency, 1);
assert.equal(runtime.env.wasm.numThreads, 1);
assert.equal(runtime.env.wasm.initTimeout, 60000);
} finally {
if (previousNavigator === undefined) delete globalThis.navigator;
else Object.defineProperty(globalThis, 'navigator', {configurable: true, value: previousNavigator});
}
});
+6
View File
@@ -11,3 +11,9 @@ test('Piper worker is built and started as an ES module', async () => {
assert.match(buildScript, /outfile: join\(workerRoot, 'piper-worker\.js'\),\s*bundle: true,\s*format: 'esm'/);
assert.match(runtime, /new Worker\(workerUrl, \{type: 'module'\}\)/);
});
test('Piper runtime discards a worker after a failed initialization for a clean retry', async () => {
const runtime = await readFile(join(__dirname, '..', 'piper-runtime.js'), 'utf8');
assert.match(runtime, /TtsSession keeps a singleton even when ONNX initialization fails/);
assert.match(runtime, /worker\?\.terminate\(\);\s*worker = null;/);
});