Skip to content

Commit 3bffdb0

Browse files
romtsnclaude
andcommitted
fix(feedback): Require minimum sample count before triggering shake
The 75% bit-shift formula degrades at low sample counts (e.g. 33% at 3 samples). With SENSOR_DELAY_NORMAL (~5Hz) the queue may hold only 3 samples in 0.5s. Adding a MIN_QUEUE_SIZE guard ensures the threshold stays accurate and prevents false triggers from walking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 82ea13d commit 3bffdb0

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

sentry-android-core/src/main/java/io/sentry/android/core/SentryShakeDetector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ private void purge(final long cutoff) {
201201
boolean isShaking() {
202202
return newest != null
203203
&& oldest != null
204+
&& sampleCount >= MIN_QUEUE_SIZE
204205
&& newest.timestamp - oldest.timestamp >= MIN_WINDOW_SIZE_NS
205206
&& acceleratingCount >= (sampleCount >> 1) + (sampleCount >> 2);
206207
}

0 commit comments

Comments
 (0)