Skip to content

Quest input: ray callbacks, click trace, menu button; glTF byte weights and cache lock - #476

Draft
oliedis wants to merge 2 commits into
developfrom
claude/quest-input-fixes
Draft

oliedis wants to merge 2 commits into
developfrom
claude/quest-input-fixes

Conversation

@oliedis

@oliedis oliedis commented Nov 28, 2026

Copy link
Copy Markdown
Member

The renderer half of the Quest fixes for the bugs the XR Demos apps (Soak Squad and others) found on Quest 3 with 3.2.3, all still present in 3.3.0. The ViroReact half is ReactVision/viro#638.

Not tested on a headset, and not built. No Quest was available, and dl.google.com is blocked where this was written, so there was no NDK: libviro_renderer.so has not been built with these changes. The five changed .cpp files were type-checked with host clang++ -fsyntax-only as the Android platform, against stubbed NDK headers. The WASM and iOS builds, which share Controller_JNI.cpp, VROInputPresenter.h, VROLog.h and VROGLTFLoader.cpp, were not compiled at all. CI's :viroreact:assembleDebug is the first real build.

What changed

Brief item Status Workaround ID
2.3 Ray callbacks held weakly Fixed viroreact-controller-ray-weak-callback
2.2 ViroController.onClickState receives nothing on Quest Instrumented; link hardened; menu button routed. Root cause unknown viroreact-quest-controller-click-route (keep)
2.8 glTF byte/short skin weights Fixed viroreact-gltf-byte-weights
2.9 glTF static caches Guarded. Cause of the reported corruption not found viroreact-gltf-static-cache (keep)
2.7 onHandUpdate Not attempted here: needs a new per-frame hand-joint callback viroreact-quest-hand-update (keep)
2.10 Sound preload No renderer change needed: fixed in viro#638

2.3: Controller_JNI.cpp

nativeGetControllerRayAsync and nativeGetControllerForwardVectorAsync take a strong global reference to the callback and delete it after calling, on every path. A context that has gone answers with no ray or a zero vector, where the forward-vector call used to return without calling back. There is no native timeout: the bridge in viro#638 has one (2 s), and with a strong reference the only request that never answers is one whose render queue never runs.

2.2: controller clicks

Reading the path end to end did not show where clicks to the presenter's delegate are lost while the scene-root route keeps working. What was ruled out by reading: the OpenXR input controller and its presenter are created once per renderer and never replaced, and nothing but Controller_JNI sets the presenter's delegate. So this PR does the three things the brief asked for whatever the cause:

  • Trace. pinput(...) logs under the logcat tag ViroInput, which the bridge uses too, at: each button edge flushed in VROInputControllerOpenXR::onProcess; onButtonEvent returning early because the ray has no hit result (this drops the click for every listener); VROInputPresenter::onClick (delivered, no delegate, or clicks not enabled); EventDelegate_JNI::onClick (handed to Java, or Java object gone); nativeSetEventDelegate (set, or dropped because the context, delegate or presenter was missing); nativeEnableEvent for clicks. With viro#638's bridge lines, one press on a headset shows the last hop reached.
  • Link. The presenter holds its delegate through a shared_ptr. A delegate whose Java object is gone drops its events itself and says so in the trace. nativeSetEventDelegate no longer dereferences a null presenter.
  • Menu button. notifyMenuButton also delivers to the scene root's delegate when clicks are enabled on it. No other node hears it. Behaviour change: a scene-level onClick / onClickState now fires for source 13.

The haptic pulse still fires on detection. The comment at that call now says so.

2.8: VROGLTFLoader::buildBoneWeightSource

The converted weights are described as floats: isFloat true, 4 components of 4 bytes, stride 16, length 16 * count. Before, the source used the accessor's component type over data that had already been converted. Also: a zero weight sum no longer divides, and the buffer is allocated with calloc because VROData frees with free.

2.9: VROGLTFLoader static caches

The whole build of a model already runs inside one rendering-thread task, between two clearCachedData() calls, so on a single rendering thread two loads cannot interleave in the caches. I could not find how models mounted in the same frame corrupt each other through them. What is unprotected is two rendering threads in one process, which the VRActivity re-entry bug (brief 2.6) produces. The build is now under a mutex, released before injectGLTF and before any failure callback, so a callback that starts another load cannot deadlock where dispatch is synchronous (WASM). Per-load state would be the fuller fix and is a much larger change to a 4,000-line loader that could not be built or run here.

Some of the reported "stray triangles" may have been 2.8.

2.7: not attempted

There is no hand-joint data path to forward. ViroViewOpenXR has no hand listener and nothing calls into Java with joints. Adding one means locating 26 joints per hand every frame and crossing JNI and the bridge at 72 to 90 Hz, on the same main thread whose load is the subject of brief 2.5. That needs a design (what to send, how often) and a device, so it is left as follow-up.

Smaller fixes on the way

  • nativeDestroyDelegate deleted its reference as VRONode. It now uses EventDelegate_JNI.
  • EventDelegate_JNI::onClick leaked its weak global reference when the Java object was gone.

To check on a Quest 3

Build the AAR from this branch into viro#638 and use examples/quest-input-validation there.

  1. getControllerRayAsync in a loop for 5 minutes under GC pressure: every request settles, none times out.
  2. Each trigger, A, B, X, Y and menu, aimed at nothing, at a node with no handlers, and after re-entering the headset view. Read adb logcat -s ViroInput: for each press the lines run from OpenXR button edge to EventDelegate onClick ... -> Java, and the bridge lines follow. The first missing line is where the click is lost.
  3. Menu button: ViroARScene onClickState receives source 13.
  4. The same rigged model exported with float, byte and short WEIGHTS_0 renders identically.
  5. 12 different rigged GLBs mounted in the same frame all render correctly.

Follow-up

  • 2.5: clicks and ray answers are delivered through VROPlatformDispatchAsyncApplication, behind every node command on the main thread. A dedicated thread or JSI delivery, and a synchronous read of the latest controller pose, is a design proposal and not part of this PR.
  • 2.7: a hand-joint callback, as above.
  • 2.9: per-load loader state.

Generated by Claude Code

doranteseduardo and others added 2 commits November 26, 2026 17:54
… the scene root; glTF byte weights and cache lock

Controller_JNI held the callbacks of getControllerRayAsync and
getControllerForwardVectorAsync weakly, so a garbage collection before the answer
dropped it. They are held strongly until called.

For ViroController.onClickState receiving nothing on Quest, whose cause is not
known: a ViroInput trace of each click through the input controller, the presenter
and EventDelegate_JNI; the presenter holds its delegate strongly; and the menu
button reaches the scene root as well as the controller's delegates.

glTF: byte and short skin weights were converted to floats but described with the
file's component type, which exploded the mesh. Builds through the loader's static
caches are under a lock.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoDeNibskBVXyR57tP3WdH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants