Search Issue Tracker
Third Party Issue
Third Party Issue in 2020.3.X
Votes
0
Found in
2020.3.42f1
Issue ID
UUM-40109
Regression
No
[Android] BeforeSplashScreen methods are re-triggered after modifying Android notification settings
1. What happened
Hello Unity team!
We have found a strange behavior that happens in Android 13 devices both targeting SDK 33 and lower, which does not happen in lower Android version devices and is related to the RuntimeInitializeOnLoadMethods-BeforeSplashScreen:
On an Android 13 device, if you have opened the game and granted notification permissions, put it in background, go to Android settings, disable the permission and re-enable it again; when the app is put in the foreground again, the RuntimeInitializeOnLoadMethods with RuntimeInitializeLoadType.BeforeSplashScreen are triggered again, even that the application was in background and already initialized.
This causes that we cannot rely on these methods to initialize our services as they will initialize more than once. We can implement a fix on our side for this, but we are wondering if this is the expected behavior as it does not happen on Android 12 devices.
Maybe it is related to the new Android notification permission management for Android 13 devices, but, I don't see behavior differences targeting SDK 33 (implementing this new permission) or lower versions (the permission is managed by the OS).
2. How can we reproduce it using the example you attached
1- Uncompress the attached “IN-40049” project
2- In Android Studio synchronize the Logcat with the Android 13 device that will be tested to check its registers, for easy reading, filter the registers by using 1540379
3- Build and Run the app on an Android 13 device
4- Check the logcat in Android Studio, you should see messages like:
1540379_BeforeSplashScreen - Core Register
1540379_Static ScopelySdkPackageSetupRepository ctor - _packagesSetup before:
etc, this is expected.
5- Put the app in background and check the Android App permissions: Go to the Android Settings > Apps Settings > your app settings > Notifications settings, and check that the notification permissions are enabled, if they are enabled, disable the permissions and re-enable them again, then select the app and check the logcat, you should see the messages in point 4 are triggered again.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Package signature validation unexpectedly return an invalid signature status if the validation check is done after the code signing certificate validaty range has passed
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
Resolution Note:
I made an Android app using Android Studio and printed the Android activity life cycle to check if this is caused by Android or not.
I was able to confirm that turning off notifications ends the process. After that, when I accessed the app from the recent apps list, I could see it printing onCreate again. I think RuntimeInitializeLoadType.BeforeSplashScreen was triggered again because Android killed the process when the Notification was turned off.
Resolution Note (2020.3.X):
I made an Android app using Android Studio and printed the Android activity life cycle to check if this is caused by Android or not.
I was able to confirm that turning off notifications ends the process. After that, when I accessed the app from the recent apps list, I could see it printing onCreate again. I think RuntimeInitializeLoadType.BeforeSplashScreen was triggered again because Android killed the process when the Notification was turned off.