iOS - apps crash if a 'smallfont.png' is in the .app folder.

Previous topic - Next topic

Moebius

I've been trying to figure out for some time why some of my apps crash and some don't, and it seems to be down to an innocent, 'smallfont.png'.
I noticed on windows that if a 'smallfont.png' file is present in the .app folder, the program seems to load this at startup and set it as the default font.  Hence, it is very useful for testing purposes as I can easily replace GLBasic's default font with something more readable.
Trying this on iOS, it fails.  I'll post the output from GDB soon but from memory sometimes it is a lot of gibberish about messages, other times it says something about 'libpng-gf' failing (which is understandable), followed by SIGABRT which from what I understand is something about aborting the application.

Anyway is it possible to resolve this issue?  It's annoying that such a handy way to change the font, particularly for testing and debugging purposes, would cause such problems.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

It might not be readable from that directory?

Hark0

Easy way:

Make a directory called /MEDIA in app folder

...and place png files into folder...



Load font in you app like this:

LOADFONT GETCURRENTDIR$()+"/smallfont.png",0

;)

My project actually have more than one folder in /MEDIA...

Ex:

/MEDIA/fonts
/MEDIA/grfx
/MEDIA/wave
/MEDIA/mp3
/MEDIA/data
...

I use LOADFONT GETCURRENTDIR$()+"/font/smallfont.png",0

http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Hark0

Don't forget to paste this at start of program.

SETCURRENTDIR("Media")


;)
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Moebius

I'm not loading it myself... And don't worry I use the holy Media folder  :nw:

Everything inside the .app folder should be readable anyway - I've seen apps which don't have any subfolders for content.
Also the fact that GDB reports a libpng error suggests that it isn't about loading the file...

BTW is this automatic font loading an intended feature?  It seems strange that it would load a file called "smallfont.png", and I haven't seen any mention of this in the docs.
If it is an intended feature and for some reason it doesn't work on iOS, it would be good if it worked, but can it at least be disabled so that this problem doesn't happen?
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

You must somehow tell XCode to transmit the stuff outside the Media directory to the device, manually.

Moebius

I know, I've done that.  That isn't the problem anyway  :P
I know the file is there.  I can check using OpenSSH, and file browsers (and I have).  It can be loaded.  This isn't the problem.  :P

It seems that GLB has a feature that automatically loads the 'smallfont.png' file if it is present, and sets it as the default font.  I have used this in Windows.

On iOS, not only does this not work, but it causes the application to crash while loading.  The debugger in XCode reports an error that has occurred with "libpng", implying to me that the program tries to load "smallfont.png" but fails.

It would be good if this feature worked in iOS, but it would good if it is at least removed if it can't be fixed and causes the application to crash before it even gets to the start of the user's code...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

uhm. Does your program not start? Mine do. (confused)

MrTAToad

Can you try using smalfont.bmp instead (removing the png file) and see if that works.

The other possibility is that the png file isn't compatible with the iOS PNG library (or its corrupt).

Moebius

Thanks I'll look into this.  Clever as I am, the idea to try another png file never occurred to me  :whistle:  I'll try saving one using a different program or something similar.

Quoteuhm. Does your program not start? Mine do. (confused)
My explanations haven't been rock-solid lately have they sry  :whistle:  My program does 'start' as such (it opens and begins initialising), but before the first bit of my code it crashes, due to something involving the .png file...

I wouldn't worry about looking into this until I've confirmed that it's not just the png I'm using (and sorry again about failing to already have done this...)
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello

Please run it with the "Console" feature of the XCode menu, and post what is says there, please.

Moebius

Okay here's the output from GDB (only the last two lines are important, but just for the sake of it I've posted more):
Code (glbasic) Select
sharedlibrary apply-load-rules all
continue
init with frame.
desktop backing: 320 x 480
mainScreen: 320x480
-applicationDidBecomeActive    -> unpause
Init GFX
BGRA ext supported
AudioStreamBasicDescription:  2 ch,  44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved
libpng error: CgBI: unknown critical chunk
Program received signal:  "SIGABRT".


Resaving the file as a .bmp works, implying moreso that it is a problem with the png library.


I'm about to try other pngs now, and also see if I can load this one using LOADSPRITE.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Kitty Hello


MrTAToad

This Apple thread has an interesting bit of information about this error message : http://discussions.apple.com/thread.jspa?threadID=1976694

Moebius

QuoteYikes!! That file works on Windows?
Yes!  I was wondered if this was an intended feature when I stumbled across it...  Should this actually NOT be happening?  If so that is alarming   :doubt:

Also I have to update something:  It isn't "smallfont.png", it is "smalfont.png", with one 'L', the default filename when using the DINGS font creator in tools.
Noting this though, it's also surprising that you can use "smalfont.bmp", and it still automatically loads it as the font!



QuoteThis Apple thread has an interesting bit of information about this error message : http://discussions.apple.com/thread.jspa?threadID=1976694

I've only looked over this briefly so far, but now  I remember reading somewhere about internal PNG file structure and chunks...  If memory serves, if the chunk name starts with a capital letter, then it is considered "critical" and a PNG file reader won't open the file unless it knows how to interpret these "critical" chunks...


The strange thing though is that, I have confirmed with testing, I can load the PNG file with LOADSPRITE and LOADFONT successfully...   I'm really not sure what to make of this.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary