Author Topic: Android: Glbasic not updating surface when auto rotated (still in 11.171).  (Read 9511 times)

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
I removed the previos post because its did have too many edits and confuctions post, thus because I have invistated what its really happens. So sorry about it, but its still a bug, Sorry about it.

BUG:
- When surface is changed by Android due rotation or such when user slide keyboard or such thing, then glGasic does noet reflect that. A example can been seen in this video (when he slide controller in and out):
http://dl.dropbox.com/u/3236515/GreedyMouse/orintation_issue.wmv

If you using android:screenOrientation="sensor" in your manifest.xml, then its happens that too as well (which is much easier to invoke the bug).

What Happens?
- Glbasic does not do a SETSCREEN at all when surface have been changed, and then countinue to use the old resoulution like nothing have been happen. Neither GETSCREENSIZE or GETDESKTOPSIZE have been updated after that surface change, which is very important for Android and on ICS4.

With other word:
- Glbasic is not aware on a surface changes at all, which can been happens on Android. I also think its why its have its own problems on Kindle Fire due this?

To fix (which I cant do my self here):
- Glbasic should return the new resoulution to GETDESKTOPSIZE after a surfaceChanged() call, and then the surface size can then been set on SETSCREEN.
« Last Edit: 2012-Oct-10 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

MrTAToad

  • Guest
Sounds like a useful thing to incorporate...

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
How about this:
Do not let the OS rotate the display (make your app work always in portrait). Then, use GETJOYX/GETJOYZ to determine the orientation and use SETORIENTATION to draw rotated?

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
I have allways did that, but I remind I did have a 90 degree rotation issue on a Android tablet (which use Landscape mode), which is not good at all (but I not sure why still), which is why I changed it to "nosensor". But "nosensor" have its own issue as you saw in the video.
 
So "The Xperia Play" did not respect the "nosensor" in the manifest.xml and rotated the display and changed its surface from Portrait to Landscape internally, which is why you see that issue. This is simply because glBasic is not aware when a surface change (and also in Sony Guidelines, you should also checks for surface changes).

So the best and the most correct way on Android is let the "sensor" auto rotate it and change the resoulution on the new surface, in that way its would fell a much a Android app and the 100% correct way.

So the best way is GlBasic should respect surface changes, which is invoked by the java call (which do happens), but the surface do never change, and hence either GETDESKTOPSIZE or GETSCREENSIZE is still on launched resoulution.

I also pretty sure its that its happens example on Kindle Play with odd mouse pointer simply due the surface have been changed and GlBasic have not respected it (so the screen was in potrait mode and hence mouse pointer might been wrong too).

So its a really important bug and I have no issue to eventuely pay for it (read donate), but Greedy Mouse is still about 1.5 month before a release, so in the end, nothing hurry (and I plans to ads some of other glbasic games too, but its nothing to debate here in this thread).
 
« Last Edit: 2012-Apr-13 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
Later I looking what its happens in this bug in the fellow day. Its actuelly really important for ICS smartphones as well tables, due they often have a touchbar in the bottom or to right and here its should been device based rotation, not software.

What I think its nothing is happens when the c++ function onNativeResize() is called and its property a costume function, but I have not a clue where its is, so I could checks what it happens there. Its should resize to the new resoulution when it invoked, and update the GETSCREENSIZE values.

Howover by now I simply disable auto rotate on Android, since some devices have trouble with it and set it to "Landscape" mode only.... Later I simple do a manual rotation under option instead.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
today I have tried doing different thing about this issue. I have tried varous settings in the manifest file, so its dosent rotate as well doing that in java runtime. But its still auto rotating, which might even do that on some devices with "nosensor". So I would nice to prefer "Sensor", also let Android rotate the surface and the game accour to that. But its not possible by now, but its also works nice when locked into one rotation, like "Landscape" (but progressbar would not rotated correctly then).

For future progress I have output the logfile, so you can see what its happens (from my HP TouchPad):

Code: GLBasic [Select]
I/glbasic (12411): onCreate
I/glbasic (12411): /mnt/asec/com.headsoft.greedymouse-2/pkg.apk
I/glbasic (12411): done with updating
I/glbasic (12411): external files dir is /data/data/com.headsoft.greedymouse/files
I/glbasic (12411): external storage /mnt/sdcard/Download
I/glbasic (12411): Updating media files - Source Dir:
I/glbasic (12411): onResume()
I/glbasic (12411): assets found, copying...
I/glbasic (12411): assets still up to date, proceed to main...
I/SDL     (12411): surfaceChanged(): 4 768 976
I/SDL     (12411): ****************************************
I/SDL     (12411): orintation: 1
I/SDL     (12411): pixel format RGB_565
I/SDL     (12411): SDL_Android_Init()
I/glbasic (12411): timer
I/glbasic (12411): rbow
I/glbasic (12411): rbow init
I/glbasic (12411): SDL_init video
I/glbasic (12411): SDL_GetVideoInfo = 768x976 @ 16 bpp
I/glbasic (12411): Setting video mode: 768x976x16 fl=4800000
I/SDL     (12411): [STUB] GL_LoadLibrary
I/SDL     (12411): Starting up OpenGL ES 1.1
I/glbasic (12411): SDL_SetVideoMode seems to be 1
I/glbasic (12411): get accurate timer - 1st call
I/glbasic (12411): flip - 1st call
I/glbasic (12411): BGRA ext supported
I/glbasic (12411): Texture size limit: 4096
I/glbasic (12411): init fbo
I/glbasic (12411): 2D VP
I/glbasic (12411): OGRB init [OK]
I/glbasic (12411): Cptn
I/glbasic (12411): Network
I/glbasic (12411): Input
I/glbasic (12411): Window mode
I/glbasic (12411): Create DXin
I/glbasic (12411): sdl_grab
I/glbasic (12411): reptr
I/glbasic (12411): getexe
I/glbasic (12411): cd
I/glbasic (12411): set cdir to: /data/data/com.headsoft.greedymouse
I/glbasic (12411): exepath=curdir= /data/data/com.headsoft.greedymouse
I/glbasic (12411): set cdir to: files
I/glbasic (12411): Init Finalized
I/glbasic (12411): set cdir to: Media
I/glbasic (12411): set cdir to: languages
I/glbasic (12411): set cdir to: /data/data/com.headsoft.greedymouse/files/Media/
I/glbasic (12411): set cdir to: levels/light
I/glbasic (12411): set cdir to: /data/data/com.headsoft.greedymouse/files/Media/
I/SDL     (12411): surfaceChanged(): 4 1024 720
I/SDL     (12411): ****************************************
I/SDL     (12411): orintation: 2
I/SDL     (12411): pixel format RGB_565
I/glbasic (12411): onPause()
I/glbasic (12411): glbasicOnPause(1)
I/glbasic (12411): super.onPause
I/glbasic (12411): set cdir to: languages
I/glbasic (12411): set cdir to: /data/data/com.headsoft.greedymouse/files/Media/
I/glbasic (12411): Shut down GLB
I/glbasic (12411): glb is shut down
I/SDL     (12411): [STUB] GL_UnloadLibrary
 

As you can see, the first surfaceChanged() works quite nice and perform the correct init and all, but when surfaceChanged() invoked again, then its does nothing and I got a wrong display. I guess its somewhere in the Android Init() c++ code that dosent resize as its should, so its impossible to do that with activity java (unlike the assets one I did a workaround my self).
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Ah. It's crashing on the HP touchpad when you rotate it?
Can you please post the manifest.xml changes for me to test it? I have a TP and if I can get it working here, it will be easy to fix.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
no its did NOT crash, I just closed down few secs after rotation, so I could output the log file. With this xml file, Hp Touchpad would do the same thing as in video:

Code: GLBasic [Select]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.headsoft.greedymouse"
      android:installLocation="preferExternal"
      android:versionCode="40"
      android:versionName="0.040">
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.VIBRATE" />
        <uses-permission android:name="android.permission.BATTERY_STATS" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-feature android:name="com.acer.android.XLONG_SCREEN" android:required="false" /
        <supports-screens android:resizeable="false"
                                          android:smallScreens="true"
                                          android:normalScreens="true"
                                          android:largeScreens="true"
                                          android:anyDensity="true" />
    <application android:label="Greedy Mouse" android:icon="@drawable/icon" android:debuggable="false">
        <activity       android:name="org.libsdl.app.SDLActivity"
                                        android:label="Greedy Mouse"
                                        android:screenOrientation="unspecified"
                                        android:configChanges="keyboard|keyboardHidden|orientation" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
 

also its does the same if android:screenOrientation="unspecified" changed to android:screenOrientation="sensor".

Its a pity since with "nosensor" as some devices still want to call that and rotate the screen, so not all devices respect that. Look on the video, which does the same when he draw the keyboard out. I think its complete the very same issue (but hard to do when I dont have the phone, but got invoked similar like that on HP Touchpad instead).
« Last Edit: 2012-May-03 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Fixed in V11. I had to hint the new size to the core. Te showscreen will auto-correct the viewport, and the GETSCREENSIZE/GETDESKTOPSIZE will return the right values, taking care of the rotation.

Phew. That was a not so easy one.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
I should pay you for that one :-). i wait to you doing v11 donate button :-).

So awesome!
« Last Edit: 2012-May-22 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
I have tested this in new GLBasic v11 beta and I just can say, this bug is not fixed correctly.

I use this code to detect a SURFACE CHANGE:

Code: GLBasic [Select]
        IF device$="a" OR device$="ak"
                LOCAL xx, yy, x2, y2
                GETSCREENSIZE xx, yy
                GETDESKTOPSIZE x2, y2
                IF x2<>xx OR y2<>yy
                        SETSCREEN x2, y2, 1
                        ScreenWidth=x2
                        ScreenHeight=y2
                ENDIF
                PORTRAIT=1
                IF ScreenWidth>ScreenHeight  THEN PORTRAIT=0
                DEPRINT("test resolution...."+xx+" "+yy+" "+x2+" "+y2)
        ENDIF
 

my Manifest to test:
Code: GLBasic [Select]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.spacefractal.greedymouse"
      android:installLocation="preferExternal"
      android:versionCode="990"
      android:versionName="0.990">
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.VIBRATE" />
        <uses-permission android:name="android.permission.BATTERY_STATS" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <supports-screens android:resizeable="false"
                                          android:smallScreens="true"
                                          android:normalScreens="true"
                                          android:largeScreens="true"
                                          android:anyDensity="true" />
    <application android:label="@string/app_name" android:icon="@drawable/icon" android:debuggable="false">
        <activity       android:name="org.libsdl.app.SDLActivity"
                                        android:label="@string/app_name"
                                        android:screenOrientation="unspecified"
                                        android:configChanges="keyboard|keyboardHidden|orientation" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
 

But if I start in Landscape mode and change to Portrait, then the game is still display in Landscape mode with a top left corner offset. Howover SETSCREEN is invoked after a hint, so I guess its more really a ORIENTATION issues that dosent reflect the SURFACE change as its should?

Howover I does not touch SETORIENTATION at all (which cause SETSCREEN to been crazy if I does), nor its should not been required.

PS. The assest issue with no animation is a easy fix, so dont worry about it, if you ask me.
« Last Edit: 2012-Sep-15 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
a screenshots to see what it happens:


its a ORINTATION issue that is not set correctly after the change, even I have not used SETORIENTATION at all. I thinks surface change is correct, but just not ORIENTATION for some reason.

The red circles is there ther controls was (but seen is normal, due wrong orientation after SETSCREEN and still thinks its in Landscape mode).
« Last Edit: 2012-Sep-15 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
so, when you rotate - don't you get different GETSCREENSIZE informations now?
Or is the internal viewport broken after the rotation?
I really must dig out an Android device now...

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
GETSCREENSIZE works nicely and does as its should, but its does not rotate correctly and that is the main issue. I guess its a pure rotation issue, not a surface issue.

This was on a Android HP Touchpad, the same device you have.

Not looking since happens.
« Last Edit: 2012-Sep-26 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Ah. So if the width>height, use setorientation 2, maybe?
Do you expect me to put that in the engine?