[Android] Problem using OgreJNI and Android-Fragments

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
spookysister
Gnoblar
Posts: 3
Joined: Fri Dec 20, 2013 2:49 pm

[Android] Problem using OgreJNI and Android-Fragments

Post by spookysister » Tue Jan 07, 2014 10:54 am

Hi,

I'm currently trying to integrate Ogre (using the OgreJNI-Version) into my App by using fragments. For first tests I was using a normal Activity. Ogre works fine, no exception or problems. But after I used nearly the same code in a Fragment I got strange behavior.

The Layout:
I have a two panel design with a menu on the left and the main-stage on the right

Problem:
Ogre with the scene and all is loading without problem, even rendering works fine. But in the moment I touched something OUTSIDE the ogre-fragment, for example the menu (not necessarily a menu-entry), a get the following error while trying to render one frame:

Code: Select all

E/OGRE(4839): OGRE EXCEPTION(3:RenderingAPIException): Fail to SwapBuffers in swapBuffers at .\..\..\..\..\RenderSystems\GLES2\src\EGL\OgreEGLWindow.cpp (line 161)
No Event like focus changed is thrown, not by the Ogre-Fragment or the main-Activity. Also the Surface in Android is (as far android knows it) valid.
This also happens when the back-button is pressed (moments before "onPause" is called).

Environment:
I'm using the 1-9 branch from around 2 weeks ago. A targeted, while building ogre and on the ndk-level in my project, the api 9. As Android-SDK I target API-level 14 (i can't get lower because I need some functionality from higher than api 10).

Devices:
The problem accures on all my devices.
Samsung Galaxy Note 2 10.1 (Android 4.2.2)
Asus Transformer Pad Infitity (TF700T) (Android 4.2.2)

I've tried many things to find the moment the ogre-exception is produced, but no success so far. So without any more ideas I came here with the hope that somebody might help me out.


Thanks.
0 x

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

Re: [Android] Problem using OgreJNI and Android-Fragments

Post by Wolfmanfx » Tue Jan 07, 2014 12:42 pm

Hi,

I know about the issuse it seems that everything which is higher 10 (2.3.3) fails recompiling the shaders on the device.
I can advise you to disable RTSS and try if you still get that exception.
0 x

spookysister
Gnoblar
Posts: 3
Joined: Fri Dec 20, 2013 2:49 pm

Re: [Android] Problem using OgreJNI and Android-Fragments

Post by spookysister » Tue Jan 07, 2014 2:19 pm

Wolfmanfx wrote:Hi,

I know about the issuse it seems that everything which is higher 10 (2.3.3) fails recompiling the shaders on the device.
I can advise you to disable RTSS and try if you still get that exception.
do you mean that I should disable RTSS while compiling Ogre? Or not use it in my code?

Is there a chance in the near future, that this problem will be fixed?


Thx.
0 x

spookysister
Gnoblar
Posts: 3
Joined: Fri Dec 20, 2013 2:49 pm

Re: [Android] Problem using OgreJNI and Android-Fragments

Post by spookysister » Tue Feb 04, 2014 2:14 pm

spookysister wrote:
Wolfmanfx wrote:Hi,

I know about the issuse it seems that everything which is higher 10 (2.3.3) fails recompiling the shaders on the device.
I can advise you to disable RTSS and try if you still get that exception.
do you mean that I should disable RTSS while compiling Ogre? Or not use it in my code?

Is there a chance in the near future, that this problem will be fixed?
Thx.
after some testing I was not able to avoid the issue with a higher android version than 10 (with <=10 everything works). Even with no RTSS either for the project and the ogre-build (and API >10) the exception on rending while loosing focus remains.

@Wolfmanfx: is their a chance for a fix to happen this year??? Considering that I use ogre for my projects at work it would by mostly appreciated if a fix for higher android-api-version is planned in the near future. while I'm using ogre on currently scientific projects, I'm considering using it for commercial applications too. Unfortunately, the support for android api >=14 is required.

thx.
0 x

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

Re: [Android] Problem using OgreJNI and Android-Fragments

Post by Wolfmanfx » Mon Mar 03, 2014 10:36 am

Hi,

Just fixed it https://bitbucket.org/sinbad/ogre/commi ... 1e91e96d3d

make sure to call windowMovedOrResized() before you call renderoneframe than everything should render again.

When using GPU rendering for Android UI the os creates a context in the main thread Now we have 2 choices create OGRE in its own thread or set our context current before doing
anything else. I put this code here because this function called before any rendering is done.
Because the events for screen rotation / resizing did not worked on all devices it is the best way to query the correct dimensions.
0 x

Post Reply