Modern Apps git

← Modern-Apps.git

measure: make Reset tracking reset the native VIO session

Commit
983feecf6fa072312f5eec7a3ff7b52f945c6aec
Author
Vayun Mathur <[email protected]>
When
2026-11-07 20:15 UTC (28 days ago)
Parents
02ca9d1
Symptom: Reset tracking (AR page contract and the diagnostics
button) cleared the anchor list but tracking immediately continued
from the same diverged pose and landmark map.

Root cause: MeasureViewModel.resetTracking only reset UI state.
The native session handle lived solely in ArMeasurePage's
remembered state, so MeasureNative.reset was never called from
anywhere (its Kotlin wrapper had no call sites).

Fix: mirror the session handle into the ViewModel from
onSessionReady and call MeasureNative.reset in resetTracking.

Verification: :measure:compileDevKotlin and :measure:testDevUnitTest
green in the final batched run.

Diff

measure/src/main/java/com/vayunmathur/measure/platform/MeasureViewModel.kt
diff --git a/measure/src/main/java/com/vayunmathur/measure/platform/MeasureViewModel.kt b/measure/src/main/java/com/vayunmathur/measure/platform/MeasureViewModel.ktindex 3863bfb3c9..8a01325a51 100644--- a/measure/src/main/java/com/vayunmathur/measure/platform/MeasureViewModel.kt+++ b/measure/src/main/java/com/vayunmathur/measure/platform/MeasureViewModel.kt@@ -56,6 +56,9 @@ class MeasureViewModel(app: Application) : AndroidViewModel(app),     internal val diagnosticsState = MutableStateFlow(DiagnosticsUiState())     val diagnostics: StateFlow<DiagnosticsUiState> = diagnosticsState +    /** Native VIO session handle, mirrored from the AR page so reset can reach it. */+    internal var nativeSessionHandle: Long = 0L+     internal var nextAnchorId = 1L     internal var nextMeasurementId = 1L @@ -161,6 +164,10 @@ class MeasureViewModel(app: Application) : AndroidViewModel(app),     }      override fun resetTracking() {+        // Actually reset the engine, not just the UI: without this the+        // diagnostics Reset button cleared the anchor list while the+        // native session kept its (possibly diverged) pose and map.+        MeasureNative.reset(nativeSessionHandle)         clearAnchors()         arState.value = arState.value.copy(quality = TrackingQuality.Initialising, hasPlane = false)     }
measure/src/main/java/com/vayunmathur/measure/ui/ArMeasurePage.kt
diff --git a/measure/src/main/java/com/vayunmathur/measure/ui/ArMeasurePage.kt b/measure/src/main/java/com/vayunmathur/measure/ui/ArMeasurePage.ktindex c019b54ddf..d40a85b174 100644--- a/measure/src/main/java/com/vayunmathur/measure/ui/ArMeasurePage.kt+++ b/measure/src/main/java/com/vayunmathur/measure/ui/ArMeasurePage.kt@@ -103,7 +103,10 @@ fun ArMeasurePage(backStack: NavBackStack<Route>, viewModel: MeasureViewModel) {                     onTrackingUpdate = { q, hasPlane ->                         viewModel.onTrackingUpdate(trackingQualityFrom(q), hasPlane)                     },-                    onSessionReady = { sessionHandle = it },+                    onSessionReady = {+                        sessionHandle = it+                        viewModel.nativeSessionHandle = it+                    },                     onDiagnostics = { fps, skew, imuHz, tracked, landmarks, confidence ->                         viewModel.updateDiagnosticsImpl {                             copy(