Search Issue Tracker
Won't Fix
Votes
1
Found in
2018.1.0f2
2018.4
2020.2
Issue ID
1044454
Regression
No
[Android] System.Diagnostics.StopWatch don't track time properly when application is on background
When the application is put on the background on Android Time.realtimeSinceStartup and System.Diagnostics.StopWatch either run slower or stops running completely. This is against the expected behavior for Stopwatch and the documented behavior for Time.realtimeSinceStartup:
"realtimeSinceStartup also keeps increasing while the player is paused (in the background)"
To reproduce:
1. Download attached project "AndroidBlit.zip" and open in Unity
2. Open "SampleScene" scene
3. Build and Run for Android.
4. Launch application on a device
5. Disconnect device from the computer
6. Lock the device and wait for few minutes
7. Unlock the phone notice
Expected results: Observe that RealtimeSinceStartup, StopWatch, DateTime, and SystemClock elapsed times are the same after coming back to the app from sleep
Actual results: Observe that RealtimeSinceStartup, StopWatch, DateTime, and SystemClock elapsed times are not the same after coming back to the app from sleep
Notes:
- This issue reproduces only on Android devices
- On iOS devices, this issue does not reproduce
- If a phone is connected to PC via USB it works fine because it affects the power management of the device causing the clock to run properly
Reproducible with: 2018.4.27f1, 2019.4.11f1, 2020.1.7f1, 2020.2.0b5
Devices:
- Google Pixel 2, OS: 8.1.0, CPU: arm64-v8a, GPU: Adreno (TM) 540 - Reproduced
- VLNQA00015, Samsung Galaxy Note8 (SM-N950W), Android 8.0.0, CPU: Snapdragon 835 MSM8998, GPU: Adreno (TM) 540
- iPhone 6s, iOS: 10.3.2, CPU: A9 - Not reproduced
RESOLUTION:
The Time.RealtimeSinceStartup case is a duplicate of case 1037712.
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
- Inspector elements are rendered twice when the script component is added via drag-and-drop while the HideFlags.HideInInspector property is set
- Error "Light baking failed with error code 5 (Convergence data not available while rendering lightmaps)" thrown in Console when generating lighting for specific GameObjects
- Copy and Paste options for an Animation Property value are disabled in the Right click contextual menu
- Asset is not found when searching the Label "NewLabel" in Search Window
- "Compute dispatch: missing texture ID..." and "Compute dispatch: missing UAV ID..." warnings are thrown after changing the platform in High Definition 3D template
Resolution Note (2020.1.X):
At this time the Stopwatch implementation for Android is as monotonic as is possible.