Android, Landscape - restarts on sleep

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Android, Landscape - restarts on sleep

Post 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?

BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Re: Android, Landscape - restarts on sleep

Post 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.

BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Re: Android, Landscape - restarts on sleep

Post 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.

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Re: Android, Landscape - restarts on sleep

Post 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

BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Re: Android, Landscape - restarts on sleep

Post 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.

nimlas
Gnoblar
Posts: 1
Joined: Wed Jun 12, 2013 4:56 pm

Re: Android, Landscape - restarts on sleep

Post by nimlas »

same here..what's the solution of this problem? why the application is crashing?

Post Reply