Jump to content

iphone 3gs image issues


alex_h
 Share

Recommended Posts

Softgames have pointed out that all of my games fail to complete loading on their iPhone 3GS running iOS 6. I've determined that the game attempts to start loading my png format texture atlas file but never completes doing so. My first thought was that my atlas might be too big for the 3GS to handle, and the info on this link:

 

http://www.williammalone.com/articles/html5-javascript-ios-maximum-image-size/

 

seemed to confirm these suspicions. But when I split the atlas into smaller chunks that all come in under 3 megapixels the game still apparently crashes. As I don't have an iPhone 3GS and also currently have quite restricted web access this is a pretty difficult one to fix, so I thought I'd post here to see if there is some known issue I am missing.

 

Does anybody know if there is some trick to getting standard png files with alpha channel to load on an iPhone 3GS? Currently I am just creating Image objects for each image file, setting the src, and waiting for the onload to fire; a pretty standard way of doing things I'd have thought.

Link to comment
Share on other sites

It's not just the size of the images, it's also how many you've got. However if you exhaust the memory in Safari it crashes back to the home screen, not freeze, so I suspect something else is going on. My next guess would be the audio. Try disabling it entirely perhaps and see if the game at least starts.

Link to comment
Share on other sites

It was initially just a single texture atlas, less than 2048 square, with an additional full screen jpeg for the background and another full screen sized 'please rotate' jpeg image. Should be well within acceptable limits I would have thought. When web audio is available the game loads audio files before the images using xhr, and this process appears to complete successfully. It then reports beginning to load the images, appears to succeed with the jpeg background but never completes loading the png. When I switched to use 2 smaller atlas pngs from what I can tell I think it fails when trying to load the first of them.

It doesn't try to play any audio until everything has finished loading, and even then it has to wait until a touch event has occurred before initialising the sound engine, so I'm pretty confident that (for once!) audio is not causing the problem.

 

By the sound of it, at least there is not some obvious answer to this that I was not previously aware of!

 

I suppose one possible avenue would be to try loading the images via xhr as well, but I can't really see any logical reason why that should make any difference. Still, sometimes it pays off just to try things though, even if it's not obviously going to fix the issue, could still lead to more insight into the matter!

Link to comment
Share on other sites

I'd still disable the audio, not because it might be crashing on playback but simply because it's consuming memory.

 

You should take this right back to the most simple test case possible maybe? Just a single js file that does nothing but load up your images and draw them to a canvas. Should only be a few lines of code, but will let you know immediately if it's actually the images or something deeper in your game code.

 

Isolate and test. Or hook it up to a Mac and use Remote Debugging in Safari to see what error it's throwing?

Link to comment
Share on other sites

  • 3 months later...

For me the problem was actually not that it was taking too long to load, but that the game was crashing outright during loading as a result of too big texture atlas for the device to handle. The solution I found worked in my case was to generate a duplicate set of assets at half scale (1024 rather than 2048) and use those when running on devices with a 480 x 320 or smaller screen. I'm not sure if this will help for you. If the problem in your case is that your game takes too long to load you need to change the game so that it loads less assets on the the 3GS. One way of achieving this could be to do the same as I did and halve the size of your assets for that platform, but this may or may not be possible depending on what resolution your assets are to start with.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...