godot icon indicating copy to clipboard operation
godot copied to clipboard

Target FPS option removed - how to handle low FPS for battery saving on mobile?

Open florix91 opened this issue 10 years ago • 27 comments

Operating system or device - Godot version:

Issue description (what happened, and what was expected):

Steps to reproduce:

Link to minimal example project (optional but very welcome):

florix91 avatar Oct 06 '16 15:10 florix91

yeah, we removed this because it was misleading, you can change the phyics FPS if you want, but the game FPS will be always fixed to your refresh rate.

On Thu, Oct 6, 2016 at 12:30 PM, florix91 [email protected] wrote:

Operating system or device - Godot version:

Issue description (what happened, and what was expected):

Steps to reproduce:

Link to minimal example project (optional but very welcome):

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z24oIhHfTvh6Q6pb1ekdwunvptaUvks5qxRP7gaJpZM4KQFUz .

reduz avatar Oct 06 '16 15:10 reduz

Sorry so how can i set to 15 fps my application for example?

2016-10-06 17:40 GMT+02:00 Juan Linietsky [email protected]:

yeah, we removed this because it was misleading, you can change the phyics FPS if you want, but the game FPS will be always fixed to your refresh rate.

On Thu, Oct 6, 2016 at 12:30 PM, florix91 [email protected] wrote:

Operating system or device - Godot version:

Issue description (what happened, and what was expected):

Steps to reproduce:

Link to minimal example project (optional but very welcome):

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727, or mute the thread <https://github.com/notifications/unsubscribe-auth/AF- Z24oIhHfTvh6Q6pb1ekdwunvptaUvks5qxRP7gaJpZM4KQFUz> .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252001624, or mute the thread https://github.com/notifications/unsubscribe-auth/ANZmYtUiDML5DwZZHAGVjK-rtg8HttJrks5qxRZlgaJpZM4KQFUz .

florix91 avatar Oct 06 '16 15:10 florix91

there is not much of a point in doing this, so this is unsupported

On Thu, Oct 6, 2016 at 12:46 PM, florix91 [email protected] wrote:

Sorry so how can i set to 15 fps my application for example?

2016-10-06 17:40 GMT+02:00 Juan Linietsky [email protected]:

yeah, we removed this because it was misleading, you can change the phyics FPS if you want, but the game FPS will be always fixed to your refresh rate.

On Thu, Oct 6, 2016 at 12:30 PM, florix91 [email protected] wrote:

Operating system or device - Godot version:

Issue description (what happened, and what was expected):

Steps to reproduce:

Link to minimal example project (optional but very welcome):

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727, or mute the thread <https://github.com/notifications/unsubscribe-auth/AF- Z24oIhHfTvh6Q6pb1ekdwunvptaUvks5qxRP7gaJpZM4KQFUz> .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomment-252001624 , or mute the thread <https://github.com/notifications/unsubscribe- auth/ANZmYtUiDML5DwZZHAGVjK-rtg8HttJrks5qxRZlgaJpZM4KQFUz> .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252003513, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z249EbsJKOmaej274k2Aky2G8Cw3Iks5qxRfKgaJpZM4KQFUz .

reduz avatar Oct 06 '16 15:10 reduz

you could set the physics fps to 15 and do all your logic in fixed_process.. but you are most likely doing something wrong

On Thu, Oct 6, 2016 at 12:47 PM, Juan Linietsky [email protected] wrote:

there is not much of a point in doing this, so this is unsupported

On Thu, Oct 6, 2016 at 12:46 PM, florix91 [email protected] wrote:

Sorry so how can i set to 15 fps my application for example?

2016-10-06 17:40 GMT+02:00 Juan Linietsky [email protected]:

yeah, we removed this because it was misleading, you can change the phyics FPS if you want, but the game FPS will be always fixed to your refresh rate.

On Thu, Oct 6, 2016 at 12:30 PM, florix91 [email protected] wrote:

Operating system or device - Godot version:

Issue description (what happened, and what was expected):

Steps to reproduce:

Link to minimal example project (optional but very welcome):

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727, or mute the thread <https://github.com/notifications/unsubscribe-auth/AF- Z24oIhHfTvh6Q6pb1ekdwunvptaUvks5qxRP7gaJpZM4KQFUz> .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252001624>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYtUiDML5DwZZHAGVjK-rtg8HttJrks5qxRZlgaJpZM4KQFUz> .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252003513, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z249EbsJKOmaej274k2Aky2G8Cw3Iks5qxRfKgaJpZM4KQFUz .

reduz avatar Oct 06 '16 15:10 reduz

@reduz I was using that trick - lowering from 60 to 30 fps - to lower battery consumption on android devices and as far as I was able to test, it worked, so not entirely 'not much of a point', at least for me.

freemanfromgodotengine avatar Oct 06 '16 19:10 freemanfromgodotengine

​@reduz yes i was using that trick too for lowering battery consumption on android devices, and using OS.set_low_processor_usage_mode(true) . And for me was working great....To not make just game but even little app that will not consume battery like a game.... however it was under the func _ready(): why cannot i use that?​

2016-10-06 21:26 GMT+02:00 Freeman [email protected]:

@reduz https://github.com/reduz I was using that trick - lowering from 60 to 30 fps - to lower battery consumption on android devices and as far as I was able to test, it worked, so not entirely 'not much of a point', at least for me.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252063683, or mute the thread https://github.com/notifications/unsubscribe-auth/ANZmYq1_Qqc_iwmus8RidSvHrENoFC90ks5qxUtlgaJpZM4KQFUz .

florix91 avatar Oct 06 '16 19:10 florix91

What should I do if I want to have vsync off but not have the game run at several hundred FPS? Many games offer an option to set the FPS cap and set the vsync separately.

CowThing avatar Oct 06 '16 19:10 CowThing

OS.set_low_processor_usage_mode(bool) is not working currently on Android, it should really be implemented as it' s a great way of saving battery if you are using Godot to make apps and not games.

@RandomShaper would you like to give this a try? basically it means skipping OpenGL redraw of next frame (and keep the current one) if VisualServer::get_singleton()->has_changed() returns false

reduz avatar Oct 06 '16 19:10 reduz

@reduz hope you make OS.set_low_processor_usage_mode(bool) working for Android and iOS as soon as possible. Thanks

On Oct 6, 2016 21:55, "Juan Linietsky" [email protected] wrote:

OS.set_low_processor_usage_mode(bool) is not working currently on Android, it should really be implemented as it' s a great way of saving battery if you are using Godot to make apps and not games.

@RandomShaper https://github.com/RandomShaper would you like to give this a try? basically it means skipping OpenGL redraw of next frame (and keep the current one) if VisualServer::get_singleton()->has_changed() returns false

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252070671, or mute the thread https://github.com/notifications/unsubscribe-auth/ANZmYvAZjQpArA08LZtZcOcaAgcTJUkbks5qxVIfgaJpZM4KQFUz .

florix91 avatar Oct 06 '16 21:10 florix91

I'm researching it.

RandomShaper avatar Oct 07 '16 19:10 RandomShaper

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

RandomShaper avatar Oct 08 '16 18:10 RandomShaper

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252439099, or mute the thread https://github.com/notifications/unsubscribe-auth/ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz .

florix91 avatar Oct 08 '16 18:10 florix91

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 [email protected] wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomment-252439099 , or mute the thread <https://github.com/notifications/unsubscribe-auth/ANZmYis6qp4sky- P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252440546, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz .

reduz avatar Oct 08 '16 19:10 reduz

All I found is this: https://developer.android.com/reference/android/opengl/GLSurfaceView.html#requestRender() which could obviously work, but then who calls the frame callbacks? Also you would have some delay between processing and drawing.

On Sat, Oct 8, 2016 at 4:14 PM, Juan Linietsky [email protected] wrote:

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 [email protected] wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252439099>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252440546, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz .

reduz avatar Oct 08 '16 19:10 reduz

Yeah, setRenderMode()/requestRender() seem to be the way to go. I'm looking into them…

El 08/10/2016 a las 21:22, Juan Linietsky escribió:

All I found is this: https://developer.android.com/reference/android/opengl/GLSurfaceView.html#requestRender() which could obviously work, but then who calls the frame callbacks? Also you would have some delay between processing and drawing.

On Sat, Oct 8, 2016 at 4:14 PM, Juan Linietsky [email protected] wrote:

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 [email protected] wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252439099>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/godotengine/godot/issues/6727#issuecomment-252440546, or mute the thread

https://github.com/notifications/unsubscribe-auth/AF-Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252443177, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQCtlwpM_tynrImh2XPiTfKErIEFXIkks5qx-10gaJpZM4KQFUz.

RandomShaper avatar Oct 08 '16 19:10 RandomShaper

the problem is the delay.. Godot can render in a thread in the worst case, but I'm wondering if this is not kinda too much

On Sat, Oct 8, 2016 at 4:25 PM, Pedro J. Estébanez <[email protected]

wrote:

Yeah, setRenderMode()/requestRender() seem to be the way to go. I'm looking into them…

El 08/10/2016 a las 21:22, Juan Linietsky escribió:

All I found is this: https://developer.android.com/reference/android/opengl/ GLSurfaceView.html#requestRender() which could obviously work, but then who calls the frame callbacks? Also you would have some delay between processing and drawing.

On Sat, Oct 8, 2016 at 4:14 PM, Juan Linietsky [email protected] wrote:

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 [email protected] wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252439099>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252440546 , or mute the thread

<https://github.com/notifications/unsubscribe-auth/AF- Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252443177,

or mute the thread <https://github.com/notifications/unsubscribe-auth/ALQCtlwpM_ tynrImh2XPiTfKErIEFXIkks5qx-10gaJpZM4KQFUz>.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252443332, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z28NFcCs2fre7e0UvhEIMDoCXE7NUks5qx-4VgaJpZM4KQFUz .

reduz avatar Oct 08 '16 19:10 reduz

Not sure if that's what you mean, but GLSurfaceView already employs a thread for the frame callbacks. Is blocking the main thread your concern here?

El 08/10/2016 a las 21:38, Juan Linietsky escribió:

the problem is the delay.. Godot can render in a thread in the worst case, but I'm wondering if this is not kinda too much

On Sat, Oct 8, 2016 at 4:25 PM, Pedro J. Estébanez <[email protected]

wrote:

Yeah, setRenderMode()/requestRender() seem to be the way to go. I'm looking into them…

El 08/10/2016 a las 21:22, Juan Linietsky escribió:

All I found is this: https://developer.android.com/reference/android/opengl/ GLSurfaceView.html#requestRender() which could obviously work, but then who calls the frame callbacks? Also you would have some delay between processing and drawing.

On Sat, Oct 8, 2016 at 4:14 PM, Juan Linietsky [email protected] wrote:

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 [email protected] wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252439099>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252440546 ,

or mute the thread

<https://github.com/notifications/unsubscribe-auth/AF- Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/godotengine/godot/issues/6727#issuecomment-252443177,

or mute the thread <https://github.com/notifications/unsubscribe-auth/ALQCtlwpM_ tynrImh2XPiTfKErIEFXIkks5qx-10gaJpZM4KQFUz>.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/godotengine/godot/issues/6727#issuecomment-252443332, or mute the thread

https://github.com/notifications/unsubscribe-auth/AF-Z28NFcCs2fre7e0UvhEIMDoCXE7NUks5qx-4VgaJpZM4KQFUz .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252444031, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQCtpaoxY7TEPcl_fqxHZP37mmV9Bvpks5qx_EngaJpZM4KQFUz.

RandomShaper avatar Oct 08 '16 19:10 RandomShaper

Godot supports rendering in a thread, so technically it could be possible (probably with a little work also from the engine side), to run Godot on the main thread and do rendering in another. This was, however, never done. If there is no other way to get the low cpu mode to work, I will make sure threaded rendering works on Android (which is quite some work).

The easy solution would be to simply be able to abort the current frame being drawn (do not swapbuffers or blit), is this not possible in any way? Who does perform the swap in GLSurfaceView?

On Sat, Oct 8, 2016 at 4:45 PM, Pedro J. Estébanez <[email protected]

wrote:

Not sure if that's what you mean, but GLSurfaceView already employs a thread for the frame callbacks. Is blocking the main thread your concern here?

El 08/10/2016 a las 21:38, Juan Linietsky escribió:

the problem is the delay.. Godot can render in a thread in the worst case, but I'm wondering if this is not kinda too much

On Sat, Oct 8, 2016 at 4:25 PM, Pedro J. Estébanez <[email protected]

wrote:

Yeah, setRenderMode()/requestRender() seem to be the way to go. I'm looking into them…

El 08/10/2016 a las 21:22, Juan Linietsky escribió:

All I found is this: https://developer.android.com/reference/android/opengl/ GLSurfaceView.html#requestRender() which could obviously work, but then who calls the frame callbacks? Also you would have some delay between processing and drawing.

On Sat, Oct 8, 2016 at 4:14 PM, Juan Linietsky [email protected] wrote:

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 <[email protected]

wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252439099>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252440546 ,

or mute the thread

<https://github.com/notifications/unsubscribe-auth/AF- Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252443177 ,

or mute the thread <https://github.com/notifications/unsubscribe-auth/ALQCtlwpM_ tynrImh2XPiTfKErIEFXIkks5qx-10gaJpZM4KQFUz>.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252443332 , or mute the thread

<https://github.com/notifications/unsubscribe-auth/AF- Z28NFcCs2fre7e0UvhEIMDoCXE7NUks5qx-4VgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252444031,

or mute the thread <https://github.com/notifications/unsubscribe-auth/ALQCtpaoxY7TEPcl_ fqxHZP37mmV9Bvpks5qx_EngaJpZM4KQFUz>.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252444402, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z2-WETR6RcRxIu9ayIhK6sFt9sPKjks5qx_LhgaJpZM4KQFUz .

reduz avatar Oct 08 '16 21:10 reduz

I think there are two possible workarounds:

  • Since a helper class in GLSurfaceView is the one that performs the swap, we could grab a copy of the original from the Android source code and modify it to conditionally swap according to our needs. Downside: a little bit of maintenance.
  • Another one I'm going to try right now and detail (and PR) if success.

El 08/10/2016 a las 23:12, Juan Linietsky escribió:

Godot supports rendering in a thread, so technically it could be possible (probably with a little work also from the engine side), to run Godot on the main thread and do rendering in another. This was, however, never done. If there is no other way to get the low cpu mode to work, I will make sure threaded rendering works on Android (which is quite some work).

The easy solution would be to simply be able to abort the current frame being drawn (do not swapbuffers or blit), is this not possible in any way? Who does perform the swap in GLSurfaceView?

On Sat, Oct 8, 2016 at 4:45 PM, Pedro J. Estébanez <[email protected]

wrote:

Not sure if that's what you mean, but GLSurfaceView already employs a thread for the frame callbacks. Is blocking the main thread your concern here?

El 08/10/2016 a las 21:38, Juan Linietsky escribió:

the problem is the delay.. Godot can render in a thread in the worst case, but I'm wondering if this is not kinda too much

On Sat, Oct 8, 2016 at 4:25 PM, Pedro J. Estébanez <[email protected]

wrote:

Yeah, setRenderMode()/requestRender() seem to be the way to go. I'm looking into them…

El 08/10/2016 a las 21:22, Juan Linietsky escribió:

All I found is this: https://developer.android.com/reference/android/opengl/ GLSurfaceView.html#requestRender() which could obviously work, but then who calls the frame callbacks? Also you would have some delay between processing and drawing.

On Sat, Oct 8, 2016 at 4:14 PM, Juan Linietsky [email protected] wrote:

Yes, you are already at the OpenGL frame when this callback happens, and Android controls the swapping of buffers. The only way this could be implemented in Android is to somehow avoid the buffer swapping of the current frame. Still, in GodotView.java, all you get is a callback to draw and Android seems to swap buffers internally.

On Sat, Oct 8, 2016 at 3:31 PM, florix91 <[email protected]

wrote:

On Android this line of code cause a flashing Like mode of the scene Where it is used ​ OS.set_low_processor_usage_mode(true) at least for me. And juan told us that is not working on Android at the moment but will be implemented..(i really hope soon to make apps and not only games). ​

On Oct 8, 2016 20:01, "Pedro J. Estébanez" [email protected] wrote:

I've found that the check for low CPU usage mode is perfomed at every iteration of the main loop (main/main.cpp). Because of that it should already work on every platform.

For instance, on the Android case the callback to re-render the GL surface calls through that code so it should already skip frames and add delays.

Any thoughts on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/6727#issuecomme nt-252439099>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ ANZmYis6qp4sky-P1Rw2rGEBCm8wt6q2ks5qx9qIgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252440546

,

or mute the thread

<https://github.com/notifications/unsubscribe-auth/AF- Z2wBtV7aq3oHTR3UdXaXGQP2Bxqqdks5qx-GHgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252443177 ,

or mute the thread <https://github.com/notifications/unsubscribe-auth/ALQCtlwpM_ tynrImh2XPiTfKErIEFXIkks5qx-10gaJpZM4KQFUz>.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

<https://github.com/godotengine/godot/issues/6727#issuecomment-252443332 ,

or mute the thread

<https://github.com/notifications/unsubscribe-auth/AF- Z28NFcCs2fre7e0UvhEIMDoCXE7NUks5qx-4VgaJpZM4KQFUz> .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/godotengine/godot/issues/6727#issuecomment-252444031,

or mute the thread <https://github.com/notifications/unsubscribe-auth/ALQCtpaoxY7TEPcl_ fqxHZP37mmV9Bvpks5qx_EngaJpZM4KQFUz>.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub

https://github.com/godotengine/godot/issues/6727#issuecomment-252444402, or mute the thread

https://github.com/notifications/unsubscribe-auth/AF-Z2-WETR6RcRxIu9ayIhK6sFt9sPKjks5qx_LhgaJpZM4KQFUz .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/6727#issuecomment-252448679, or mute the thread https://github.com/notifications/unsubscribe-auth/ALQCti9_B81molIasqHmEQbffqpThBqEks5qyAcpgaJpZM4KQFUz.

RandomShaper avatar Oct 08 '16 22:10 RandomShaper

My little experiment failed, so here are my options:

  1. Grab GLSurfaceView from the Android SDK corresponding to the minSdkVersion (currently, 14). It employs some private APIs and, although they probably could be stripped out, maintining a patched copy of it is ugly.
  2. Play with EGL_SWAP_BEHAVIOR set to EGL_BUFFER_PRESERVED. That would make almost irrelevant that GLSurfaceView swaps unconditionally because the buffer would be preserved. Downsides: 1) it should be set on EGL setup, thus potentially taking some VRAM without knowing beforehand if the low CPU usage mode was going to be used at all (and adding a useless copy every frame when low CPU mode is disabled), 2) it seems not to be widely supported.
  3. In case low CPU is enabled, render to a FBO and just blit it on subsequent render requests. This would be more or less the same as (2), but taking VRAM only if needed. Downside: blitting plus swapping is more energy demanding than just skipping the frame.
  4. Decouple process and rendering on Main::iteration() so we can call the process part unconditionally and the render part as needed. Not sure about how easy would this be and that would still require adding some more threading to the specific code of each platform.

(3) could be a transient solution until Godot main loop is rearchitected, couldn't it?

RandomShaper avatar Oct 09 '16 00:10 RandomShaper