Skip to content

feat: Auto-create traces for MAUI navigation events#5111

Draft
jamescrosswell wants to merge 11 commits intomainfrom
maui-transactions-5109
Draft

feat: Auto-create traces for MAUI navigation events#5111
jamescrosswell wants to merge 11 commits intomainfrom
maui-transactions-5109

Conversation

@jamescrosswell
Copy link
Copy Markdown
Collaborator

@jamescrosswell jamescrosswell commented Apr 2, 2026

Resolves: #5109

Out of scope

The Android and Cocoa SDKs instrument traces for navigation, gesture and scroll events. This PR does so only for navigation events.

See #5116 for details:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features ✨

  • feat: Auto-create traces for MAUI navigation events by jamescrosswell in #5111

Fixes 🐛

  • fix: CaptureFeedback now supports multiple attachments correctly by bitsandfoxes in #5077

Dependencies ⬆️

Deps

  • chore(deps): update CLI to v3.3.5 by github-actions in #5093
  • chore(deps): update Native SDK to v0.13.4 by github-actions in #5081
  • chore(deps): update Java SDK to v8.37.1 by github-actions in #5071
  • chore(deps): update CLI to v3.3.4 by github-actions in #5068
  • chore(deps): update Java SDK to v8.37.0 by github-actions in #5069
  • chore(deps): update Cocoa SDK to v9.8.0 by github-actions in #5044
  • chore(deps): update Java SDK to v8.36.0 by github-actions in #5036
  • chore(deps): update epitaph to 0.1.1 by github-actions in #5036

Other

  • chore: Update validate-pr workflow by stephanie-anderson in #5108
  • ci: fix workflows that always fail for fork PRs by jamescrosswell in #5065

🤖 This preview updates automatically when you update the PR.

/// Starts a transaction that will automatically finish after <paramref name="idleTimeout"/> if not
/// finished explicitly first.
/// </summary>
public ITransactionTracer StartTransaction(ITransactionContext context, TimeSpan? idleTimeout);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Technically it'd be a breaking change if we added this method to the public IHub interface. Potentially in v7 we could consider making this public and getting rid of the IHubInternal interface.


// Tracks the active auto-finishing navigation transaction so we can explicitly finish it early
// (e.g. when the next navigation begins) before the idle timeout would fire.
private ITransactionTracer? _currentTransaction;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Race condition: _currentTransaction field accessed without synchronization in singleton service

The _currentTransaction field is added to a singleton MauiEventsBinder and accessed from multiple event handlers (OnShellOnNavigating, OnApplicationOnModalPushed, OnApplicationOnModalPopped, OnWindowOnStopped) without thread synchronization. These handlers can fire concurrently from different navigation events. The StartNavigationTransaction method has a TOCTOU race where it checks _currentTransaction is { IsFinished: false } and then conditionally finishes or resets it - another thread could modify _currentTransaction between the check and the subsequent operations.

Verification

Read the full MauiEventsBinder.cs to trace all usages of _currentTransaction. Confirmed it's registered as singleton via SentryMauiAppBuilderExtensions.cs line 79. Found multiple event handlers modifying this field: StartNavigationTransaction (lines 327-366), OnApplicationOnModalPopped (lines 388-392), OnWindowOnStopped (lines 407-411). The StartNavigationTransaction method has check-then-act logic without locks (lines 330-334, 337, 364).

Identified by Warden find-bugs · HKG-HRW

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.

Transactions for UI events in MAUI

2 participants