These are all the crashes in common and the most relevant that my apps are having with Build 3699.
I have already tried everything and I have not been able to find a solution.
Maybe CoronaRuntime need a life cycle request queue to solve like Controller.stop cause ANR when Lua Codes (GLThread) doing heavy work and Android life cycle been triggered (CoronaActivity in main thread).
This suggestion seems to fit with feedback we had from Google about our ANRs. They said that it seemed as though heavy work on the GL thread (they suspected it could be garbage collection) was the root cause. Having looked at the source I found that the controller.stop() function does make requests to the GL thread - there’s a comment in stop() that says:
// If we don't do this then there won't be one last onDrawFrame call which means the runtime won't be stopped!
requestEventRender();
My theory is that this sequence of events happens:
The rendering has frozen for some reason
User tries to close the app.
App goes through shutdown process, which includes calling the stop function.
The stop function has a line which is attempting to render one more frame - but the GL thread is stuck so it cannot do this.
I don’t have any ideas on how to resolve this though.
I can try make a build which does just that, doesn’t do anything in the GL thread right away but schedules update to the GL thread. We will lose some events on Lua side, but we would anyway because app would be killed because of ANR. Will this post with the links
Controller.start() and others that using the synchronized/mutex things also needs to be shedule.
I’ll collect the reproduced demos and prototypes and send them to you or submit a PR.
Not sure how reliable this might be, but there is another idea to try to track crashes: use the Flurry analytics plugin with option ‘crashReportingEnabled = true’. If you saturate the application with different events such as app resume, show ads etc., you will probably be able to see some kind of pattern. I tried it myself, but haven’t delved too deeply into it yet and haven’t seen much of anything. Maybe someone more experienced can try this.
Unfortunately it doesn’t look like this change had any impact.
ANR rate is unchanged and I still see the ANR getting stuck in controller.stop() in my ANR traces.
That is of course assuming that it did actually build using the test version. After downloading that build I clicked the Setup Native button - there was nothing else that needed to be done for the command line builds to use that version, right?
A month or so ago I tried tweaking the source code and used the gradle function to send those changes to the sim, but afaik downloading a new version and clicking Setup Native would override that.