Search Issue Tracker
By Design
By Design in 2021.3.X
Votes
0
Found in
2020.3.34f1
2021.3.2f1
Issue ID
UUM-580
Regression
No
[Android] OnApplicationPause() is triggered when an activity window is being opened or closed
Reproduction steps:
1. Open the user's attached "HelloWorld.zip" project
2. Open the "MainScene" Scene
3. Go to Assets > Google Mobile Ads > Settings > Google Mobile Ads ID
4. Add "ca-app-pub-3940256099942544~3347511713" as the App ID to the Android field
5. Build and Run for Android
6. Make sure there is an internet connection on the device
7. In the Build, press the "Request AppOpen Ad" button
8. Press the "Request Rewarded Ad" button and wait a few seconds
9. Press the "Show Rewarded Ad" button
10. After the advertisement ends close it
11. Observe the Build
Expected result: OnApplicationPause(false) doesn't get triggered, and the "AppOpen" ad is not shown
Actual result: OnApplicationPause(false) gets triggered and the "AppOpen" ad is shown
Reproducible with: 2020.3.34f1, 2021.3.2f1
Couldn't test with: 2019.4.38f1 (Build fails after downgrade), 2022.1.0f1, 2022.2.0a12 (Build fails after upgrade)
Reproducible with these devices:
VLNQA00468 - Huawei - (ELS-NX9), Android 10, CPU: HiSilicon Kirin 990 5G, GPU: Mali-G76
VLNQA00407 - Samsung Galaxy Z Flip3 5G (SM-F711B), Android 11, CPU: Snapdragon 888, GPU: Adreno (TM) 660
VLNQA00264 - Samsung Galaxy S10+ (SM-G975F), Android 10, CPU: NOT FOUND, GPU: Mali-G76
Not reproducible with: iOS (User's info)
Couldn't test with these devices:
VLNQA00110 - Samsung Galaxy Note2 (GT-N7100), Android 4.4.2, CPU: Exynos 4 Quad 4412, GPU: Mali-400 MP ("Install_Failed_Older_SDK" build error)
iOS (Xcode build failed with "Framework not found FBLPromises" error)
Notes:
- OnApplicationPause(false) gets triggered again after closing "AppOpen" ad
- OnApplicationPause() should be triggered only when the app switches between background and foreground, as mentioned in the documentation
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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
Resolution Note:
After some investigation, we have found that Android OS makes a call to onPause when an ad is played, as another activity (the ad) is in focus instead of the main application window. See Android doc: https://developer.android.com/reference/android/app/Activity.
This is how Android OS behaves and Unity reacts to this by invoking OnApplicationPause() to be true when the application window is covered by another activity. The doc https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html may need to be updated to reflect this, which we are looking into.
If user would like the pausing to not occur, the suggestion is to override onPause in the activity class in their project, which allows the user to decide when exactly to pass this callback to Unity.
Resolution Note (2021.3.X):
After some investigation, we have found that Android OS makes a call to onPause when an ad is played, as another activity (the ad) is in focus instead of the main application window. See Android doc: https://developer.android.com/reference/android/app/Activity.
This is how Android OS behaves and Unity reacts to this by invoking OnApplicationPause() to be true when the application window is covered by another activity. The doc https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationPause.html may need to be updated to reflect this, which we are looking into.
If user would like the pausing to not occur, the suggestion is to override onPause in the activity class in their project, which allows the user to decide when exactly to pass this callback to Unity.