The same NativeScript conversion leak as the frame path (see
java-direct-buffer.ts) applied to every other ArrayBuffer handed to a
Java ByteBuffer parameter:
- Shell scenes (submitShellScene on the bridge and the preview display),
submitted on every shell render, which the frame-path fix predates.
These now go through a reused JavaDirectBuffer like frames do.
- Glyph, firmware-glyph and image atlas registration, Mapbox image
decode, the preview placeholder bitmap, firmware hash/write, binary
file writes and the EvenHub privacy-policy download, plus the Kotlin
protocol smoke test. These are rare or large, so they cross through a
new copyToJavaByteBuffer: a fresh Java direct buffer per call that is
freed normally, rather than one pinned for the life of the isolate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
connect() registers window surfaces in a loop that reads the foreground
window once, before the loop, then awaits each surface's configure call
before queuing its visibility. On a fresh process restoreOpenApps runs at
the same time and focuses windows as it relaunches them. The bridge runs
Java calls in order, so a visibility decided before the await lands after
the focus change's own calls and undoes them: the old foreground can stay
visible and cover the new one, and a later window switch doesn't clear
it, because a switch only hides the window being left.
configureWindowSurface now also accepts visibility as a function, asked
after the configure call, when the visibility call is queued. The display-
attach loops (glasses and preview), the display-mode, per-app layout and
vertical-position changes, and an in-process window's height-mode change
pass one. Launch paths that pass a literal false are unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Passing a JS ArrayBuffer to a Java ByteBuffer parameter leaks it in
@nativescript/android 9.0.4 through 9.1.1: JsArgConverter wraps the backing store with
NewDirectByteBuffer and takes a JNI global ref that it never deletes. The
ref keeps the ByteBuffer reachable, so makeInstanceWeakAndCheckIfAlive
always answers "alive", the JS finalizer re-arms, and V8 never frees the
ArrayBuffer. submitSurfaceFrame passed a fresh copy of each frame this way,
so every frame leaked a full surface (576x260, 640x452 or 640x480 bytes)
plus one global ref, including frames that Java then discards as unchanged.
The draw-list buffer and buzzer payloads leaked the same way.
Each payload now goes through a reused Java direct ByteBuffer
(app/native/java-direct-buffer.ts): JS writes into it through an
ArrayBuffer.from view, and the Java object itself is passed, which takes
NativeScript's ordinary object path. Every consumer (SurfaceCompositor
applyAndComposite, playBuzzerSequence) copies before returning, so one
buffer per JS context is safe.
Covered: the communicator bridge (frames, draw lists, buzzer, which also
carries EvenHub tones), the preview-only display, and all eight worker
apps. Workers submit through the Android getActiveDisplay() (frames) and
worker-buzzer (tones), so the reused buffers live there rather than in
each worker; the worker sources are shared with iOS, whose active display
takes the ArrayBuffer itself. The
smaller one-off crossings (glyph and image atlas registration, the gray
preview helper, firmware and file writes) are left as they are.
tests/java-direct-buffer.test.cjs covers the helper against a fake
ByteBuffer, and the Android worker-buzzer test stubs it.
(Rebased onto main by James Babcock: worker changes moved into
active-display.ts and worker-buzzer.ts.)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ported to the shared Kotlin FlashPromptFlow after the Java was converted. The settings ack the battery read already parses carries silentMode; read it before writing the prompt page, and refuse only on a positive report. An arm that does not answer, or an ack without the field, falls through to the prompt as before.
The native session already clears silent mode on touchpad input and re-reads it on every battery poll, so the TypeScript-side clearing duplicated that. The display-target trigger was also wrong: the communicator stays up in silent mode, so it cleared the flag on the next shell render.
tests/ios-glanceboard.test.cjs requires .test-build/app/g2/events.js, but events.ts was not in tests/tsconfig.json, so a clean build never produced it.
An ack is not a render: the lens can accept the create-prompt page and display
nothing, so a null check on the reply throws away the only thing that can say
what it did. The page size going out and the ack payload coming back are both
logged now.
Silent mode blanks the display and stops the firmware dispatching input while
BLE and GATT stay up, so the create-prompt page is written, accepted, and never
rendered. There is no touchpad event available to answer it with, and the flash
ends after four attempts on "prompt page not acked", which tells the wearer
nothing about what is wrong or what to do about it.
readBattery was already performing a sid-0x09 settings read whose ack carries
silentMode next to the battery, and the field was being discarded. readSettings
is factored out so one read serves both callers, and requireNotSilent runs it
before the prompt page is written. A positive report throws, and the existing
error path turns the message into what the wearer sees: that the glasses are in
silent mode, and that long-pressing both touchpads leaves it.
It refuses only on a positive report. An arm that does not answer, and firmware
whose ack omits the field, both fall through to the prompt exactly as before, so
older firmware is unaffected and a missing answer can never block a flash.
This replaces the phone-side confirmation fallback that was here before. An
unacked page is not by itself evidence that the prompt was never displayed, and
the on-lens step is what proves the glasses being flashed are the ones in front
of you, so overriding it on a timeout gave up more than it was worth.