godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.57k stars 20.41k forks source link

Android Emulator on Mac M1 break fps #68438

Open kyoz opened 1 year ago

kyoz commented 1 year ago

Godot version

3.5.1

System information

Mac mini M1 (Monterey 12.6), GLES2

Issue description

When trying to test Godot 3.5.1 for my new project, I do found some bug (This is not really Godot bug, maybe of Android Studio on Silicon Macs).

This is not happen on real devices (I'v test on a few real device and it not happen, just on Emulator)

I don't have any Window PC so doesn't know if it occurs on em too, it's great if someone can help to test.

The issues:

When running on Simulator with Android 10+ (SDK >=20), thing work normally:

https://user-images.githubusercontent.com/29815830/200754749-2955b235-e90e-41dc-bdc3-2694dc27493d.mov

But if we're running on Simulator with Android 9 and below, this happen:

https://user-images.githubusercontent.com/29815830/200754879-b8d79dc8-4cd8-4422-b731-41bf38ad1bb4.mov

Logcat:

2022-11-09 13:08:11.992 16326-16352/org.godotengine.androidemulatormacm1issue E/godot: WARNING: Final value of `time_accum` is larger than `p_frame_slice`. It should always be between 0 and `p_frame_slice`. This hints at an engine bug.
2022-11-09 13:08:11.992 16326-16352/org.godotengine.androidemulatormacm1issue E/godot:    at: advance_checked (main/main_timer_sync.cpp:467) - Final value of `time_accum` is larger than `p_frame_slice`. It should always be between 0 and `p_frame_slice`. This hints at an engine bug.

I do test a fews game on store which make with Godot and they still have this problem (remember that it only occurs on Emulator). You can create an Emulator with Google Play Service to download Godot games and test too.

Steps to reproduce

Run the reproduction project on:

Minimal reproduction project

AndroidEmulatorMacM1Issue.zip

lawnjelly commented 1 year ago

Just to note that aside from the Godot side (e.g. bug in jitter fix, try setting it to 0.0), there's a lot of hardware / emulator issues that can cause duff timing information.

Particularly if the MONOTONIC clock is running backwards, or if the mutexes aren't working correctly in our timing calls. For the unsigned math, if the MONOTONIC clock is running backwards, you get very high values for the delta and everything can break.

See #31863 and #31900 for more investigation into this and links. I'm not an expert in hardware timers, but from what I could gather I put the current issues down to hardware / OS bugs. Thankfully these seem to be rare, and as such we didn't merge any workarounds.

kyoz commented 1 year ago

Thanks @lawnjelly for the information, I've tested again with jitter fix setting, but it's still the same, I'm not sure but I think the problem come from Android Studio Emulators (On Mac M1). I'll borrow a window laptop and testing to see if it happen on Window or not.