[9.0.50 Android] Splash screen is randomly left blank
Description
I noticed in using Publish command on Android that splash screen files are randomly sometimes generated incorrectly, leading to a blank (normally blue in MAUI) splash screen. In particular, the file base/res/drawable/maui_splash_image.xml is then merely one line with the text layer-list. In contrast, the other splash screen file base/res/drawable/maui_splash.xml seems to be always correctly generated.
Steps to Reproduce
- Clone the reproduction repository at https://github.com/hyvanmielenpelit/GnollHackMAUIEasyBuild and build it according to instructions in Visual Studio 2022
- Choose Release configuration, and activate your Android device from the debugging device dropdown list
- Delete
binandobjdirectories if they exist - Right-click on GnollHackM project and select Publish
- Go to step 3 or step 4 randomly until 10 archives have been created
- In some of these archives the file
base/res/drawable/maui_splash_image.xmlis correct (gnollhackicon.png is then present in various drawable folders), in some of the other ones it is not (also, no gnollhackicon.png in any folder).
Link to public reproduction project repository
https://github.com/hyvanmielenpelit/GnollHackMAUIEasyBuild
Version with bug
9.0.50 SR5
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 15
Did you find any workaround?
No.
Relevant log output
It seems that if I delete bin and obj directories first before selecting Publish, the splash screen is more often created correctly. So perhaps a problem with using intermediate files or the like.
Based on the reproduction steps, I am unable to reproduce the splash screen issue. The splash screen is displaying correctly. Please refer to the video below.
https://github.com/user-attachments/assets/d1b3f443-7a16-4d4e-9f4c-9d454e8c9358
Can you check if that remains the case when you rebuild or build without deleting obj and bin directories? What you should notice is that the base/res/drawable/maui_splash_image.xml file becomes sometimes 18 bytes long inside the aab and all gnollhackicon.png files are missing from various drawable directories under res. This happens randomly on my side, so the occurrence may depend on the system setup or pure luck (if a threading or file access error).
The splash screen displays properly without deleting the bin and obj folders. If you encounter the splash screen issue on any specific emulator or device, please let us know.
There was certainly a (random) problem there. Let me investigate if I can found a more reliable way to replicate it. It may be due to my slow computer or something like that, so it may not necessarily appear on every development setup.
I just had the same problem (Google Pixel 6a / Android 15). In my case it was caused by the Microsoft Launcher. The splash screen showed up again after switching to the default Google Launcher.
This is a known issue in some launchers or running from F5. Android treats this as a special resume and thus does not load the images. This is nonsensical, but Google deemed that the best user experience.
Duplicate of https://github.com/dotnet/maui/issues/12636
Google reasoning: https://issuetracker.google.com/issues/205021357?pli=1#comment14
I think you can trigger this code path if you are resuming the app. Initial launch from the Google launcher is fine, but resumes may not load it. And I am not sure if the MS Launcher found a way, but it sometimes does trigger the icon.
I don't think this has anything to do with the other issue. This is a problem of malformed splash screen files inside the APK that happen randomly, perhaps because something got done in the wrong order or at the same time as the files were being copied, etc. I can check that if the files are ok, then the splash screen works, if they are malformed, then the splash screen does not work. This is our standard check before publishing on Android.
As a note, this random corruption of the splash screen file seems to almost never happen if I first delete bin and obj directories. So perhaps it has something to do how the build process handles existing files in those directories.
Duplicate of #23268