OpenSeizureDetector / Android_Pebble_SD

The main OpenSeizureDetector Android App, that is published on the Android Play Store.
http://openseizuredetector.org.uk
GNU General Public License v3.0
9 stars 14 forks source link

V4.3.x - Occasional server re-starts during transition from portrait to landscape mode #96

Open jones139 opened 1 year ago

jones139 commented 1 year ago

With the main page displayed, rotating the phone from portrait to landscape mode sometimes results in the main app screen disappearing and the background service re-starting. I don't know why this might be - there is no crash report generated - maybe a race condition relating to onPause and onResume? I have not had any success in reproducing it reliably so it might be difficult to find and fix.

jones139 commented 1 year ago

It is not obvious why this is occurring, and it does not affect performance seriously, so will leave it for V4.2.

jones139 commented 1 year ago

I am struggling to reproduce it - I am wondering if it was something with my phone that I was using for testing as I can not make it happen on an emulator.

AroonPro commented 1 year ago

This I think, has to do with how we set-up the lifecycle:

Android does perform an ActivityDestroy. When destroying onStop will be called. It gets restarted and the third function being called is: onStart. in onStart is given: if isServerRunning(): server stop.

mHandler.postDelayed(()->{server start},100);

jones139 commented 1 year ago

I think it will be something like that - I fixed a couple of issues with the server not stopping properly by delaying the re-start - I'll have a look in the mainActivity life cycle methods to see where to include this. Thanks! Graham

AroonPro commented 1 year ago

https://stackoverflow.com/questions/10126845/handle-screen-rotation-without-losing-data-android

jones139 commented 9 months ago

I have not seen this in V4.1.x or V4.2.x, so changing this to a V4.3.x issue