minetest / irrlicht

Minetest's fork of Irrlicht
Other
115 stars 87 forks source link

Android: Make ALooper_pollAll call always non-blocking #255

Closed srifqi closed 11 months ago

srifqi commented 1 year ago

This PR tries to fix minetest/minetest#10842. See there for further discussion.

Implementation details

Original:

((Focused && !Paused) || !Initialized) ? 0 : -1

Since we want Minetest to still run when the text box shows up (Focused is false) and when Minetest is minimised (Paused is true), we remove both variables from the formula.

!Initialized ? 0 : -1

Because of this:

https://github.com/minetest/irrlicht/blob/85081d6fe0c422cf47f74714ee25562715528aa2/source/Irrlicht/Android/CIrrDeviceAndroid.cpp#L100-L101

we need to remove Initialized from the formula to prevent it from making Minetest freeze/stuck waiting a (blocking) ALooper_pollAll call.

0

EDIT: The Visual Studio builds failed due to vcpkg errors.

srifqi commented 12 months ago

What about line 67 in the same file?

I am not sure about that line. I have not tested it. Since that is run in initialisation step, it is probably fine to not change it.


To avoid an unnecessarily big increase in battery usage from this PR, maybe we could add code to Minetest to stop rendering while the app is paused? Something like this:

That looks good. The frame/window would not be shown anyway, but we still need the engine to run for other background tasks. It is probably better to also use conditional inclusion (#ifdef directive) since it is only used for Android devices.

sfan5 commented 12 months ago

To avoid an unnecessarily big increase in battery usage from this PR, maybe we could add code to Minetest to stop rendering while the app is paused?

take a look at isWindowActive, it already enables exactly this

sfan5 commented 11 months ago

I think that change in MT is a bit risky to pull in last minute.