-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android : Fixing rendering for all FPS (> 60 or < 60) - Thread to trigger rendering manually #2125
base: dev
Are you sure you want to change the base?
Android : Fixing rendering for all FPS (> 60 or < 60) - Thread to trigger rendering manually #2125
Conversation
@rh101 I think it's working as before now. I'm pausing the thread when the activity |
Perhaps I am misunderstanding what you mean by this, but that is not how the implementation worked (after the changes in #1942). If the application activity loses focus, then the The reason for this is that calling You easily test this by finding this function call, The other to test will be to ensure
I'll be able to test it in 1-2 days time. |
core/platform/android/java/src/org/axmol/lib/AxmolGLSurfaceView.java
Outdated
Show resolved
Hide resolved
Yeah I think you misunderstood, but it's my fault too as it wasn't clear enough. Let me explain: My changes are based to always use
I'll try this
I'll ensure about this too but as far as I understood and coded, your logic is not changed by my PR, only the way to trigger the surface view update calls.
Nice :) |
It looks like that thread adds 100% CPU usage for one core, or I'm missing something? What is the actual problem you are having? |
It always runs unless paused yes, but it just calls a check so nothing heavy to me and not using 100% from what I saw, but yeah we should sleep it for the interval.
The actual rendering is not working well with 120FPS (and low FPS too), the native render is called twice and so the |
I don't think this is a good solution overall. Adding another thread to an already complicated problem of syncing will make it even more complicated. Maybe we should create an issue for this, do some research and have a discussion to find the best way to implement this. |
To me it’s not more complicated than before once you know how it works
Anyway I still need to test what @rh101 suggested before to ensure it’s working as before |
I'm talking about complexity of understanding behavior and what the consequences of the code are, not what the code does. |
@AlexandreK38 Using the changes in this PR is causing the application to freeze, and attempting to pause it in the debugger to see where it is stuck just shows it in a wait state. The only way to recover is to put the app into the background, then bring it back to the foreground, and suddenly it recovers and starts responding again. This does not happen with the existing Axmol code, so it seems like something in this PR is causing the issue. Perhaps it is something to do with this section:
Is there any way Aside from this, I have to agree with @smilediver. Please log an issue, and explain the problem you are having (the reason for this PR) in as much detail as possible. |
Alexandre is going to submit a fix for stuck issue (there was indeed a problem with the thread) |
Excellent!
I did notice that the performance is smoother, but given that this change will impact all applications targeting Android, it does need to be tested as thoroughly as possible. |
We identified that the first freeze you had could come from a deadlock, so please try again if it works on your device. On my Pixel 6 and Samsung S8 I don't see any freeze. I'll test on several (heavy) games we have.
No it's the interval at most
The current implementation use This is clearly a big impact and it definitely needs several devices to test, any help is welcome of course 🙏 Also I opened the issue #2129 (not sure I explained the best I could) as suggested and posted the simple fix I had at first in it. |
For everyone interested in this PR we discuss the potential other solutions in the issue #2129, dont hesitate to have a look and give your advice. |
Describe your changes
Hi!
I found a rendering issue again on a Pixel 6 with 120FPS rendering, and in fact I realized I made such changes on my old Cocos2dx, and forgot to add it in axmol when we switched few months ago.
So, this PR is a fix so the Android rendering is called following the interval we give as expected, and not 60.
The surface view is now using
RENDERMODE_WHEN_DIRTY
rendering mode and notRENDERMODE_CONTINUOUS
so theonDrawFrame()
is called only when we ask the surface view we need to update the UI (usingrequestRender()
). A thread is used to check the intervals so it works for any FPS (lower like 30FPS or greater like 120FPS).Why a thread? We could have computed the intervals in the renderer class itself like it is now, but unfortunately sleeping the thread that is rendering is not precise.