Skip to content

in_foreground is missing from MAUI events on iOS and Mac Catalyst apps using the UIScene lifecycle #5726

Closed

Description

@jamescrosswell

Sentry.Maui sets SentryMauiEventProcessor.InForeground from MAUI's application-level iOS lifecycle events: OnActivated, OnResignActivation and DidEnterBackground. Apps that use the UIScene lifecycle get SceneOnActivated, SceneOnResignActivation and SceneDidEnterBackground instead (see MauiUISceneDelegate in dotnet/maui). So InForeground stays null, and because the event processor writes it over the enricher's value, in_foreground is missing from every iOS and Mac Catalyst event.

This affects 6.x users now. Apps built with Xcode 27 must adopt the UIScene lifecycle, and that includes .NET 10 apps using the .NET 10 Xcode 27.0 support packs.

Fix

Already on version7 in #5725, commit fix(maui): report in_foreground for apps using the UIScene lifecycle, which registers the Scene* events alongside the application-level ones. It cherry-picks cleanly onto main.

That commit also asserts "in_foreground":true in integration-test/ios.Tests.ps1. On main, though, the iOS integration test app is integration-test/net9-maui, which doesn't use scenes. The old application-level handlers still set InForeground there, so the assertion would pass even without the fix. To make it guard the fix, adopt the UIScene lifecycle in net9-maui as #5725 did for integration-test/maui-device:

  • a UIApplicationSceneManifest in Platforms/iOS/Info.plist;
  • an empty SceneDelegate : MauiUISceneDelegate;
  • the app's OnActivated test hook moved from AppDelegate to that SceneDelegate, because UIKit stops calling the application-level one under scenes.

This works under Xcode 26.6, so main's CI exercises it.

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

Metadata

Metadata

Labels

.NETPull requests that update .net codeBugSomething isn't workingFramework: MAUI

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions