⚡ Bolt: Add emission threshold to CompassSensor#107
Conversation
… churn - Introduces a 1.0 degree emission threshold (`EMISSION_THRESHOLD`) in `CompassSensor.kt`. - Avoids blindly emitting new `CompassData` objects on every ~60Hz `onSensorChanged` callback. - Significantly reduces downstream Jetpack Compose UI recomposition churn by skipping imperceptible sensor fluctuations. - Documented findings in `.jules/bolt.md`. Co-authored-by: nacl-dev <243312305+nacl-dev@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Added an emission threshold (
EMISSION_THRESHOLD = 1.0f) toCompassSensor.ktso thatCompassDatais only emitted when the azimuth, pitch, or roll changes by more than 1 degree.🎯 Why: Before this change, the
CompassSensoremitted newCompassDataobjects at the raw hardware sensor rate (SENSOR_DELAY_UI, ~60Hz) even when the device was completely still due to minute sensor noise. Because this flow is observed as state in Jetpack Compose UI components (likeNachsucheScreen), it caused constant, imperceptible recomposition churn, leading to unnecessary GC pressure and potential micro-stutters.📊 Impact: Reduces UI recomposition events from ~60/sec to near 0/sec when the device is resting, and significantly throttles them during slow movement, saving battery and CPU cycles.
🔬 Measurement: Run the app and observe the
NachsucheScreencompass UI; it should remain smooth but with significantly fewer underlying state updates. Verified via./gradlew testDebugUnitTestand code review.PR created automatically by Jules for task 17745397877722462412 started by @nacl-dev