Page 1 of 1

Android, Landscape - restarts on sleep

Posted: Sat Aug 04, 2012 2:36 pm
by BigDave2001
Hi, not sure if this is an Ogre problem, or Android, so bear with me.

Note this problem also occurs with the sample browser.

I want my (Android) app to be Landscape only, so in the manifest.xml I set it to be Landscape:

Code: Select all

<activity android:name="android.app.NativeActivity"
                  android:label="OgreSampleBrowser"
                  android:configChanges="orientation|keyboardHidden"
                  android:screenOrientation="landscape"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
            <!-- Tell NativeActivity the name of or .so -->
            <meta-data android:name="android.app.lib_name" android:value="OgreSampleBrowser" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity> 
The problem I have, is when the device sleeps (just leave it alone for a minute or two), I get the following events:

APP_CMD_SAVE_STATE
(a small wait...)
APP_CMD_TERM_WINDOW

and term_window restarts the app!

If I disable the landscape / no status bar (both cause the problem I think) then I get the following states:

APP_CMD_SAVE_STATE
(a small wait...)
APP_CMD_LOST_FOCUS

which is fine and dandy.

So, I want the app to have no status bar and be landscape, but it causes the app to restart on sleep?

Any ideas how this problem could be solved?

Re: Android, Landscape - restarts on sleep

Posted: Sat Aug 04, 2012 3:10 pm
by BigDave2001
Ah, just tried an native activity sample (ie, non ogre code) and the App_CMD_TERM_WINDOW does not get called...

So might be Ogre related.

Re: Android, Landscape - restarts on sleep

Posted: Tue Aug 07, 2012 2:39 pm
by BigDave2001
From my research it would appear this is common issue to EGL on Android - losing the context.

The restart was caused a common bug in my code and the sample browser code which tried to delete resources that had already been deleted (_destroyInternalResources).

There is an issue with setting landscape mode however. When the device / app is restarted, the app loads all the resources in portrait mode, rotates the screen to landscape, and loads them again.

For now I've put a temporary fix in my ogre code which, if not landscape, doesn't re-load the resources (it waits until landscape mode), but this is clearly not the right way to do it.

Possibly one for the Ogre developers to ponder.

Re: Android, Landscape - restarts on sleep

Posted: Fri Aug 10, 2012 10:37 am
by Wolfmanfx
Hi,

I already recreate resources when you go out to the home screen or rotate the device i assume that i just miss the sleep event -> but i can test that next week when i get a Qualcomm android device

Re: Android, Landscape - restarts on sleep

Posted: Sun Aug 12, 2012 7:29 pm
by BigDave2001
Ok great. Just to add - stuff is re-created on waking from sleep, it just does it twice if the app is in Landscape mode.

Another issue I've had is that if I have a 'ManualObject' with a manually created mesh with vertices and texture coordinates the app crashes on re-creation. I've checked in the Ogre code and it's when the resources are recreated the crash occurs.

I've tried creating a mesh (ConvertToMesh, or whatever it is called), and deleting the ManualObject, but the crash still occurs.

Re: Android, Landscape - restarts on sleep

Posted: Wed Jun 12, 2013 5:00 pm
by nimlas
same here..what's the solution of this problem? why the application is crashing?