BASIC

Author Topic: SHOEBOX does not work on ANDROID  (Read 1170 times)

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
SHOEBOX does not work on ANDROID
« on: 2018-Feb-14 »
Hi,

My simple code works on Win32:
Code: GLBasic [Select]
SETCURRENTDIR("Media") // go to media files

SETSHOEBOX "1.sbx",""

LOADANIM "kockak.png",1,45,45

DRAWANIM 1,1,50,50

SHOWSCREEN
MOUSEWAIT


But LOADANIM command crashes on Android:

Quote
I/glbasic ( 9200): Extracting asset file:
F/libc    ( 9200): Fatal signal 11 (SIGSEGV) at 0x7fffffff (code=1), thread 9222 (SDLThread)
I/DEBUG   ( 1522): pid: 9200, tid: 9222, pkg name: com.company.title
I/DEBUG   ( 1522): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   ( 1522): Build fingerprint: 'motorola/ghost_retasia/ghost:4.4.2/KOT49H/G900FXXU1ANCE:user/release-keys'
I/DEBUG   ( 1522): Revision: '0'
I/DEBUG   ( 1522): pid: 9200, tid: 9222, name: SDLThread  >>> com.company.title <<<
I/DEBUG   ( 1522): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 7fffffff
W/NativeCrashListener( 1698): Couldn't find ProcessRecord for pid 1885955130
I/DEBUG   ( 1522):     eax 7fffffff  ebx 18083260  ecx 00000001  edx 8956bd4f
I/DEBUG   ( 1522): AM write failure (32 / Broken pipe)
I/DEBUG   ( 1522):     esi 1a215030  edi 00000000
I/DEBUG   ( 1522):     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000043  xss 0000007b
I/DEBUG   ( 1522):     eip 8a47ab72  ebp 1a215000  esp 8966c744  flags 00210287
I/DEBUG   ( 1522):
I/DEBUG   ( 1522): backtrace:
I/DEBUG   ( 1522):     #00  pc 00076b72  /system/lib/lib3btrans.so (memcpy+3730)
I/DEBUG   ( 1522):
I/DEBUG   ( 1522): stack:
I/DEBUG   ( 1522):          8966c704  8a791a58
I/DEBUG   ( 1522):          8966c708  0000001c
I/DEBUG   ( 1522):          8966c70c  8966c71c  [stack:9222]
I/DEBUG   ( 1522):          8966c710  8a4b2fdd  /system/lib/lib3btrans.so
I/DEBUG   ( 1522):          8966c714  00000000
I/DEBUG   ( 1522):          8966c718  b76aa370  /system/lib/libc.so (free+32)
I/DEBUG   ( 1522):          8966c71c  8966c74c  [stack:9222]
I/DEBUG   ( 1522):          8966c720  8a58860c  /system/lib/lib3btrans.so
I/DEBUG   ( 1522):          8966c724  1453f924  /system/lib/arm/libc.so (strtol+544)
I/DEBUG   ( 1522):          8966c728  00000000
I/DEBUG   ( 1522):          8966c72c  1a215030  [stack:9212]
I/DEBUG   ( 1522):          8966c730  b76aa356  /system/lib/libc.so (free+6)
I/DEBUG   ( 1522):          8966c734  00000000
I/DEBUG   ( 1522):          8966c738  180163c6
I/DEBUG   ( 1522):          8966c73c  8a592706  /system/lib/lib3btrans.so
I/DEBUG   ( 1522):          8966c740  8a585227  /system/lib/lib3btrans.so
I/DEBUG   ( 1522):     #00  8966c744  1a215030  [stack:9212]
I/DEBUG   ( 1522):          8966c748  00000000
I/DEBUG   ( 1522):          8966c74c  18083260
I/DEBUG   ( 1522):          8966c750  18083291
I/DEBUG   ( 1522):          8966c754  8956bd4f
I/DEBUG   ( 1522):          8966c758  7fffffff
I/DEBUG   ( 1522):          8966c75c  00000001
I/DEBUG   ( 1522):          8966c760  8966c770  [stack:9222]
I/DEBUG   ( 1522):          8966c764  00000000
I/DEBUG   ( 1522):          8966c768  00000000
I/DEBUG   ( 1522):          8966c76c  00000000
I/DEBUG   ( 1522):          8966c770  8966c798  [stack:9222]
I/DEBUG   ( 1522):          8966c774  8966c760  [stack:9222]
I/DEBUG   ( 1522):          8966c778  8a5926dd  /system/lib/lib3btrans.so
I/DEBUG   ( 1522):          8966c77c  8966c988  [stack:9222]
I/DEBUG   ( 1522):          8966c780  00000000
I/DEBUG   ( 1522):
I/DEBUG   ( 1522): memory map around fault addr 7fffffff:
I/DEBUG   ( 1522):     1c260000-1c263000 rwx
I/DEBUG   ( 1522):     (no map for address)
I/DEBUG   ( 1522):     88a67000-88a89000 rwx
D

I attached the shoebox file, please rename it to .sbx!

I've already tried it with other images, png's, bmp's, jpg's, etc... Tried on real phones and on Bluestacks as well.
It is very important to me, because I'm now porting my iOS game to Android, and it uses a lot of shoeboxed data. It worked on iOS.

Thank you,
Adaz

GLBasic 15.089, latest AE, api-22
« Last Edit: 2018-Feb-14 by adaz »

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #1 on: 2018-Feb-19 »
This is due file copy issue on Android. ALL files from the APK files require to been copy to the internal memory, before its can been used.

What you can try to do is do a DOESFILEEXISTS() before any file checking. That command make sure the file got extracted from the APK file to internal memory before uses.

Also a file copy from Android APK to internal is required for ALL files when used on Android. This is just a bit crappy design, but nothing im can do. So Shoebox can been fiffly on Android. Sorry about it.

So this is a issue im will not fix.
« Last Edit: 2018-Feb-19 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 adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
Re: SHOEBOX does not work on ANDROID
« Reply #2 on: 2018-Feb-19 »
Thanks spacefractal. The file exists, I already used DOESFILEEXISTS(), but LOADSPRITE still cannot access the sbx, or even doesn't try to access it, I don't know. All my levelpacks and graphics are based on this, so I'm very despondent if it really won't work on Android :-(

By the way, here is the _logview.bat's result when LOADSPRITE failed to load from the sbx:

Quote
02-19 15:31:48.309  5757  5757 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-19 15:31:48.310  5757  5757 F DEBUG   : Build fingerprint: 'HUAWEI/VTR-L29/HWVTR:7.0/HUAWEIVTR-L29/C432B151:user/release-keys'
02-19 15:31:48.310  5757  5757 F DEBUG   : Revision: '0'
02-19 15:31:48.310  5757  5757 F DEBUG   : ABI: 'arm'
02-19 15:31:48.310  5757  5757 F DEBUG   : pid: 5688, tid: 5728, name: SDLThread  >>> com.adaz.antirock <<<
02-19 15:31:48.310  5757  5757 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7fffffff
02-19 15:31:48.310  5757  5757 F DEBUG   :     r0 ce17ea1f  r1 7fffffff  r2 80000000  r3 00000000
02-19 15:31:48.310  5757  5757 F DEBUG   :     r4 ce17ea54  r5 008000ff  r6 00000001  r7 00000000
02-19 15:31:48.310  5757  5757 F DEBUG   :     r8 00040a74  r9 00000000  sl 7fffffff  fp ce17ecfc
02-19 15:31:48.310  5757  5757 F DEBUG   :     ip 20000000  sp ce17e1b0  lr e51042e0  pc ee9c15cc  cpsr 80030010
02-19 15:31:48.311  5757  5757 F DEBUG   :
02-19 15:31:48.311  5757  5757 F DEBUG   : backtrace:
02-19 15:31:48.311  5757  5757 F DEBUG   :     #00 pc 000175cc  /system/lib/libc.so (memcpy+196)
02-19 15:31:48.311  5757  5757 F DEBUG   :     #01 pc 0009f2dc  /data/app/com.adaz.antirock-1/lib/arm/libmain.so (_ZN12OPENGL_IMAGE12LoadImageBMPEPKcm+340)
« Last Edit: 2018-Feb-19 by adaz »

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #3 on: 2018-Feb-19 »
filesystem on Android is crap...... on IOS, you have direct file access to the files, that is not on on the case with the Android.

Im recommend you to use folder based files instead to access your file and perform a function to that.

Currectly its a issue that wont been fixed in near feature, and its a hell on Android really.

This is why im newer used them. its really dont give any mean at all on Android, since you dont have direct access and require some "hacking" to that.

The media files is also copied to the main document folde ron Android before access. Howover the file might get deleted before its try access. im can take a look here, because the deleting should not do that on shoebox files really, but stay it. here the deleting of tiles happens in the Java file too. "EDIT". Just checked, its should not do that really. So its can been a bug, but its much more compliced here. Android is here very strange.
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: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #4 on: 2018-Feb-19 »
btw you can try to do those two things:

Code: GLBasic [Select]
        ?IFDEF ANDROID
                IF DOESDIREXIST("Media")=0 THEN CREATEDIR("Media")
                IF DOESDIREXIST("Media/levels")=0 THEN CREATEDIR("Media/levels")
                IF DOESDIREXIST("Media/levels/paid")=0 THEN CREATEDIR("Media/levels/paid")
                IF DOESDIREXIST("Media/levels/maze")=0 THEN CREATEDIR("Media/levels/maze")
                IF DOESDIREXIST("Media/music")=0 THEN CREATEDIR("Media/music")
                IF DOESDIREXIST("Media/music/ogg")=0 THEN CREATEDIR("Media/music/ogg")
                IF DOESDIREXIST("Media/music/mp3")=0 THEN CREATEDIR("Media/music/mp3")
        ?ENDIF
 

Please note, showbox is VERY ineffective on Android and is not recommend to use them at all. This due shoebox will use DOUBLE amount of memory, so its might fail on Android. Mostly on devices with low internal memory, which is COMON on older devices. So im will recommend to NOT support Android 4 at all really. Many of those devices have crappy memory management.

The main reason above thigng file access is NOT supported inside APK and is require to extract that to the internal memory first.

DOESFILEEXISTS will copy the file from a APK to the internal, while DOESDIREXISTS will copy the whole folder from that one.

So bear in mind, you can end the game uses TWICE of memory required.

This is why im newer used them at all. Its not effective on Android, nor newer will.


« Last Edit: 2018-Feb-20 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: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #5 on: 2018-Feb-20 »
so yes, its mightbeen a bug. but im will not fix it. sorry. Its a bigger issue here. Its just one of the strangers on Android.

But again, you should property use folders for each shoebox and do file access directly from those, if you used same filename for tiles etc.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
Re: SHOEBOX does not work on ANDROID
« Reply #6 on: 2018-Feb-22 »
Hi spacefractal,
I don't understand one thing: it's OK to check if the folders are exist or not, but if not, why should I create them? My level files won't be accessible from a just created folder... And if the folder exists (with the files in it), I don't have to create it.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #7 on: 2018-Feb-22 »
that due glbasic try to copy all files from that subfolder to internal memory from APK.

glbasic calls copyAsset() in sldActivity.java for each file you access. But if folder does not exists, its might crash instead. CREATEDIR() make sure its exits, before glbasic calling copyAsset(). Its can been required for some issues.

If you do a DOESDIREXISTS(), its also calls recursiveCopy() in java instead. Howover recursiveCopy can take too long time for the app, and can crash. Mostly if its many many MB.

This is why shoebox is simply not recommend to been used on Android at all! Im sorry.

you should dropping them, and instead uses subfolders for each level instead (using the same name you used from shoebox). That is much much more effective for memory wise, and you would have much more direct access to them.

Due this im will not fix shoebox issue on Android, since its ineffective anyway (sorry Gernot, but if you can fix it, then it ok).

« Last Edit: 2018-Feb-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 MrPlow

  • Prof. Inline
  • *****
  • Posts: 1315
    • View Profile
Re: SHOEBOX does not work on ANDROID
« Reply #8 on: 2018-Mar-12 »
I've never used SETSHOEBOX.

But just recently I see a few crashes referencing GFShoebox command?!

#00  pc 0000000000077580  /data/app-lib/..../libmain.so (GFShoeBox::FindOrExtract(char const*, char*, bool)+80)

Is this a new thing?!

In general the app is question is working very well for me.
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #9 on: 2018-Mar-13 »
ooh dear.... That means, this issue will newer been fixed!!!!

Its a bug in glb_prepare_reading_file(), which is called by all file commands, and property crash on line:
Code: GLBasic [Select]
if(!__g_ShoeBox_Data->FindOrExtract(filename, TempFileName.getbuffer(1024), true))
 

That mean its confimered SHOWBOX does not work and is 100% unstable on Android. Also.... Due that way file system is working on Android, which is piece of crap, that meant its impossible to use it anyway.

But instead we should trick SHOWBOX as its was a folder.

Property its crash on this function:


Im will not fix shoebox at all, but im will instead should remove it completly instead.

Instead im highly recommend to use SETCURRENTDIR() instead to access to a new level instead SHOEBOX it from a new folder. That can do the trick.

Gernot please contact me again, about Steam (Im home again and can offer help), and can you send me your newest source. we need to REMOVE all SHOEBOX support on Android.

With other word, if you ask me:

SHOEBOX will been DEPREACTED on Android.
« Last Edit: 2018-Mar-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: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #10 on: 2018-Mar-13 »
Code: GLBasic [Select]
BOOL glb_prepare_reading_file(DGStr& filename)
{       if(filename.len()==0)
                return FALSE;

        STDOUT(CGStr("glb_prepare_reading_file: ")+filename);
        #ifdef ANDROID
                TempFileName.releasebuffer();
                DGStr checkfilename=filename;
                                // SPACE FRACTAl - THIS IS REQUIRED. FULL PATH MUST NOT BEEN USED FOR EXTRAXCT
                                checkfilename=REPLACE_Str(GETCURRENTDIR_Str()+filename, DGStr(android_files_dir()), CGStr(""));
                                checkfilename=REPLACE_Str(checkfilename, CGStr("//"), CGStr("/"));
                                checkfilename=REPLACE_Str(checkfilename, CGStr("/Media/"), CGStr("Media/"));
                                STDOUT(checkfilename);
                if(!DOESFILEEXIST(checkfilename)) // This will unpack the file from the APK, if fails to extract from above.
                                {       return FALSE;
                }
                                //STDOUT(CGStr("3: "));
                return TRUE;
#endif
#ifdef WANT_SHOEBOX
        DGStr TempFileName;
        if(!__g_ShoeBox_Data->FindOrExtract(filename, TempFileName.getbuffer(1024), true))
        {
                                TempFileName.releasebuffer();
                                //STDOUT(CGStr("2: "));
                return FALSE;
        }

        TempFileName.releasebuffer();
        filename = TempFileName;
#endif

        return TRUE;
}
 

will remove shoebox feature on Android completly and should no longer crash like crasy.

Also im recommend to redirect SETSHOEBOX() to SETCURRENTDIR() when its used, which im guess its a much better alternative.
« Last Edit: 2018-Mar-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 MrPlow

  • Prof. Inline
  • *****
  • Posts: 1315
    • View Profile
Re: SHOEBOX does not work on ANDROID
« Reply #11 on: 2018-Mar-14 »
No probs. I only metioned it as I wasn't even using SETSHOEBOX and I got a Shoebox error?
Is there a reason for that?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3473
    • View Profile
    • Space Fractal
Re: SHOEBOX does not work on ANDROID
« Reply #12 on: 2018-Mar-14 »
Yes. It's a relevant issue as well.

It's call and checking if shoebox file is open or not in the code I'm posted.  It's does with all commands that use files. For some reason it's can also crash too it's seen.

Generally shoebox is very bad on Android, due indirect file access. You ends with more double amount of memory anyway and different issues. On other systems they work, due you have direct file access. Not on Android.

So yes, it's a relevant issue and confirmed. But I'm won't fix it. I'm more interested to remove shoebox completely on Android for improve stability.
« Last Edit: 2018-Mar-14 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.