Skip to content

Add Device Tests, Apply Fixes for Bugs Found - #3344

Merged
TheCodeTraveler merged 427 commits into
mainfrom
Add-device-tests-and-ui-tests
Nov 8, 2026
Merged

TheCodeTraveler merged 427 commits into
mainfrom
Add-device-tests-and-ui-tests

Conversation

@TheCodeTraveler

@TheCodeTraveler TheCodeTraveler commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description of Change

This PR builds on @ne0rrmatrix's work in #3277. It adds device tests for the platform code the net10.0 unit tests cannot reach, runs them in CI on every platform, and fixes the bugs the tests and the Sample app walks found.

Review guide (for maintainers)
  • Final for review now:
  • Final for review too:
    • the device-test projects (src/CommunityToolkit.Maui.DeviceTests*) and their entries in src/CommunityToolkit.Maui.slnx and samples/CommunityToolkit.Maui.Sample.slnx;
    • eng/;
    • .github/: workflows, actions, instructions, copilot-instructions.md and the device-test entry of dependabot.yml;
    • .config/dotnet-tools.json and NuGet.config;
    • the device-test InternalsVisibleTo lines in Directory.Build.props;
    • the device-test sections of CONTRIBUTING.md and README.md.
  • The three device-test apps are now one, so each CI job builds one app instead of three. The sections Device-test apps, CI, Running the device tests locally and Dependabot below describe that state.
  • Already in this PR: the fix for a popup's CloseAsync when another page opened above the popup while the call waited. Before the fix, the call could close that page and hang.
  • All breaking and behavior changes are listed at the bottom, under Additional information.

What the device tests cover

  • The device-test app runs in Release on Android (API 28 and 36 emulators), iOS (simulator), Mac Catalyst and Windows (packaged and unpackaged).
  • CommunityToolkit.Maui.DeviceTests covers CommunityToolkit.Maui, CommunityToolkit.Maui.Core and CommunityToolkit.Maui.Maps:
    • alerts: Snackbar, Toast;
    • behaviors;
    • Essentials: Badge, FileSaver, FolderPicker, SpeechToText;
    • views: AvatarView, DrawingView, Expander, Popup, RatingView, SemanticOrderView, StateContainer;
    • StatusBar and NavigationBar;
    • Maps on Windows.
  • The same app covers:
    • MediaElement: the handlers and managers of each platform;
    • Camera: the CameraView, the camera providers and managers (preview, capture, video recording, camera switching, permissions).

Device-test apps

  • One app, CommunityToolkit.Maui.DeviceTests, tests every package, like the unit tests: CommunityToolkit.Maui, .Core, .MediaElement, .Camera and, on Windows, .Maps.
    • It is built like dotnet/maui's device tests: xUnit, a vendored test runner and XHarness.
    • The two extra apps are gone, with their manifests, icons and bundle ids.
    • Merging the apps kept history: the tests, the handler test bases and the Raw assets moved with git mv.
  • Supporting projects:
    • CommunityToolkit.Maui.DeviceTests.Shared: shared test code.
    • CommunityToolkit.Maui.DeviceTests.Runners: the vendored runner.
    • CommunityToolkit.Maui.DeviceTests.Runners.SourceGen: the runner's source generator, built against the toolkit's CodeAnalysisVersion.
  • The app declares Android 26 as its minimum, MediaElement's minimum. The libraries keep their own minimums.
    • The other packages' Android branches below 26 no longer have a device test.
    • CI ran only API 28 and 36, so no CI status changes.
  • Android: the twelve Camera classes that grant CAMERA and RECORD_AUDIO with pm grant run in a PermanentAndroidGrants collection, which a collection orderer runs last. So the SpeechToText tests that need RECORD_AUDIO denied still run first.
  • The infrastructure tests are split:
    • Each package keeps its own: MediaElementInfrastructureTests, CameraInfrastructureTests.
    • The main app's DeviceTestsInfrastructureTests now covers every class: feature categories, capability names, run-time skips.
    • 16 duplicate rows are dropped and 8 rows move to the new class names. No other test name changes.
  • Android runner fix (vendored): MauiTestActivity runs one test pass per process.
    • The bug: Android recreates the test activity for a configuration change the generated ConfigurationChanges does not list (font scale, locale, an overlay). The recreated activity's OnCreate started a second pass in the same process.
    • The fix: the recreated activity joins the running pass, and TestWindow drops a destroyed activity.
    • Proven on API 36 with a font-scale change during a run: two passes without the fix, one with it.
  • Android keyboard tests (UserStoppedTypingBehavior, MaxLengthReachedBehavior) type only once the soft keyboard shows steadily. Test-only.
    • On the API 36 emulator they could type before the keyboard was laid out, then read a frame without it (seen once in 44 runs).
  • Device-test helper bugs that .NET 11 exposes are fixed. Test-only; .NET 10 results are unchanged.
    • Android: the test MauiContext provides a NavigationRootManager, which a NavigationPage and MAUI 11's Shell read.
    • iOS and Mac Catalyst: the pixel assertions render the image once and scan its bytes on the calling thread. Before, a UIColor per pixel on the thread pool crashed under CoreCLR.
  • Android, test-only:
    • The camera test StartVideoRecordingDuringARecordingWhoseImageCaptureIsNotBoundBindsTheImageCaptureAgain waits 2 s after its own ImageCapture unbind, like its camera-switch sibling. So its second start no longer overlaps CameraX's capture-session reset, which once left a 0-byte recording on .NET 11.
    • The Android script sets a 64 MB logcat buffer on each attempt, so a long run keeps its logs.

CI

  • dotnet-build.yml calls the new device-tests.yml, which has no project input. Each platform builds and runs the one app in Release, on seven legs:
    • Android API 28 and API 36 emulators;
    • the iOS simulator: iOS 27.2 (xcode-27), and iOS 26.5 (macos-26, which tests the app that xcode-27 built once);
    • Mac Catalyst;
    • Windows, packaged and unpackaged.
  • Every leg runs eng/devices/run.ps1, the same command as a local run.
  • The coverage jobs (Android API 36, iOS and Mac Catalyst) build the app once. They instrument the toolkit assemblies before the app is built, instead of building the app and then repackaging it with the instrumented assemblies.
    • Locally, a run with coverage builds the one app once too.
  • The Android, iOS and Mac Catalyst jobs cache the NuGet packages and the .NET workload packs (keyed on the SDK and the workload set that run).
  • Timeouts per run: Android 50 minutes, iOS 60, Mac Catalyst 30, Windows 30.
    • Each is at least 2.5 times the measured test time of the three old apps: 19.6 minutes for Android on a local emulator, 22 minutes for iOS in CI.
  • iOS worst case: at most about 103 minutes, under the 120-minute job limit.
    • With the build-time instrumentation there is no repackaging, so a hang reaches the 01:00:00 run timeout and is never retried: 1.5 + 35 + 6.5 + 60 = 103.
    • 35 minutes is what the three apps' coverage builds took together in CI; the one app builds the shared code once.
    • An infrastructure retry of a full run is lower: 1.5 + 35 + 6.5 + 2 x 24 = 91 minutes.
  • A Windows job takes about 18-20 minutes packaged and 15-17 unpackaged, against 20-25 and 19-20 with the three apps.
    • Windows has only the NuGet cache, which saves seconds. It collects no coverage.
  • A Code Coverage job merges the unit-test and device-test coverage into one report and flags the coverage levels in GitHub Copilot's review colors.
  • .github/workflows/shared.env holds the tool versions the workflows share.

Running the device tests locally

  • One command, eng/devices/run.ps1, runs the device tests on every platform the machine can run.
  • eng/devices/LOCAL.md explains how to run and debug them. eng/devices/README.md describes the scripts and the CI jobs. CONTRIBUTING.md and README.md link to both.
  • .github/copilot-instructions.md and .github/instructions/device-tests.instructions.md give coding agents the same steps.
  • run.ps1 -Project MediaElement and -Project Camera fail with a message that names the filter to use: -TestFilter 'Category=<name>'.
  • If one package's tests crash the app, eng/devices/README.md has two ready-made SkipCategories lists: "everything but Camera" and "everything but MediaElement".

Dependabot

  • A weekly entry updates XHarness, coverlet and ReportGenerator: the runner project's packages and the local tools in .config/dotnet-tools.json.
  • The /samples entry ignores these four, so they are not updated twice.

Product fixes

  • The first commit fixes the bugs the device tests found in:
    • Alerts: Snackbar and Toast.
    • Behaviors: TouchBehavior, IconTintColorBehavior, ImageTouchBehavior, SelectAllTextBehavior, MaskedBehavior, MaxLengthReachedBehavior, UserStoppedTypingBehavior and the validation behaviors.
    • Essentials: Badge, FileSaver, FolderPicker and SpeechToText.
    • Views: AvatarView, DrawingView, Expander, Popup, RatingView, SemanticOrderView and StateContainer.
    • StatusBar and NavigationBar.
    • Camera, MediaElement, and Maps on Windows.
  • Later commits fix:
    • Camera:
      • StartCameraPreview and the commands report failures through ErrorOccurred and MediaCaptureFailed.
      • A first start that fails because of the camera follows SelectedCamera.
      • StopCameraPreview cancels a start, a video-recording start or a camera switch that still waits for the platform.
      • Android: the preview starts when the activity resumes with the camera permission.
      • Android: StartCameraPreview after SetExtensionMode on a stopped preview shows the selected camera.
      • Video recording after the merge of Await native video recording start acknowledgment #3311, including:
        • A restore failure after a successful export.
        • A double tap on iOS.
        • A start cancelled while it waits.
      • Android, iOS, Mac Catalyst and Windows: a video recording on a stopped preview turns the camera on for the recording and off again afterwards.
      • Windows: MediaCapture races, a start while the preview runs, and StopCameraPreview during a recording.
      • StopVideoRecording with a cancelled token stops the recording and throws OperationCanceledException on every platform.
      • Windows: a StartVideoRecording during a recording ends the running recording first.
      • An app's CameraViewHandler.PlatformViewFactory no longer makes CameraView throw InvalidOperationException (older than this PR). The camera shows in the factory's view.
      • Android, after another screen such as FileSaver's save dialog or Home (older than this PR):
        • The camera uses ZoomFactor again instead of zoom 1.
        • The torch comes back on when IsTorchOn is true; before, it stayed off.
    • MediaElement:
      • An event handler's exception during a Source change is reported through MediaFailed.
      • Windows: a late rate notification no longer undoes a newer Speed.
      • A disconnected MediaElement stops its position timer, so a page that was left can be collected (found on iOS). This holds even when Windows raises MediaOpened after the disconnect.
      • The Sample's MediaElementFromStreamPage is no longer disposable: the window's service scope kept every page that was opened.
    • SpeechToText:
      • A StartListenAsync that still waits for the platform (on Windows, and for a start from a background thread on iOS and Mac Catalyst):
        • A StopListenAsync or DisposeAsync ends that start without an exception, where it threw a NullReferenceException or ObjectDisposedException.
        • The stopped start no longer uses or releases a newer start's recognizer.
        • Windows: a newer StartListenAsync during the wait releases the waiting start's recognizer. The waiting start then ends without listening and without an exception, instead of going on with the newer start's recognizer.
        • iOS and Mac Catalyst: cancelling the stopped start's token no longer makes it throw OperationCanceledException and stop a newer start's recognition.
      • Windows: a start releases the recognizer left by a session that ended by itself.
      • Windows: a released recognizer is closed only after its native operations have ended. Closing it while it compiled its constraints crashed the app (0xC0000005 in Windows.Media.Speech).
    • Popup:
      • BackgroundColor precedence and the theme default.
      • The platform setup is redone when a popup above it closes.
      • The iOS keyboard observers are released with the window.
      • The navigation lock is released before the result is returned.
      • The Android gesture overlay stays hidden from TalkBack.
      • ShowPopupAsync completes, and Closed is raised, when navigation removes the popup without CloseAsync.
      • A tap outside the popup, or the Android Back button, no longer crashes the app when an earlier tap, Back or navigation already closed the popup.
      • CloseAsync of a popup shown on a modal NavigationPage under a Shell closes only the popup.
      • A close that waits for an earlier popup operation throws PopupBlockedException when a popup or page was shown above its popup meanwhile. A tap outside or Back does nothing in that case. Before, the close popped that popup or page and hung, which blocked every later popup in the app.
      • ShowPopupAsync, CloseAsync and ClosePopupAsync throw OperationCanceledException instead of never completing when the app cancels the navigation (a Shell.Navigating handler, or Window or Application ModalPopping setting e.Cancel).
    • StatusBar:
      • Colors without alpha on Android 15+.
      • SetStyle on iOS with .NET 10.
      • The iOS status bar view follows rotation and lets touches through.
      • iOS 26: the status bar color comes back after an iPhone turns back to portrait. The color view kept a height of 0 until the next StatusBar call.
      • iOS: merged [iOS] StatusBar: apply the color only to the app windows #3373 from main (not from this PR): the status bar color is applied only to the app's windows. 4 new iOS StatusBar device tests cover it.
      • Android 6.0 is now the minimum for StatusBarBehavior.
    • Behaviors:
      • TouchBehavior inside a CollectionView on Android and Windows.
      • TouchBehavior and ImageTouchBehavior on Windows: a quick click sometimes did nothing.
        • From then on, clicks at the same spot did nothing either and left the element looking pressed (an ImageTouchBehavior image kept its PressedImageSource).
        • A click worked again once the pointer had left the element and come back.
      • Keyboard dismissal.
      • The validation behaviors' Errors thread and IsRunning.
    • Windows:
      • Badge without package identity.
      • Toast and Snackbar: each removes only its own notification, and Show waits up to 1 s for Windows to list it.
      • The SemanticOrderView Tab order.
      • Expander keyboard and UI Automation support.
      • DrawingView pointer capture.
      • GravatarImageSource pictures.
      • Maps Satellite.
    • Views:
      • AvatarView: the text that replaces a failed or empty image waits until the image is laid out, so a Gravatar that failed to load offline loads again when its Email changes.
      • RatingView FillOption.
      • StateContainer.
      • Expander accessibility on Android, iOS and Mac Catalyst.
      • The modal page layout of DialogFragmentService on Android.
      • SemanticOrderView, which ignored ViewOrder when the app set ContentViewHandler.PlatformViewFactory (older than this PR).
    • Null guards: the public and protected API of the five libraries throws ArgumentNullException for a null argument it cannot handle.
    • Maps: CommunityToolkit.Maui.Maps is marked [Obsolete] and recommends Microsoft.Maui.Controls.Maps. The package is removed in Update to .NET 11 #3331.
    • GravatarImageSource in a Button (see item 31 under Additional information):
      • The picture is requested at the smaller of the WidthRequest and HeightRequest that the Button sets, or at 80 pixels. So on iOS and Mac Catalyst the Button no longer grows until it is as wide as the screen (older than this PR).
      • Windows: the picture is drawn whole, at most at its natural size, and the Button no longer grows for it.
    • Snackbar (Windows): Show no longer throws ArgumentOutOfRangeException for a Duration such as TimeSpan.MaxValue or TimeSpan.MinValue (older than this PR).
    • StringToListConverter: a Separators list with one entry splits at that entry, as documented, instead of at Separator (older than this PR).
  • Sample app:
    • The 84 commits named "Sample (...)" fix the Sample app.
      • One of them makes the Popups page's C# Binding button await ShowPopupAsync, so a double tap opens one popup instead of two. Proven on Android: one dim layer and one Back press, where the old code stacked two popups.
    • The Complex popup's overlay-color loop stops when the popup closes; it kept running and kept each page's view model alive.
    • The SpeechToText and OfflineSpeechToText pages no longer start the recognizer when the page was left while the permission prompt was open.
    • Page texts, titles, messages and accessibility descriptions now say what each page does.
    • The custom Snackbar button reads "Display Custom Snackbar" again once its Snackbar is dismissed.
    • A text sweep fixed 12 page bugs, for example:
      • Every Behaviors page scrolls.
      • DrawingView "Save image" shows where it saved the drawing.
      • SpeechToText "Language Output" shows each word once.
    • The Views gallery shows 10 cards instead of 27: its AvatarView, MediaElement, RatingView and Maps pages are grouped into four cards that each open a page of buttons, like Popups.
    • The HttpClient retry settings apply to every HttpClient the container creates (ConfigureHttpClientDefaults); the two typed-client registrations never applied. MediaElementFromStreamPage catches the handler's ExecutionRejectedException, which would have crashed the app.
    • The StatusBarBehavior page:
      • The Shell.TitleView demo (no longer "Broken") has a Back button.
      • Back or the Android back key returns to the page as the user left it: same color, style and scroll position.
      • Coming back from the modal page keeps the chosen alpha and style.

Breaking changes: only two items touch the API at build time: StatusBarBehavior and the Maps deprecation. The complete list, grouped by API, behavior, and setup or dependencies, is under Additional information.

Linked Issues

Partially Fixed (will be finished in a future PR): #3317, #2894, #2691, #3063, #2952, #1987, #2645, #3220, #3248, #2602, #3190

Partially Fixed (already closed, will be finished with #3317): #2383, #2950

Related, not fixed by this PR:

PR Checklist

Additional information

Tested on (CI on 6634c69 passed on every leg, 0 failed):

  • Android API 28 and API 36 emulators (ubuntu-24.04 runners): API 28 2325 passed and 236 skipped, API 36 2459 passed and 102 skipped.
  • iOS 27.2 simulator, iPhone 18 Pro (xcode-27 runner): 2380 passed, 45 skipped.
  • iOS 26.5 simulator, iPhone 17e (macos-26 runner, testing the app built on xcode-27): 2380 passed, 45 skipped.
  • Mac Catalyst (xcode-27 runner): 2264 passed, 51 skipped.
  • Windows packaged and unpackaged (windows-2025 runners): packaged 1655 passed and 261 skipped, unpackaged 1650 passed and 266 skipped.
  • The Sample app walks on Windows ran on a Windows 11 VM.
  • CI's Windows runners don't support Windows notifications, so the Toast and Snackbar device tests skip there:
    • In the CI run of 6634c69, packaged and unpackaged alike: Toast skipped 37 and passed 0; Snackbar skipped 71 and passed 2. Seven of those Snackbar skips need a person to press a notification's button.
    • The Windows 11 VM is the only Windows evidence for these two. Their Windows fixes ran there, packaged and unpackaged, in Release.
  • CI's Windows runners have no camera, so the Windows Camera tests that need one skip there. On the Windows 11 VM, the Windows Camera tests passed unpackaged:
    • 974c6f4, an earlier commit of this PR, with the VM's cameras: 184 passed, 0 failed, 19 skipped (they need a machine without a camera, or a feature the cameras lack).
    • 2a8bfb4, on the same VM camera: of 209 tests, 189 passed, 0 failed, 20 skipped (they need a machine without a camera, a second camera, or a feature the camera lacks).
      • This commit of the PR carries the later Windows changes to a cancelled StopVideoRecording and to a start during a recording (item 12).
      • Every new test of those changes passed, and so did the two tests that fail without the earlier Windows recording fixes.
    • Why unpackaged: a packaged app needs the user's camera consent in Windows' privacy settings, which changes no toolkit code.

Running the device tests: pwsh ./eng/devices/run.ps1 runs every platform the machine can run. See eng/devices/LOCAL.md.

Breaking changes and behavior changes (for the GitHub Release notes)
  • ApiCompat found no removed or changed public type or member; the only API differences are additions.
  • Null arguments throw ArgumentNullException at the call, in all five libraries.
  • CommunityToolkit.Maui.Core adds a <queries> entry to Android apps and references System.Speech 10.0.11 on Windows.
All packages
  • API: Null arguments throw ArgumentNullException at the call. Public and protected members of the five libraries now guard the non-nullable reference parameters they cannot handle (about 275 guards).
    • A null that used to cause a NullReferenceException later (or was stored silently) fails at the call, with a ParamName. What to do: fix the caller.
    • An async member throws from the call itself, before it returns a Task.
    • Null arguments that a member handled before are still accepted, for example an IProgress<double> or a Paint background of null.
    • Feature-specific effects are listed in each feature's section.
    • BasePlatformBehavior guards only bindable. A null platform view passes through, because the Android IconTintColorBehavior accepts it.
  • Setup: CommunityToolkit.Maui.Core on Android adds a <queries> entry for the launcher (MAIN/HOME) to the app's merged manifest through the package's library manifest (src/CommunityToolkit.Maui.Core/AndroidManifest.xml). Badge needs it on Android 11 and later. If your app or Play listing reviews <queries>, check the merged manifest.
  • Setup: Dependencies: on Windows, CommunityToolkit.Maui.Core references System.Speech 10.0.11 (it was 10.0.1). No action is needed unless you pin the package. This comes from Update Unit Tests Packages #3288 on main, not from this PR.

ApiCompat found no removed or changed public type or member in the five libraries, on any target framework. Baselines: the released packages CommunityToolkit.Maui and CommunityToolkit.Maui.Core 15.0.1, Camera 6.1.0, MediaElement 10.0.0 and Maps 4.0.0.

  • Checked on 4a8d407 with Microsoft.DotNet.ApiCompat.Tool 10.0.403: each library on net10.0, Android, iOS, Mac Catalyst and Windows (25 comparisons). The Windows assemblies were built on a Mac.
  • The only API differences are additions:
    • the new API from other PRs, listed below;
    • Popup declares IPaddingElement, which it already inherited from ContentView (ApiCompat lists it only on the Windows target);
    • GravatarImageSource declares IStreamImageSource, which it already inherited from StreamImageSource, and overrides Cancel() (see GravatarImageSource, after that ApiCompat run);
    • [Obsolete] on the Maps types (see Maps);
    • [SupportedOSPlatform("android23.0")] on the Android StatusBarBehavior (see StatusBar and StatusBarBehavior).

New API in this release from other PRs (not this one):

AvatarView
  • Behavior: AvatarView.
    • HorizontalOptions, VerticalOptions, HeightRequest, WidthRequest, Padding, Stroke, StrokeThickness and StrokeShape are no longer local values, so an implicit AvatarView Style applies (and a Border Style with ApplyToDerivedTypes).
    • An empty image source shows Text on every platform; iOS, Mac Catalyst and Windows showed an empty circle. Set Text to "" for a blank circle.
    • The text replaces a failed or empty image only once the image has been laid out (about one layout pass later), because a GravatarImageSource asks for its picture only after its image has a size. So:
      • An AvatarView whose Gravatar failed to load while the page opened offline shows the picture again when the Email changes or a new load succeeds.
      • Such an AvatarView may show an empty circle for that one layout pass before the text.
Badge
  • Setup: CommunityToolkit.Maui.Core adds a <queries> entry for the launcher (MAIN/HOME) to Android apps; Badge needs it on Android 11 and later (see All packages).
  • Behavior: Badge on Windows without package identity. In an unpackaged app, Badge.SetCount writes one trace line and returns, instead of throwing a COMException that ended the app. No badge appears, so package the app if you need the taskbar badge.
CameraView
  • API: Null arguments: ErrorOccurredEventArgs, MediaCaptureFailedEventArgs and CameraInfo reject null for their non-nullable members.
  • Behavior: Failures are reported through events instead of exceptions.
    • StartCameraPreview(CancellationToken) no longer throws for a camera that cannot start (except in the Android failed-connection case below). It raises ErrorOccurred on every platform.
      • A cancelled token still throws OperationCanceledException.
      • A view without a handler still throws InvalidOperationException.
    • The commands let no exception escape:
      • CaptureImageCommand, StartVideoRecordingCommand and StopVideoRecordingCommand report through MediaCaptureFailed.
      • StartCameraPreviewCommand and StopCameraPreviewCommand report through ErrorOccurred.
    • Failures of the handler's own work (connecting, switching to SelectedCamera, applying ImageCaptureResolution) raise ErrorOccurred instead of ending the app.
    • Android:
      • A preview without the camera permission now fails, is reported, and stays stopped until the activity resumes with the permission. iOS and Mac Catalyst report a denied permission the same way.
      • CaptureImage before the camera has started throws CameraException instead of waiting until its token is cancelled.
    • What to do: subscribe to ErrorOccurred and MediaCaptureFailed instead of relying on try/catch.
  • Behavior: Android: one ErrorOccurred for a failed connection. A StartCameraPreview called while the CameraView connects to its camera waits for the connection.
    • When the connection fails and raises ErrorOccurred, that StartCameraPreview throws the same failure to its caller instead of raising ErrorOccurred again. StartCameraPreviewCommand doesn't report it again.
    • What to do: catch the exception where you await such a start.
  • Behavior: StopCameraPreview cancels starts that still wait. StopCameraPreview and StopCameraPreviewCommand now cancel a pending StartCameraPreview, a pending StartVideoRecording (both overloads), the start the view makes when it connects its camera, and a camera switch.
    • The cancelled start throws OperationCanceledException, with no ErrorOccurred or MediaCaptureFailed. A start that a stop interrupted needs a new start.
    • What to do: do not treat that exception as a failure.
    • On iOS and Mac Catalyst, StartCameraPreview with an already-cancelled token throws and no longer starts the session.
  • Behavior: Video recording.
    • Android: a StartVideoRecording during a recording replaces it: the new stream receives the video, and the earlier recording's video is discarded. Camera 6.1.0 ignored the second start; iOS and Mac Catalyst already replaced it.
    • Android, iOS, Mac Catalyst and Windows: a start that arrives while an earlier start still waits for the platform joins it. It returns once that recording has started, its stream receives no video, and it throws the earlier start's failure. On iOS and Mac Catalyst this holds for a double tap too, where Camera 6.1.0 replaced the first recording.
    • StartVideoRecording returns only once the platform has started the recording (Await native video recording start acknowledgment #3311), so await it before relying on the recording. On iOS and Mac Catalyst, a start cancelled while it waits releases the recording state.
    • Windows, as on Android, iOS and Mac Catalyst:
      • StopVideoRecording waits for a pending StartVideoRecording.
      • A StartVideoRecording or a second StopVideoRecording that arrives while a stop waits for Media Foundation to finish the recording waits for that stop.
    • StopVideoRecording throws CameraException on Android, iOS and Mac Catalyst when the platform reports a recording with no playable video. A recording the platform ended early that has usable video is still returned.
    • Android: when the photo session cannot be restored after a successful export, StopVideoRecording still returns the video, and the failure is raised through ErrorOccurred. Selecting another camera during a recording waits until the recording stops or is replaced.
    • Windows: a StopVideoRecording whose token is cancelled already or while the stop finishes the video:
      • It still stops the recording and throws OperationCanceledException, as on Android, iOS and Mac Catalyst. It used to ignore the token and return the video.
      • The next StopVideoRecording returns the video. A StartVideoRecording that comes first discards it and puts its stream back, as for a replaced recording.
      • The camera that the recording turned on is off again when the cancelled stop throws.
      • A cancelled stop while a start or another stop is still pending throws without stopping anything.
      • With no recording, a cancelled StopVideoRecording returns Stream.Null on every platform.
      • StopVideoRecordingCommand ends without an event.
      • Camera 6.1.0 already handled a cancelled stop this way on Android and iOS; Mac Catalyst follows iOS.
      • Catch the OperationCanceledException and call StopVideoRecording again to get the video.
    • Windows: a StartVideoRecording during a recording ends and finishes the running recording and discards its video.
      • The running recording's stream goes back to the length and position it had when that recording started.
      • The video goes to the stream of the latest start, as on Android, iOS and Mac Catalyst. The camera stays on in between.
      • Camera 6.1.0 prepared a second recording without ending the first, so the first video was left unfinished or the new stream stayed empty.
      • If you relied on the first recording continuing, call StopVideoRecording before a new start.
    • What to do: handle ErrorOccurred and CameraException. On Android, don't rely on a second start being ignored.
  • Behavior: Recording while the preview is stopped starts the camera.
    • On Android, iOS, Mac Catalyst and Windows, StartVideoRecording after StopCameraPreview, or before StartCameraPreview, starts the camera and then the recording. Android already did; Camera 6.1.0 recorded nothing on iOS, Mac Catalyst and Windows.
    • A camera that the recording turned on turns off again when the recording ends. After a cancelled StopVideoRecording on Android, iOS and Mac Catalyst, it turns off only once the next stop returns the video.
    • A preview that the app started stays on.
    • When the camera can't start, a stopped preview stays stopped. On iOS, Mac Catalyst and Windows, StartVideoRecording throws the failure: for example a CameraException without a camera or without the camera permission, or on Windows an UnauthorizedAccessException when the privacy settings block the camera. StartVideoRecordingCommand reports it through MediaCaptureFailed.
    • On Android, a StartCameraPreview after SetExtensionMode on a stopped preview shows the SelectedCamera. Camera 6.1.0 kept showing the camera that was selected when SetExtensionMode ran.
  • Behavior: Windows: a start while the preview runs, and a stop during a recording.
    • StartCameraPreview while the preview already runs is a no-op.
    • A StartCameraPreview while an earlier start is still opening the camera releases that start's MediaCapture, so the camera is never held twice.
    • StopCameraPreview during a recording ends the recording, like on Android. A later StopVideoRecording returns Stream.Null, so do not expect a video from a recording that a stop ended.
  • Smaller change: CameraView with an app's CameraViewHandler.PlatformViewFactory:
    • The camera shows in the factory's view, which the toolkit doesn't dispose.
    • On Windows, only a MediaPlayerElement shows the preview. Another element shows none, and a warning is written to the trace output.
  • Smaller change: CameraView on Android applies ZoomFactor and IsTorchOn again after another screen, such as FileSaver's save dialog or Home.
ColorAnimationExtensions
  • Behavior: BackgroundColorTo and TextColorTo with a rate of 0 throw ArgumentOutOfRangeException from the call. Before, the error came later on the animation ticker and ended the app. Pass a rate above 0.
DialogFragment (Android)
  • Behavior: Android modal pages and the status bar. DialogFragmentService lays the dialog of a modal page out like the activity's window, for every status bar color.
    • On Android 11 and newer, a modal page receives the status bar inset. It must keep clear of the status bar itself, as a page in the activity's window does.
    • On Android 10 and older, a modal page also receives window insets with a transparent status bar color, where it received none.
DrawingView
  • Behavior: DrawingView.
    • On iOS and Mac Catalyst, GetImageStream with no lines returns Stream.Null instead of throwing InvalidOperationException, and a NaN image size, or one that is infinite on both sides, throws ArgumentException. Handle Stream.Null where you caught the exception.
    • An image scaled to ImageOptions.DesiredSize has its pixel size rounded half away from zero on Android, iOS and Mac Catalyst, as Windows already did. A 1920 x 1080 target of a 411 DIP canvas gives 1920 x 934 on Android, where it gave 1919 x 934.
    • On Windows a line captures the pointer, so a line released outside the view completes with DrawingLineCompleted, a lost capture raises DrawingLineCancelled, and a second pointer no longer starts or changes a line. No action is needed unless you worked around the old behavior.
  • Smaller change: An unloaded view keeps its handler and listens again when it is loaded. DrawAction draws in a canvas state of its own.
Expander
  • Setup: Windows, iOS and Mac Catalyst: UseMauiCommunityToolkit registers the Expander layout handler (see Behavior below), so keep calling it at startup. That handler keeps its own platform view even when the app sets LayoutHandler.PlatformViewFactory.
  • Behavior: Expander accessibility.
    • On Windows the Expander is a Tab stop that Enter and Space toggle. UI Automation exposes it as a Button with the ExpandCollapse and Invoke patterns.
    • On Android, iOS and Mac Catalyst the header is one element for TalkBack and VoiceOver, with expand and collapse actions.
    • The Expander's internal layout now resolves to an internal ExpanderLayoutHandler, so a handler an app registers for Grid no longer applies to the Expander's internal Grid; LayoutHandler.Mapper changes still apply.
    • On Windows, iOS and Mac Catalyst, an app's LayoutHandler.PlatformViewFactory no longer creates the platform view of that layout, so the layout keeps the platform view that gives the header this support. The factory still creates the platform views of the app's other layouts, including the ones in the Expander's Header and Content, and on Android also the platform view of that layout.
  • Smaller change: Expander Direction can be changed again by bindings and Styles.
FileSaver and FolderPicker
  • API: Null arguments throw ArgumentNullException at the call; FileSaver and FolderPicker still return the exception in the result. (see All packages)
  • Behavior: FileSaver and FolderPicker.
    • progress reports percentages from 0 to 100. It reported fractions from 0 to 1 during the copy, then a final 100, so remove any * 100 you applied.
    • A stream that cannot seek no longer fails the save; it gets only the final report.
    • On Android, a document whose provider gives no file path, such as a cloud document, is a successful save whose FilePath is its content:// URI. It used to fail with FileSaveException. Open such a path with the ContentResolver.
    • A null fileName or stream (and a null initialPath for FolderPicker) comes back as an ArgumentNullException in the result, without showing the picker.
GravatarImageSource
  • Behavior: GravatarImageSource.
    • The email is trimmed and lower-cased before hashing, as Gravatar requires, so mixed-case addresses now load their real image.
    • The download is fully read into a seekable stream, so on Windows the picture shows again. HttpClient.Timeout limits the whole download, and a body that fails halfway gives Stream.Null.
    • One load no longer cancels another.
    • A load that you start with CancellationToken.None never throws. Only a token that you pass and cancel makes GetStreamAsync and the default Stream function throw OperationCanceledException, instead of returning Stream.Null. .NET MAUI catches it for the loads that it cancels itself, so a view keeps the picture of the load that replaced it.
    • Cancel() ends only the loads started without a cancelable token, which then return Stream.Null. Its task always completes with true.
    • What to do: catch the exception where you call Stream or GetStreamAsync with your own token.
  • Behavior: GravatarImageSource in a Button.
    • The picture is requested at the smaller of the WidthRequest and HeightRequest that the Button sets, or at Gravatar's default 80 pixels, and again when those requests change. It was requested at the Button's laid-out size, so on iOS and Mac Catalyst each picture made the Button larger until it was as wide as the screen (older than this PR).
    • Image, ImageButton and AvatarView still request the size they are laid out at.
    • A Button without size requests now gets an 80-pixel picture instead of one the size of the laid-out Button: on a 420 dpi Android screen, a 30 dp icon instead of 15 dp. Set HeightRequest on the Button for a smaller picture.
    • Windows: the picture is drawn whole, at most at its natural size, and scaled down to the room the Button has for it. The Button no longer grows for it.
      • Before this change, the picture loaded on Windows only with this PR's download fix (see the GravatarImageSource change above). It was then stretched to the Button's width, and the Button clipped it to a thin band.
      • A Button whose image is above or below its text (ContentLayout Top or Bottom) needs a HeightRequest that leaves room for the picture.
      • A Button without Text needs a HeightRequest or MinimumHeightRequest. The .NET MAUI app template's Button style sets MinimumHeightRequest to 44.
      • This works around a .NET MAUI behavior: on Windows, MAUI limits a Button's picture to its natural size only when it sees the BitmapImage's ImageOpened event, which a picture decoded from a stream has already raised.
KeyboardExtensions
  • Smaller change: KeyboardExtensions on iOS and Windows call the platform on the UI thread. IsSoftKeyboardShowing called from another thread blocks until the UI thread answers. The tasks of HideKeyboardAsync and ShowKeyboardAsync complete once the UI thread has done the work.
Maps
  • API: CommunityToolkit.Maui.Maps is deprecated. UseMauiCommunityToolkitMaps, its AppBuilderExtensions class and the Windows handler MapHandlerWindows are [Obsolete].
    • Code that uses them gets warning CS0618, an error in builds that treat warnings as errors.
    • The package is removed in a later major version (Update to .NET 11 #3331).
    • What to do: move to .NET MAUI's own Map in Microsoft.Maui.Controls.Maps, which supports Windows since .NET MAUI 10 (see Setup below). Until then, suppress CS0618 around the call.
    • The warning says: "Call UseMauiMaps() from .NET MAUI's Microsoft.Maui.Controls.Maps instead; it supports Windows since .NET MAUI 10, where it needs an Azure Maps key", with a link to Deprecate Map Control in favor of MAUI Map implementation #3190.
  • Setup: Change the package and the startup call.
    • Remove the CommunityToolkit.Maui.Maps package, its using CommunityToolkit.Maui.Maps; directives and the UseMauiCommunityToolkitMaps call.
    • Reference the Microsoft.Maui.Controls.Maps package directly; the toolkit package referenced it for you.
    • Call builder.UseMauiMaps() on every platform.
    • On Windows, also call builder.ConfigureEssentials(essentials => essentials.UseMapServiceToken("YOUR_AZURE_MAPS_SUBSCRIPTION_KEY")). There the map is the WinUI 3 MapControl backed by Azure Maps, and it shows no map data without a valid key.
    • On Windows, .NET MAUI's Map has no IsShowingUser, no polygons, polylines or circles in MapElements, no pin labels or info windows, and no MapClicked. MoveToRegion, the Street, Satellite and Hybrid map types, traffic, scrolling, zooming and pins work.
    • See https://learn.microsoft.com/dotnet/maui/user-interface/controls/map?view=net-maui-10.0 and Deprecate Map Control in favor of MAUI Map implementation #3190.
  • Behavior: Maps on Windows.
    • The info window of a pin shows Label and Address as plain text, not as HTML, so remove markup from pin labels.
    • A pin without Location is not shown.
    • MapType.Satellite shows aerial imagery without place or road labels; it was identical to Hybrid. Use MapType.Hybrid where you want the labels.
MaskedBehavior
  • Smaller change: MaskedBehavior on iOS and Mac Catalyst applies the mask during the text change.
MaxLengthReachedBehavior
  • API: Null arguments: MaxLengthReachedEventArgs rejects null for its non-nullable members.
  • Behavior: Keyboard dismissal. MaxLengthReachedBehavior hides the keyboard only while its own InputView has the focus, and through the view's own window. So Android no longer hides the keyboard of the view the user moved to, and the keyboard goes away in a modal page or a Popup too. No action is needed.
MediaElement
  • API: Null arguments: FileMediaSourceConverter.ConvertFrom(null) throws ArgumentNullException.
  • API: Null arguments: MediaFailedEventArgs rejects null for its non-nullable members.
  • Behavior: An exception thrown by an event handler while Source changes is reported through MediaFailed.
    • Before, an exception from a StateChanged, PropertyChanged or PropertyChanging handler reached the code that set Source, or ended the app when MAUI set it from XAML or a binding.
    • Now it is logged and the change goes on. The first exception is reported once through MediaFailed: ErrorMessage names its type and message, and CurrentState is not set to Failed.
    • What to do: handle MediaFailed, and check ErrorMessage before treating every MediaFailed as a failed source.
  • Behavior: MediaElement playback.
    • SeekTo clamps a position outside the media to its start or end and raises SeekCompleted. On iOS such a seek never completed.
    • SeekTo fails with the platform's exception, for example InvalidOperationException before the player is ready, where that exception ended the app.
    • Play() at the end of the media starts it again on iOS and Mac Catalyst, as on Android.
    • On Android, CurrentState reports Buffering while buffering (it was Paused) and Stopped at the end of the media.
    • A source without data empties the player and reports None.
    • What to do: check code that relied on the old states.
  • Behavior: A disconnected handler stops the position timer. The MediaElement no longer keeps its page alive after the page is left. No action is needed.
    • Why: the dispatcher timer stops when the handler disconnects, and starts again when a handler connects later.
    • Found on iOS: a probe left the Sample's MediaElementPage alive 3 of 3 times after it was left (0 of 3 with the fix). The same leak is fixed and tested on Android, Mac Catalyst and Windows.
    • On Windows, MediaOpened arrives on the player's worker thread. An open that was still running when the handler disconnected no longer starts the timer again: the timer starts on the UI thread, and only while a handler is attached.
    • A second leak was in the Sample: MediaElementFromStreamPage was IAsyncDisposable, so the window's service scope kept every page that was opened.
      • iOS: a probe left the page alive 3 of 3 times before the change, 0 of 3 after.
      • Windows (the Sample at 4a8d407, 5 visits, a GC dump after the 5th Back): 0 MediaElementFromStreamPage, MediaElement or StreamMediaSource stay alive, GC heap 6.5 MB. With the Sample change reverted: 5 of each, 167.7 MB.
  • Behavior: Also fixed: FileMediaSourceConverter.ConvertFrom had an inverted condition. A real path threw InvalidOperationException, and an empty or white-space string returned a source. Now a real path returns the FileMediaSource, and an empty or white-space string throws InvalidOperationException, as documented.
NavigationBar (Android)
  • Behavior: NavigationBar (Android). The default Color is still transparent, but it is now a plain default value, so reading the color no longer makes IsSet true. As a result:
    • A page that never set a color no longer gets one applied.
    • Clearing Color or Style gives the window back its original color.
    • From Android 15 the color is drawn as a view over the navigation bar.
    • What to do: check pages that relied on the old default.
Popup
  • API: Null arguments: Options.SetPopupDefaults(null) and SetPopupOptionsDefaults(null) no longer store null.
  • API: Null arguments: The async void PopupExtensions.ShowPopup overloads throw to the caller instead of posting the exception to the SynchronizationContext.
  • Behavior: BackgroundColor is null by default, and Styles now apply. Margin, Padding, HorizontalOptions, VerticalOptions, CanBeDismissedByTappingOutsideOfPopup and BackgroundColor are now default values. 15.0.1 set them as local values in the constructor.
    • A Style can set them, and Popup.BackgroundColor reads null until something sets it.
    • A popup without a background shows DefaultPopupSettings.BackgroundColor, or in the dark theme BackgroundColorDark: black with Add Popup support for AppTheme, Introduce DefaultPopupSettings.OnInitializing #3345 in this release, where 15.0.1 showed white.
    • What to do: set BackgroundColor where a fixed color is needed, and check popups in the dark theme.
  • Behavior: Navigation that removes a popup page ends ShowPopupAsync. When navigation removes the popup page without CloseAsync, ShowPopupAsync completes and Closed is raised exactly once. Before, neither happened, and code that awaited it stayed suspended.
    • Such navigation: Shell switching to another Shell element, PopModalAsync or PopAsync called by other code, Window.Page being replaced, or Shell popping the popup out of a modal NavigationPage.
    • Both happen one dispatcher cycle after .NET MAUI has removed the popup page, so a Closed handler can show another popup.
    • The result is the existing "closed without a result" shape:
      • WasDismissedByTappingOutsideOfPopup is true. It now means "closed without a result: by tapping outside the popup, or because navigation removed it"; it is false only after CloseAsync.
      • For ShowPopupAsync<TResult>, Result is null for a reference or nullable type. Reading it for a value type such as int throws PopupResultException, as after a tap outside.
    • What to do: check WasDismissedByTappingOutsideOfPopup first. Subscribe to Closed if you must tell a tap from a navigation removal.
    • If navigation removes the page before .NET MAUI reports that it was navigated to, Closed is raised without a preceding Opened.
    • A CancellationToken used as a timeout keeps working.
    • With a Shell as the root page, CloseAsync and ClosePopupAsync of a popup shown on a modal NavigationPage close only the popup. CloseAsync used to pop the whole page and never complete, and ClosePopupAsync threw PopupBlockedException.
    • A close that finds another page on top when it runs throws PopupBlockedException and pops nothing:
      • CloseAsync, Popup.CloseAsync and ClosePopupAsync (also through IPopupService) wait for earlier popup operations. When the close finally runs, they check again that the popup is still the page on top.
      • This applies when another page was pushed above the popup in the meantime, for example a popup that ShowPopupAsync was showing, or a modal page your code pushed. They already threw PopupBlockedException and popped nothing when that page was on top at the call.
      • Before, including in 15.0.1, they popped that other page and then never completed, so no popup in the app could open or close again. In some layouts they reported the popup closed while it stayed on screen.
      • ClosePopupAsync still targets the popup that was the most recent when you called it, not the newer one. Call it again to close the newer one.
      • A tap outside the popup or the Android Back button does nothing in this case. It no longer crashes the app if that other page is already on top when the tap runs.
    • A tap outside the popup, or the Android Back button:
      • no longer crashes the app (through async void) when an earlier tap, Back or navigation has already closed the popup;
      • ignores a pop that .NET MAUI canceled, where it crashed the app (on iOS and Mac Catalyst a NavigationPage cancels a PopAsync that waited behind a navigation that failed). The popup stays open, and a later tap closes it.
  • Behavior: ShowPopupAsync, CloseAsync and ClosePopupAsync throw OperationCanceledException when the app cancels the navigation.
    • When the app cancels the navigation that removes a popup (a Window.ModalPopping or Application.ModalPopping handler that sets e.Cancel, or a Shell.Navigating handler that cancels), Popup.CloseAsync, Popup<T>.CloseAsync, ClosePopupAsync and IPopupService.ClosePopupAsync throw OperationCanceledException. The popup stays open and usable, Closed is not raised, and the navigation lock is released.
    • When a Shell.Navigating handler cancels the navigation that shows a popup (ShowPopupAsync of a Shell, or of a page or INavigation under a Shell root), every ShowPopupAsync overload, also through IPopupService, throws OperationCanceledException and nothing is shown.
    • Before, these calls never completed. A close that the app canceled also held the navigation lock, so no popup in the app could open or close again, and the tap outside the popup stopped working.
    • ShowPopup and the tap outside or Android Back show nothing, or do nothing, and throw nothing.
    • To tell this from your own token, catch OperationCanceledException when (!token.IsCancellationRequested).
    • A .NET MAUI limitation that this PR does not change: in a Shell whose current tab has a page pushed below the popup, a ModalPopping handler that cancels makes .NET MAUI retry the pop in a loop, so CloseAsync cannot return. Cancel in Shell.Navigating there instead.
  • Smaller change: A popup shown from OnDisappearing of a modal page that is closing appears on the page below.
  • Smaller change: A WidthRequest or HeightRequest larger than the window is limited to the window.
  • Smaller change: Opened is raised once per show.
  • Smaller change: PopupClosed and Closed are raised after the navigation lock is released, in the same order as before.
RatingView
  • Smaller change: RatingView redraws when FillOption changes.
SelectAllTextBehavior
  • API: Null arguments: SelectAllTextBehavior on Windows throws ArgumentNullException instead of InvalidOperationException for a null platform view (only a derived class can reach it).
SemanticOrderView
  • Behavior: SemanticOrderView on Windows sets the Tab order. Check the Tab order of screens that use it.
    • The views of ViewOrder that the container holds are listed first in its tab focus children, followed by the rest of its content.
    • A TabIndex that the app set is no longer overwritten. The exception: views of ViewOrder that a control within the container (a ScrollView, for example) holds, or that are outside the container, still get a TabIndex from the order.
    • It does not change Narrator's scan order, which follows the visual tree.
  • Smaller change: An app's ContentViewHandler.PlatformViewFactory no longer creates the SemanticOrderView's platform view, so ViewOrder applies.
    • The factory still creates the platform views of the other content views and pages.
    • To customize that view, override CreatePlatformView in a handler derived from SemanticOrderViewHandler, and register it after UseMauiCommunityToolkit.
Snackbar and Toast
  • Behavior: Windows Toast and Snackbar remove only their own notification. Each removes its notification by Id. No action is needed unless the app relied on the old clear-all (below).
    • Before, a Toast.Show or Toast.Dismiss after an earlier toast, and a Snackbar.Show or Snackbar.Dismiss while a snackbar was shown, removed every notification of the app (AppNotificationManager.RemoveAllAsync). That included the other alert and the notifications the app shows itself, on screen and in the Action Center.
    • Since a Show no longer clears the app's other notifications, a Toast or Snackbar shown while another notification banner of the app is on screen waits behind that banner, as Windows queues banners.
    • Show now returns once Windows lists the new notification. That takes up to 1 s longer when Windows lists nothing for the app, for example while its notifications are off. A Snackbar whose Duration is zero or less does not wait.
    • Overlapping Show and Dismiss calls now take effect in call order. A call whose token is cancelled before its turn removes nothing and throws OperationCanceledException.
    • Do not block on a Show or Dismiss Task inside a Shown or Dismissed handler: .Wait() and .Result deadlock there.
  • Smaller change: Snackbar on Windows:
    • It is dismissed at the end of Duration, raises Dismissed once and runs its action on the UI thread.
    • Show can take up to 1 s longer while the app's notifications are off (see Behavior above).
    • Show no longer throws for a Duration such as TimeSpan.MaxValue or TimeSpan.MinValue.
  • Smaller change: Snackbar on Android: a Duration below 1 ms shows it for 1 ms, and Dismissed is raised once.
  • Smaller change: Toast on Windows is removed at the end of Duration.
SpeechToText
  • Setup: CommunityToolkit.Maui.Core references System.Speech 10.0.11 on Windows (see All packages).
  • Smaller change: StartListenAsync with null options throws ArgumentNullException from the call (see All packages: null arguments). With valid options, a canceled token still returns a canceled Task, so awaiting it throws OperationCanceledException.
  • Smaller change: On Windows, and for a start from a background thread on iOS and Mac Catalyst, an interrupted StartListenAsync completes without an exception and without listening, even if its token is canceled afterwards.
    • Here "interrupted" means StopListenAsync or DisposeAsync (on Windows, also a newer StartListenAsync) is called while the start waits for the platform.
StateContainer
  • Behavior: StateContainer. A StateKey that is not defined throws StateContainerException with its own message and no inner exception. It used to throw the "assigned to multiple StateViews" message, so change any code that matches the message text.
StatusBar and StatusBarBehavior
  • API: StatusBarBehavior requires Android 6.0 (API 23). The Android type is now [SupportedOSPlatform("android23.0")], like StatusBar already was.
    • C# code that uses it in a project with a lower minimum Android version (the .NET MAUI templates use 21) gets warning CA1416, which fails builds that treat warnings as errors.
    • What to do: raise the minimum Android version to 23, or create the behavior inside if (OperatingSystem.IsIOS() || OperatingSystem.IsAndroidVersionAtLeast(23)). Not IsAndroidVersionAtLeast(23) alone: it is false on iOS.
    • A StatusBarBehavior declared in XAML gets no warning.
    • Nothing changes at run time: on Android 5.0 and 5.1 it did nothing before and still does nothing.
    • CommunityToolkit.Maui's minimum Android version stays 5.0 (API 21), the same as .NET MAUI 10's.
  • Setup: iOS: remove UIViewControllerBasedStatusBarAppearance from Info.plist if you set it to false for StatusBar.SetStyle (see Behavior below).
  • Setup: Android: StatusBarBehavior needs a minimum Android version of 23 or a guard (see API above). CommunityToolkit.Maui's minimum Android version stays 5.0 (API 21), the same as .NET MAUI 10's.
  • Behavior: iOS, .NET 10: StatusBar.SetStyle and StatusBarBehavior. SetStyle no longer needs UIViewControllerBasedStatusBarAppearance set to false in Info.plist.
    • The first LightContent or DarkContent replaces preferredStatusBarStyle until the app ends, for every view controller that does not choose its own style (the system pickers included). Default gives each view controller its own style back.
    • With the key set to false, the style still applies in apps built with an iOS SDK before 27, but not with the iOS 27 SDK (Xcode 27): the app keeps its status bar style and the call writes a trace message. So remove the key from Info.plist.
    • SetStyle called off the main thread throws UIKitThreadAccessException, in Release builds too, so call it on the main thread.
  • Smaller change: On Android 15+, colors without alpha no longer paint the bars black. On iOS, the status bar color view follows rotation and lets touches through, and on iOS 26 it comes back after an iPhone turns back to portrait.
StringToListConverter
  • Smaller change: StringToListConverter splits at the entry of a one-entry Separators list, as documented; before, it split at Separator.
TouchBehavior
  • Smaller change: Windows selects the tapped CollectionView item. On Android and Windows, a tap on a header, footer or empty view selects nothing.
  • Smaller change: The state events are raised at once with the new value.
  • Smaller change: ShouldMakeChildrenInputTransparent takes effect when it changes.
  • Smaller change: A NaN DefaultOpacity, HoveredOpacity or PressedOpacity throws ArgumentOutOfRangeException, where 15.0.1 accepted it.
  • Smaller change: On Windows, a release now ends every press, as on Android (iOS also cancels a touch for good once it has left the element). Whatever CurrentHoverStatus says, a release over the element completes the tap (Command, TouchGestureCompleted), and a release outside it cancels.
    • Before, a Windows release completed only while the hover status was Entered. So a release outside the element could complete, and one over it could leave the press running.
UserStoppedTypingBehavior
  • API: Null arguments: The async void overrides of UserStoppedTypingBehavior throw to the caller instead of posting the exception to the SynchronizationContext.
  • Behavior: Keyboard dismissal. UserStoppedTypingBehavior hides the keyboard only while its own InputView has the focus, and through the view's own window. So Android no longer hides the keyboard of the view the user moved to, and the keyboard goes away in a modal page or a Popup too. No action is needed.
  • Behavior: UserStoppedTypingBehavior.StoppedTypingTimeThreshold rejects a negative value. A negative value is ignored and the previous value is kept (MAUI logs a warning). Before, it failed inside Task.Delay. Use 0 or more.
Validation behaviors
  • API: Null arguments: The async void overrides of ValidationBehavior throw to the caller instead of posting the exception to the SynchronizationContext.
  • Smaller change: Validation behaviors validate again when a rule changes. Errors is set on the UI thread, and IsRunning is reset after a cancel.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 10, 2026 22:02
@TheCodeTraveler
TheCodeTraveler marked this pull request as draft October 10, 2026 22:04

This comment was marked as outdated.

@TheCodeTraveler TheCodeTraveler changed the title Add device tests for CommunityToolkit.Maui Add device tests for CommunityToolkit.Maui, Apply Fixes for Bugs Found Oct 10, 2026
TheCodeTraveler added a commit that referenced this pull request Oct 11, 2026
…evice tests

- CameraProvider (Windows): the camera refresh skips a camera that InitializeCameraForCameraView could not open, instead
  of reading the VideoDeviceController of a MediaCapture that never initialized (its getter throws, so one such camera
  made the whole refresh fail). New Windows device test:
  CameraProviderWindowsTests.RefreshWhileAnotherCaptureHoldsACameraListsExactlyTheCamerasThatCanBeOpened.
  (Copilot review on #3344)
- Device tests: the AttachAndRun tests of the Maui, MediaElement and Camera apps wait for the Loaded and Unloaded events
  they count. OnLoadedAsync returns once the view is loaded, which can come before MAUI raises Loaded on a slow
  emulator (Android API 28 in CI).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TheCodeTraveler
TheCodeTraveler requested a balanced review from Copilot October 11, 2026 02:56

This comment was marked as outdated.

@TheCodeTraveler

Copy link
Copy Markdown
Collaborator Author

We're now up to 89.5% Line Coverage and 82% Branch coverage across all unit tests and device tests. That's pretty great!

Code Coverage Report:
https://github.com/CommunityToolkit/Maui/actions/runs/38106699644/attempts/1#summary-114378095598

image

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

@TheCodeTraveler TheCodeTraveler added the breaking change This label is used for PRs that include a breaking change label Oct 11, 2026
ne0rrmatrix added a commit to ne0rrmatrix/EbpubReaderV2 that referenced this pull request Oct 14, 2026
- Unit tests for CalibreCoverUrl, OpdsEntryStagingCache, EpubPathUtilities,
  EpubArchive and PositionSyncService.
- tests/DisplayBook.DeviceTests: a MAUI app that runs xUnit on the device
  (DeviceRunners), covering code that calls MAUI APIs: BookStorageService,
  BookDatabase, OpdsServerRepository, OpdsCatalogCache, FirebaseAuthService
  (SecureStorage), GoogleBooksOptions (Preferences) and the value converters.
  Modelled on CommunityToolkit/Maui#3344.
- tools/coverage.ps1: unit tests + Windows device tests under dotnet-coverage,
  merged into artifacts/coverage/coverage.xml (Visual Studio XML).
- .github/workflows/build.yml: build, tests and coverage between the
  SonarQube Cloud scanner's begin/end.
- Android signing: the keystore and its passwords leave the repository. They
  now come from Secrets.local.props locally and from repository secrets in CI;
  without them Android builds sign with the debug key.
@TheCodeTraveler
TheCodeTraveler force-pushed the Add-device-tests-and-ui-tests branch from 2cda4d3 to 3f57379 Compare October 16, 2026 04:57
@TheCodeTraveler
TheCodeTraveler requested a balanced review from Copilot October 16, 2026 05:20

This comment was marked as outdated.

This comment was marked as outdated.

TheCodeTraveler and others added 5 commits November 7, 2026 12:51
… no longer makes Show throw

DateTimeOffset.Now.Add(Duration) throws ArgumentOutOfRangeException when the sum passes DateTimeOffset.MaxValue or MinValue, so Show threw for a Duration such as TimeSpan.MaxValue, although DismissAfterDurationAsync already treats such a Duration as never. C#/WinRT also throws when AppNotificationListing reads back an Expiration whose local time passes DateTime.MaxValue, which a cap at DateTimeOffset.MaxValue hits east of UTC. The expiration is now capped one day before DateTimeOffset.MaxValue and a zero or negative Duration expires at the time of Show. Device tests check the expiration of a TimeSpan.MaxValue Snackbar and show a TimeSpan.MinValue Snackbar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…overlaps the capture-session reset of the test's own ImageCapture unbind

StartVideoRecordingDuringARecordingWhoseImageCaptureIsNotBoundBindsTheImageCaptureAgain unbinds the ImageCapture during a recording, which makes CameraX reset its capture session, and started the second recording right away. In the .NET 11 rehearsal of #3331 (CoreCLR on Android) that rebind came during the reset once, CameraX did not open the camera again, and the new recording file stayed empty. CameraX publishes no state for the end of the reset, so the test now waits the two seconds of AssertTheRecordingKeepsRunningAsync first, like its camera-switch sibling; that also checks that the unbind did not end the first recording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the Shell.TitleView page to the StatusBarBehavior page as the user left it

'Go to Broken Shell.TitleView' replaced the app's Shell with BrokenTitleViewShell, the repro of #2351 from #3189, and gave no way back: 'Click me' went to //MainPage, which left the TabBar and stranded the user on a page without tabs, and the Android back key closed the app. Only a relaunch left the page, which lost where the user was.

The button is now 'Back'. StatusBarBehaviorPage hands its window's Page, the app's Shell, to BrokenTitleViewShell, which sets that same instance back on Back and on the Android back key. Its navigation stack and the StatusBarBehavior page with its view model stay alive while the demo is shown, so the user returns to the page with the color and style they picked, scrolled to where they left it, and the back key there still goes to the Behaviors gallery. The page's StatusBarBehavior applies its settings again when the page is loaded again, so its status bar replaces the demo's LightContent. On Android, setting the Shell back gives the page a new ScrollView that starts at the top, so the page scrolls back to its offset when it is loaded again. The window insets that give the new ScrollView its bottom padding arrive after its first layout, and until then it cannot scroll as far as the old one, at the default font size not at all. ScrollY still holds the old ScrollView's offset, so the page first sets it to the new ScrollView's top, and then scrolls again every 50 ms, for at most 1 second, until ScrollY reaches the offset.

.NET MAUI handles the back key only while the window can go back (a modal page, a pushed page or an open flyout), which this Shell never can, so on Android 13 and later (android:enableOnBackInvokedCallback) the back key closed the app without calling OnBackButtonPressed: BrokenTitleViewShell adds its own OnBackPressedCallback while it is shown.

Since #3189 the title view is no longer broken (walked on Android 36, Android 28, iOS 27.2, Mac Catalyst and Windows), so the button says 'Go to Shell.TitleView'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… chosen alpha and style

After 'Pop Modal Page', OnNavigatedTo set the status bar to the chosen red, green and blue with an alpha of 1, so the status bar was opaque while the page's Alpha stepper and its Alpha label still showed the chosen alpha, and it left the style of the modal page's own StatusBarBehavior (Default) in place after the user had chosen Light or Dark content.

OnNavigatedTo now applies the view model's StatusBarColor and StatusBarStyle, the values the page's StatusBarBehavior binds to. The Android and iOS check is now a runtime check that leaves out Mac Catalyst, where OperatingSystem.IsIOS() is also true and StatusBar throws NotSupportedException. It also ends the CA1416 warning that SetColor had on the iOS build, where the compiler saw the call as reachable on Mac Catalyst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

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.

🟡 Changes recommended

Active findings identify unchecked native-view casts and dereferences that can cause runtime exceptions instead of actionable assertion failures when test prerequisites are unmet.

3 open issues
2 resolved since last review

Review effort: Balanced

TheCodeTraveler and others added 3 commits November 7, 2026 21:59
…compiles the constraints must stay open until the compilation ends

Windows.Media.Speech dereferences NULL when a SpeechRecognizer is closed before its CompileConstraintsAsync work item runs, which crashed the Windows unpackaged device test app (0xC0000005). The new test releases a compiling recognizer by stop, dispose and newer start in one main-thread turn and asserts it is closed only afterwards; a second test guards the cancelled-start contract. A compilation can end before its start waits for it, so these tests and the two older mid-compile tests retry such a start on a new implementation, in up to 5 attempts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions it runs have ended

Closing a SpeechRecognizer while its CompileConstraintsAsync is pending crashed the app natively (an access violation in Windows.Media.Speech on a thread-pool thread), reachable through StopListenAsync, DisposeAsync, a newer start or a cancelled start. A per-recognizer lifetime now counts the compile, start and stop operations, which get no token, and closes a released recognizer when the last one ends; callers stop waiting with WaitAsync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #3189 the Shell.TitleView demo is no longer broken, and its button already says 'Go to Shell.TitleView'. The Shell, its two files and the button's click handler (now OnTitleViewShellButtonClicked) follow. Two leftovers of the original repro go too: the Shell's title is 'Shell.TitleView' instead of 'MauiApp1', and the Back button loses its unused name 'CounterBtn'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This comment was marked as outdated.

@TheCodeTraveler

Copy link
Copy Markdown
Collaborator Author

We're nearly ready to merge!

I'm running one final CoPilot Max review now. We'll iterate over its results, then merge this tonight.

Here's the latest Code Coverage results. CommunityToolkit.Maui is now over 90% 🎉

image

This comment was marked as outdated.

@bijington bijington left a comment

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.

Approved with a couple of comments, the one that I am unclear about is the linker status of the camera package. Great work

TheCodeTraveler and others added 3 commits November 8, 2026 09:59
… where the toolkit gives the style back

On iOS 26.x UINavigationController reports DarkContent (light appearance) or LightContent (dark appearance) instead of Default, while iOS 18 and 27 report Default. StatusBarStyle.Default gives every view controller its own style back, so seven tests that expected Default for a navigation controller failed on iOS 26.5 although the toolkit behaved as documented.

IosStatusBarStyle.UIKitStyle calls UIKit's own implementation directly (the toolkit's recorded replaced one on .NET 10), so a style the toolkit failed to clear still fails the assertion. AssertStatusBarStyleAsync and ASecondReplacementKeepsTheReplacedImplementations expect it where Default is requested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…turns back to portrait

On iOS 26.x the color view kept height 0 after landscape to portrait until the next StatusBar call: UIKit lays out the window's subviews before it updates the scene's status bar frame and does not lay them out again, and the view sizes itself only in LayoutSubviews. After a resize the view now asks for one more layout on the next main-queue turn, which reads the updated frame. On iOS 18 and 27 that pass finds the same geometry and does nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…simulator

The xcode-27 image has iOS 27.x simulators only, so iOS 26 was never tested in CI, and nine StatusBar tests failed on iOS 26.5 unnoticed. device_tests_ios_app builds the iOS app once on xcode-27 (no coverage) and uploads it as a tar, which keeps the executable bit. device_tests_ios_runtime tests it on macos-26, whose image has the iOS 26.5 runtime, so nothing is downloaded. The iOS 27.2 job keeps its coverage build; the 26.5 leg collects none. Both new jobs are in the Device Tests gate.

run.ps1 gets -Runtime, which it passes to ios.ps1, and rejects it with -Udid (exit code 3). README, LOCAL.md and the coverage note of the Build workflow follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

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.

🟢 Approval recommended

The supplied review evidence identifies no active issues requiring resolution.

No open issues 🎉

Review effort: Balanced

TheCodeTraveler and others added 2 commits November 8, 2026 12:35
… rate that the player settles at

NativePauseDoesNotChangeTheSpeed failed once on the new iOS 26.5 leg (the rate read 1.5 after the pause). On iOS 18 and 26, not 27, AVPlayer reports each rate again on the main queue once its player has applied it, so after a rate of 1.5 and a pause in one main-loop turn the rate reads 1.5 again for about a millisecond before it is 0 again. It reproduces with a bare AVPlayer and no toolkit code, and playback never resumes. The test now waits until the rate is 0, which still fails when something restarts the player, and keeps its Speed assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…SDK already applies

The SDK nests TestAssemblyPage.xaml.cs under TestAssemblyPage.xaml by convention, so the explicit Compile Update item changed nothing (from Shaun Lawrence's review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

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.

🟢 Approval recommended

There are no active review issues blocking approval.

No open issues 🎉

Review effort: Balanced

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

breaking change This label is used for PRs that include a breaking change

Projects

None yet

5 participants