Skip to content
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

Auto theme change doesn't behave as expected on .NET 7 whereas the same works fine on .NET 6 #11299

Closed
egvijayanand opened this issue Nov 11, 2022 · 20 comments
Assignees
Labels
i/regression This issue described a confirmed regression on a currently supported version p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 platform/iOS 🍎 s/needs-attention Issue has more information and needs another look s/no-repro Can no longer be reproduced on latest t/bug Something isn't working

Comments

@egvijayanand
Copy link
Contributor

egvijayanand commented Nov 11, 2022

Description

The styling in the default .NET MAUI app project template is loaded with AppThemeBinding constructs to detect theme change and behave accordingly like updating the back color, text color, and so on ...

This works fine on .NET 6 whereas, on .NET 7, it doesn't work as expected. The theme change is not honored.,

Note:
Have selected Unknown/Other as the Version with the bug since .NET 7 (7.0.49) is not appearing in that list.

Have selected Unknown/Other as the Last version that worked well since SR7 (6.0.547) is not appearing in that list.

Steps to Reproduce

  1. Create two app instances (one with a target framework as .NET 6 and the other with .NET 7) from the default app template
  2. Build the app and launch it on Android/Windows (I haven't tried it on other platforms)
  3. Update the OS theme so that the app responds to that change (Light -> Dark or vice versa)
  4. App responds to this scenario fine on .NET 6 whereas the same fails on .NET 7

Link to public reproduction project repository

The default template itself is sufficient.

Version with bug

Unknown/Other (please specify)

.NET 7 GA (7.0.49)

Last version that worked well

Unknown/Other

.NET 6 SR7 (6.0.547)

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Android 33.0, Windows SDK 10.0.19041

Did you find any workaround?

So far none, need to explore further.

Relevant log output

No response

@egvijayanand egvijayanand added the t/bug Something isn't working label Nov 11, 2022
@egvijayanand
Copy link
Contributor Author

On an additional note, even on .NET 6, the auto theme change works only once. Then it doesn't respond.

@jsuarezruiz jsuarezruiz added platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue labels Nov 15, 2022
@ghost
Copy link

ghost commented Nov 15, 2022

Hi @egvijayanand. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

@jsuarezruiz
Copy link
Contributor

Could be fixed by #11200

@egvijayanand
Copy link
Contributor Author

This issue is getting simulated with the default template itself, without requiring any changes.

dotnet new maui -f net7.0
dotnet new maui -f net6.0

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Nov 15, 2022
@rachelkang rachelkang added this to the Backlog milestone Nov 23, 2022
@ghost
Copy link

ghost commented Nov 23, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@egvijayanand
Copy link
Contributor Author

@davidortinau Moving critical issues like this to the backlog defeats the whole purpose of reporting issues and the stability of the product becomes questionable.

@jaredrsowers
Copy link

Yeah, I'm puzzled how this was overlooked in the release, I have been pounding my head against the wall for several days being sure it is something with my code, until I realized that even with a fresh template 6 works while 7 does not...

@davidortinau davidortinau added i/regression This issue described a confirmed regression on a currently supported version platform/iOS 🍎 and removed s/needs-attention Issue has more information and needs another look labels Dec 5, 2022
@davidortinau
Copy link
Contributor

Confirmed the AppThemeBinding is working also inconsistently on iOS. Sample project either the new 7.0 template or https://github.com/dotnet-presentations/dotnet-maui-workshop/tree/main/Finish.

I have to close and restart the app to get some colors to update, and at runtime some views update while others on the same screen do not.

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2022-12-05.at.15.09.27.mp4

@davidortinau davidortinau added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Dec 5, 2022
@mostafagamal68
Copy link

I have this issue too. I think it solved in #11200 but still not migrated yet.

@RobTF
Copy link

RobTF commented Dec 10, 2022

@davidortinau Moving critical issues like this to the backlog defeats the whole purpose of reporting issues and the stability of the product becomes questionable.

Totally, 100% agree. Our business has gone all in on Xamarin in the last 4-5 years with two heavily used apps in production today (40k active installs) and Microsoft has us scared out of our skin with stuff like this! We're trying to port some of our internal libraries to MAUI as a test to see the viability of migrating from Xamarin due to the sorry state of Xamarin's support and on day 1 I've noticed that themed bindings nor the app theme callback is not being fired at all on the default template?! This is basic, basic stuff which should work out of the box in V1. Xamarin has been a mess for a while now, but the excuse in the last year or so has been lack of support due to MAUI, but obviously that excuse doesn't wash with MAUI itself.

We're just barely clinging on to Xamarin/MAUI due to the fact that we have so much existing code invested in the ecosystem and our developers love C#, but it seems that with each month that goes by the scales tip a little further towards us biting the bullet, dumping the lot and taking the proverbial "life boat" to another framework with more stable functionality and support.

This is coming from a business where we are 100% a Microsoft shop (except for React/Redux on web).

I'm probably just shouting into the wind, but please don't treat this as badly as Xamarin!!

@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Dec 17, 2022
@samhouts samhouts modified the milestones: Backlog, .NET 8 Planning Jan 26, 2023
@borrmann
Copy link
Contributor

The marked answer from this thread can still be used in MAUI:
How to Check For Dark Mode in Xamarin.Forms

@scriptBoris
Copy link

Any updates?

@Cybrosys
Copy link

Cybrosys commented Feb 27, 2023

I tried adding some code to manually switch the UserAppTheme. What I noticed was that the control colors were not correctly updating. The only way for all the colors to update correctly was to kill the app and launch it again.

@tj-devel709
Copy link
Member

Looks these were both fixed by #11200 as @mostafagamal68 mentioned!
From running the sample project inside main of Maui, I get the below recordings.

@jsuarezruiz can you approve?

ThemeChangeAndroid.mov
ThemeChangeiOS.mov

@jsuarezruiz
Copy link
Contributor

Yes, must be fixed by #11200
ios-appareance

Closing for now this issue, but let us know if find any detail and can reopen it etc.

@UkeHa
Copy link

UkeHa commented Apr 13, 2023

@jsuarezruiz / @samhouts - this problem still persists on latest windows 11, .net with latest stable visual studio and latest maui workloads under android 33.
The event is still only being fired once and a whole bunch of controls do not react to the changes at all.

grafik

grafik

devenv_iIJQMfhN0H.mp4

EDIT: This also affects latest iOS builds - the event is not executed correctly and some elements still do not react correctly to theme changes. The on resume behaviour might also be broken, but hasn't been tested by me yet

@UkeHa
Copy link

UkeHa commented Apr 25, 2023

@jsuarezruiz / @samhouts will this issue be resolved in one of the coming releases and if so, will it be backported to .net7?

@mattleibow
Copy link
Member

mattleibow commented May 2, 2023

I am unable to reproduce this using the default maui template with .NET MAUI 7.0.81

VS Info: https://gist.github.com/mattleibow/c59cd29ca1e7a164e65f463fb91a8b8e

Themes-Android.mp4
Themes-iOS.mp4
Themes-Windows.mp4

I think if this is still happening, there is something else that is going wrong. Can you attach a sample that you have (even if it is just the default project) and then a binlog that was used to build it: https://github.com/xamarin/xamarin-macios/wiki/Diagnosis

Other info that will help is the android device/simulator, API version and anything else that you can see.

I think I used the same emulator as you as my VS just updated to the latest stable and this was the default emulator that came with the wizard.

@mattleibow mattleibow added the s/needs-info Issue needs more info from the author label May 2, 2023
@ghost
Copy link

ghost commented May 2, 2023

Hi @egvijayanand @UkeHa. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

@UkeHa
Copy link

UkeHa commented May 5, 2023

@mattleibow as of the latest VS (17.5.5) i am no longer able to reproduce it. Both in the sample project as well as in our production software. Therefore this issue can be closed.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels May 5, 2023
@samhouts samhouts added the s/no-repro Can no longer be reproduced on latest label May 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i/regression This issue described a confirmed regression on a currently supported version p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 platform/iOS 🍎 s/needs-attention Issue has more information and needs another look s/no-repro Can no longer be reproduced on latest t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests