Skip to content

Conversation

@ChrisPulman
Copy link
Member

What kind of change does this PR introduce?

Fixes #4185

What is the current behavior?

#4185

What is the new behavior?

Introduces AndroidMainThreadScheduler and AppleMainThreadScheduler properties for platform-specific main thread scheduling. Updates WithMauiScheduler to use the appropriate scheduler based on the target platform, improving UI thread handling for Android, iOS, macOS, and Mac Catalyst.

What might this PR break?

Resolves a threading issue with Maui

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

Introduces AndroidMainThreadScheduler and AppleMainThreadScheduler properties for platform-specific main thread scheduling. Updates WithMauiScheduler to use the appropriate scheduler based on the target platform, improving UI thread handling for Android, iOS, macOS, and Mac Catalyst.
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 introduces platform-specific main thread schedulers for MAUI to resolve threading issues (#4185). The changes add AndroidMainThreadScheduler and AppleMainThreadScheduler properties that use platform-appropriate schedulers (HandlerScheduler for Android and NSRunloopScheduler wrapped in WaitForDispatcherScheduler for Apple platforms). The WithMauiScheduler method is updated to conditionally select the appropriate scheduler based on the target platform.

Key Changes

  • Added AndroidMainThreadScheduler property using HandlerScheduler.MainThreadScheduler for Android platforms
  • Added AppleMainThreadScheduler property using WaitForDispatcherScheduler with NSRunloopScheduler for Apple platforms (iOS, macOS, Mac Catalyst)
  • Updated WithMauiScheduler() to use platform-specific schedulers via conditional compilation

Introduces WinUIMauiMainThreadScheduler for WinUI/.NET MAUI main UI thread scheduling, guarded by WINUI_TARGET. Updates platform preprocessor directives to include TVOS and ensures correct scheduler is used per platform in WithMauiScheduler.
Corrected XML documentation comments to consistently use 'MAUI' in uppercase, improving clarity and adherence to naming conventions.
Updated MauiReactiveUIBuilderExtensions to use RxApp.UnitTestMainThreadScheduler when running in a unit test environment. Also changed UnitTestMainThreadScheduler's visibility from private to internal to allow access from the Maui project.
@ChrisPulman ChrisPulman merged commit c13dfe0 into main Nov 30, 2025
6 of 8 checks passed
@ChrisPulman ChrisPulman deleted the FixFor4185 branch November 30, 2025 13:25
@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.94%. Comparing base (da99d4a) to head (01e3fd4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...UI.Maui/Builder/MauiReactiveUIBuilderExtensions.cs 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4212      +/-   ##
==========================================
+ Coverage   33.90%   33.94%   +0.03%     
==========================================
  Files         145      145              
  Lines        6264     6269       +5     
  Branches      943      944       +1     
==========================================
+ Hits         2124     2128       +4     
  Misses       3973     3973              
- Partials      167      168       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[Bug]: MAUI: Animators may only be run on Looper threads exception after updating to 22.1.1 version

3 participants