Repository navigation
fix(ipc-runtime): give iPads and desktop-mode iPhones the iOS wasm memory maximum #25760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
just-mitch
merged 3 commits into
next
from
mitch/zkm-1779-bbjs-gives-ipads-and-desktop-mode-iphones-the-desktop-memory
Nov 5, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
f58d34f
fix(bb.js): give iPads and desktop-mode iPhones the iOS memory and SR…
just-mitch 16b25b0
refactor: keep the ipc-runtime memory maximum in this layer, shorten …
just-mitch ecdb999
docs(ipc-runtime): state that the thread that creates the backend rea…
just-mitch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { afterEach, test } from "node:test"; | ||
| import { WasmFfiBackend } from "./wasm/backend.js"; | ||
| import { browserPlatform } from "./wasm/browser/platform.js"; | ||
| import type { WorkerHandle } from "./wasm/platform.js"; | ||
|
|
||
| const IPHONE = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)"; | ||
| const IPAD = "Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X)"; | ||
| const MAC = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"; | ||
|
|
||
| const realNavigator = Object.getOwnPropertyDescriptor(globalThis, "navigator")!; | ||
| afterEach(() => Object.defineProperty(globalThis, "navigator", realNavigator)); | ||
|
|
||
| for (const [device, userAgent, maxTouchPoints, pages] of [ | ||
| ["an iPhone", IPHONE, 5, 2 ** 14], | ||
| ["an iPad", IPAD, 5, 2 ** 14], | ||
| ["a Mac user agent with touch points", MAC, 5, 2 ** 14], | ||
| ["a Mac", MAC, 0, 2 ** 16], | ||
| ["a worker (no touch points) on an iPad or a Mac", MAC, undefined, 2 ** 16], | ||
| ] as const) { | ||
| test(`${device} gets a maximum of ${pages} memory pages`, () => { | ||
| Object.defineProperty(globalThis, "navigator", { | ||
| value: { userAgent, maxTouchPoints }, | ||
| configurable: true, | ||
| }); | ||
| assert.equal(browserPlatform.maximumMemoryPages!(), pages); | ||
| }); | ||
| } | ||
|
|
||
| async function mainWorkerMaximum(callerMaximum?: number): Promise<number> { | ||
| let init: any; | ||
| const handlers: ((message: unknown) => void)[] = []; | ||
| const worker: WorkerHandle = { | ||
| postMessage: (message) => { | ||
| init = message; | ||
| queueMicrotask(() => handlers.forEach((h) => h({ type: "ready" }))); | ||
| }, | ||
| onMessage: (handler) => handlers.push(handler), | ||
| onError: () => {}, | ||
| terminate: async () => {}, | ||
| unref: () => {}, | ||
| }; | ||
| await WasmFfiBackend.create( | ||
| { | ||
| module: new Uint8Array([0x00, 0x61, 0x73, 0x6d, 1, 0, 0, 0]), | ||
| memory: { maximum: callerMaximum }, | ||
| }, | ||
| { | ||
| platform: { ...browserPlatform, maximumMemoryPages: () => 1234 }, | ||
| createMainWorker: () => worker, | ||
| createThreadWorker: () => worker, | ||
| }, | ||
| ); | ||
| return init.options.memory.maximum; | ||
| } | ||
|
|
||
| test("the main worker gets the caller's memory maximum, else that of the thread that creates it", async () => { | ||
| assert.equal(await mainWorkerMaximum(99), 99); | ||
| assert.equal(await mainWorkerMaximum(), 1234); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check will identify the new MacBooks with touchscreens as iPads. Just pointing out in case we needed the extra memory on MacBooks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm yeah good point. We'll have to see when they're released if/how we need to tweak this.