Skip to content

Conversation

@markushi
Copy link
Member

📜 Description

When ViewUtils.findTarget returns null in SentryGestureListener.onScroll, the code was logging an error but not updating scrollState.type from Unknown. This caused repeated target searches and duplicate log messages on subsequent onScroll calls during the same gesture.

💡 Motivation and Context

Less verbose logging, better performance.

💚 How did you test it?

Added unit tests.

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

…llState.type

When ViewUtils.findTarget returns null in SentryGestureListener.onScroll,
the code was logging an error but not updating scrollState.type from Unknown.
This caused repeated target searches and duplicate log messages on subsequent
onScroll calls during the same gesture.

The fix sets scrollState.type = GestureType.Scroll even when target is null,
preventing repeated search attempts while maintaining existing behavior.

Fixes: "Unable to find scroll target. No breadcrumb captured." being logged repeatedly
@markushi markushi requested a review from Copilot July 16, 2025 09:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where scroll target logging was being repeated during Android gesture handling. When no scroll target is found in SentryGestureListener.onScroll, the code was logging an error but not updating the scroll state, causing duplicate log messages and unnecessary target searches on subsequent scroll events within the same gesture.

  • Updates scroll state type to prevent repeated target determination when no scroll target is found
  • Adds unit test to verify the fix ensures error logging occurs only once per gesture
  • Includes changelog entry documenting the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
SentryGestureListener.java Sets scroll state type to prevent repeated target searches when no scroll target is found
SentryGestureListenerScrollTest.kt Adds test verifying error message is logged only once per gesture when no scroll target exists
CHANGELOG.md Documents the fix for repeated scroll target determination

options
.getLogger()
.log(SentryLevel.DEBUG, "Unable to find scroll target. No breadcrumb captured.");
scrollState.type = GestureType.Scroll;
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Setting scrollState.type to GestureType.Scroll when no scroll target is found may be misleading. Consider using a more descriptive state like GestureType.NoTarget or adding a comment explaining why Scroll is appropriate when no target exists.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Jul 16, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 407.72 ms 464.44 ms 56.71 ms
Size 1.58 MiB 2.09 MiB 519.27 KiB

Previous results on branch: markushi/feat/improve-touch-handling

Startup times

Revision Plain With Sentry Diff
67a3117 465.51 ms 475.47 ms 9.96 ms
25c62a4 415.61 ms 462.63 ms 47.02 ms

App size

Revision Plain With Sentry Diff
67a3117 1.58 MiB 2.09 MiB 519.26 KiB
25c62a4 1.58 MiB 2.09 MiB 519.27 KiB

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, very simple change with a lot of impact 👀

markushi and others added 2 commits July 17, 2025 08:41
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
@markushi markushi merged commit 514ac01 into main Jul 17, 2025
34 checks passed
@markushi markushi deleted the markushi/feat/improve-touch-handling branch July 17, 2025 10:01
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