With the following :
GLOBAL pause%=FALSE
LOCAL v=0.0
WHILE TRUE
IF pause%=FALSE
PRINT v,0,0
SHOWSCREEN
INC v
ELSE
SLEEP 50
ENDIF
WEND
SUB GLB_ON_PAUSE:
pause%=TRUE
ENDSUB
SUB GLB_ON_RESUME:
pause%=FALSE
ENDSUB
As soon as a minimised program is restored the program will hang. I believe it's caused by main program accessing pause%, rather than something in the GLB_ON_RESUME subroutine.
Which system?
- On Android OnResume() in java is barly never invoked.
- On Windows 7 those functions is never been called at all (even with AutoPause True).
In Greedy Mouse, there is often about 3-4 hangtime when minimized before the system respons and then there is nothing problem. Howover the game does not crash, but have never invoked pause as its should (as OnResume() in Android not working is not a big bugger for my game, since its load fast and save on pause).
So I think its should been confirmed.
On a Windows 7 PC - with debug mode of, of course...
without debug mode then its hang as decribpted. I do guess its more a code error and not a real bug. SLEEP have never released back to Windows and then Windows thinks the code hanging and hence its cannot invoke GLB_ON_RESUME.
So you need add a another SHOWSCREEN before or after SLEEP to prevent hanging and release resource back to Windows.....
This would been happens with many other languages as well.
No, that has no effect on it - nor removing the sleep command - SHOWSCREEN needs to be outside the IF block for it to work. However, that does mean CPU use increases when being minimised...
Its a normal Windows behaiver. Same happens in Purebasic as well BlitzMax.
You need to call a windows event to sleep the app and callback to Windows, I guess its here SHOWSCREEN as only command doing it. Here its works fine when added SHOWSCREEN just before SLEEP 50, which is the correct way to do. SHOWSCREEN is also important, even when minimized for Windows. Its might do some CPU, but you can skip update and render graphics to save CPU, and then just call SHOWSCREEN directly, so its very minimal CPU usage anyway (remember in minized mode for Windows 7, you can still see thumpnails, so yet not really sleeping).
So for Windows I cant see its a bug, other than its could been more aware when paused when SHOWSCREEN is used.
Howover this is a real bug for Android. Looked this into today, but still not working yet (also I tried public void onWindowFocusChanged(boolean hasFocus), which invoke correctly on false, but never true). I do heard its should crash on eglSwapBuffers(), but I do not seen any log that invoke flipEGL(), so its must been a C++ call error. So not sure about it yet.
I'm sure Gernot can fix it :)
Use the DEBUG command to see where you are. The main loop might not be called on some systems. The "sleep" will happen inside the showscreen. Not all systems though.