Baseflow/Chameleon

Duplicate OnCreate on startup when theme is selected

Inrego opened this issue ยท 1 comments

๐Ÿ› Bug Report

When a theme is selected, MainActivity.OnCreate is called twice upon startup. That results in 2x initialization, and end result is that the RootPage will show a back button, which when tapped, goes back to an empty tab page.

Expected behavior

Don't initialize app twice when a theme is selected.

Reproduction steps

  1. Select a different theme than "Auto"
  2. Close app (properly)
  3. Open app again.
    3.a. Back button should now be showing
  4. Tap back button
  5. Now you're stuck on an empty tab page, without being able to navigate further in the app. You have to close it and reopen.

Configuration

I only tested Android. Might be an issue on other platforms too.

Platform:

  • ๐Ÿ“ฑ iOS
  • ๐Ÿค– Android
  • ๐Ÿ WPF
  • ๐ŸŒŽ UWP
  • ๐ŸŽ MacOS
  • ๐Ÿ“บ tvOS
  • ๐Ÿ’ Xamarin.Forms

I do believe it's the Activity.Recreate() in ThemeService.
I tried commenting out the following lines, and the issue disappeared (it's not a fix, I know, but locates the problem).

if (Activity?.Theme != null && changed)
{
(Activity as MainActivity)?.Delegate.ApplyDayNight();
Activity.Recreate();
}