-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestedThemeChanged fires at Home button press event and shows wrong RequestedTheme in iOS #15962
Comments
I can validate that this is happening, and the reason is... complicated. maui/src/Core/src/Platform/iOS/PageViewController.cs Lines 24 to 35 in 700944b
maui/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRootRenderer.cs Lines 144 to 150 in 700944b
TraitCollectionDidChange is an event that UIKit sends whenever it detects an iOS interface change. When you leave the application and go to another app or back to the home screen, iOS, for some reason, sends a MAUI handles this event to detect platform theme changes (which it should), so it is going with what iOS is sending, inverting and reverting the theme in the background. If you did not have the code you have in place for setting the It's hard to tell where the issue is: MAUI is responding to iOS events and iOS is sending bogus information. It could be an underlying iOS issue, a .NET iOS Binding issue (@rolfbjarne, @dalexsoto?), or somewhere else in MAUI that's causing a platform event to fire when it shouldn't (Although IMO that doesn't seem likely). @PureWeen I'm not sure who would be the right person for this. It feels like an SDK and/or bug in iOS, unless I'm missing some other event that is firing. Also, seeing that Apple Documentation saying |
@drasticactions thanks for the explanation. If you remove/comment Steps:
|
AFAIK, you should never have to set UserAppTheme yourself if you are changing the theme on an OS level. If you have to do that, file a new bug. |
Verified this on Visual Studio Enterprise 17.7.0 Preview 5.0 in iOS 16.4. This issue repro on .NET 8.0 with below Project: |
This is unlikely to be an issue with the bindings, it sounds like something iOS does just because (testing an Xcode project would confirm this). |
Hi. I have now noticed the bug in my app. Anyone have an idea for a workaround? |
I'm experience this problem also, so hopefully this will be fixed asap. |
Hi @arahmancsd. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version. You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Description
RequestedThemeChanged
event occurs when clicking on the Home button in iOS andAppThemeChangedEventArgs
show a wrongRequestedTheme
.WhatsApp.Video.2023-07-01.at.7.30.49.PM.mp4
Steps to Reproduce
Current_RequestedThemeChanged
event in the App.cse.RequestedTheme
which shows a different or wrong theme.Link to public reproduction project repository
https://github.com/arahmancsd/MauiTestApp1
Version with bug
7.0.49
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS
Did you find any workaround?
No
Relevant log output
No response
The text was updated successfully, but these errors were encountered: