I just installed the Gingerbread update from Google’s update server and Corona apps aren’t launching anymore. The update link is on the xda developers forum. [import]uid: 4596 topic_id: 7129 reply_id: 307129[/import]
For Nexus 1? Mine launches no problem. In fact its running alot faster! [import]uid: 8872 topic_id: 7129 reply_id: 25129[/import]
Yes, on NexusOne build with stable .291 and daily build .305.
The EggBreaker sample works fine, so it’s particular to my app, which was previously running fine on Android 2.2.2. I’ll try to narrow down to what’s causing the crash. It’s not a very complex app, only using physics, audio, and sprites. [import]uid: 4596 topic_id: 7129 reply_id: 25139[/import]
The crash is being caused by loading the following images, which previously loaded fine on my NexusOne running Android 2.2.2.
//main.lua
local img1 = display.newImage(“layer_1.png”)
local img2 = display.newImage(“layer_2.png”)
local img3 = display.newImage(“layer_3.png”)
local img4 = display.newImage(“layer_4.png”)
local img5 = display.newImage(“layer_5.png”)
The images are large, each being about 1800 x 900 pixels. If I only load 4 instead of all 5, it doesn’t crash on the device. Any ideas? [import]uid: 4596 topic_id: 7129 reply_id: 25154[/import]
You’re running out of texture memory probably. On android this isn’t fixed and the os decides your limit. I guess this tuning changed in gingerbread.
Why are you loading 5 such large images? You should load them as needed and unload the old ones.
For example if those 5 made a image viewer which u could slide back and forth between images… load previous current. And next image. On swipe right
Previous:removeself()
Previous = current
Current = next
System.performwithtimer(50, loadnextimage)
Current.isvisible = true
Previous.isvisible = false
In load next image u load an image into next and set isvisible false
This will get over the lag of loading images on demand. [import]uid: 8872 topic_id: 7129 reply_id: 25158[/import]
Thanks kam, I’ll have to look more into managing texture memory and tiling images. [import]uid: 4596 topic_id: 7129 reply_id: 25166[/import]
np,
btw you can use system.getInfo( “texturememoryUsed” ) to check and print the texture memory usage. If you use adb:
adb logcat
you can print android logs to the console. adb is part of the android sdk. This will also show you any print()'s you used in your main code, and that normally display in the corona console window.
So you can pridocially print texture memory etc if you like.
Gingerbread enabled hw acceleration so that may be why the texture memory stuff changed. [import]uid: 8872 topic_id: 7129 reply_id: 25168[/import]
When setting isFullResolution parameter to true, it uses 29MB, but when set to false the textureMemoryUsed is 9.4MB. That seems acceptable, but the app crashes on the device. Any idea what the max texture limits are supposed to be? [import]uid: 4596 topic_id: 7129 reply_id: 25181[/import]
Corona’s using 2 MB to display a 29KB image. Does that seem correct?
local isFullResolution = true
local img5 = display.newImage(“layer_5_2.png”, 0, 0, isFullResolution )
print( (system.getInfo(“textureMemoryUsed”) / 1024) / 1024 )
[import]uid: 4596 topic_id: 7129 reply_id: 25184[/import]
1.) Any code examples of multi-page app - how to clear old page?
2.) How do I have a “background thread” that starts up when the
device starts up and calls a remote web server every 10 mins
and then asks for the user to put in password and
“passes” that back to thread ?
3.) Does Corona need PhoneGap, or does it compile to bytecode ?
How does one prepare for market apk ?
4.) What do you get when you pay that you did not get by downloading ?
Thanks for the “pointers”,
Jerry [import]uid: 12443 topic_id: 7129 reply_id: 25185[/import]
All images are decompressed and converted to 32 bit bitmaps. so a white 1000x1000 image may be 20k as a jpeg but in device memory its huge, The actual dimensions of the image is what matters. There are many problems with corona but this isnt a corona problem. Its just the way it is with device resources.
Code away in the simulator but when it comes to release u need to optimise for these things.
Android is a real headache because device memory isn’t a fixed thing between devices, That said, good coding practice is invaluable. Just because the sim is ok doesn’t mean its fine on device.
Ansca could try to make the sim more realistic but its a really hard thing to do - personally i think their effort is better spent on other things, [import]uid: 8872 topic_id: 7129 reply_id: 25233[/import]
Yeah I noticed on the device it’s reporting a radically different number. It’s like .000something MB. I don’t know what to believe anymore kam ; ) Do you know if texture memory is allocated from the moment an image is loaded, until it is disposed? If you remove it from the display hierarchy or set it to invisible, is it still stored in memory all the same? I’m trying to figure out how large I can afford to make a tile class.
Thanks for your knowledge dump sir = ) [import]uid: 4596 topic_id: 7129 reply_id: 25241[/import]
The hard limit is imposed by the OS on android, and there’s no fixed general limit. Its really annoying because u just dont know what the limit is on each particular phone 
10mb is ok tho. The isFullResolution is used to load the image in without scaling it down to the device screen size. For example if you wanted a background you could scroll, it may be 3 x screen width, you would use true. If you can use false, use it to save memory.
Texture memory gets used as soon as you load an image, its loaded into texture memory. As soon as you removeself on the image its removed from texture memory. Remember copies of the same image are only loaded once, and that copy reused. When the last copy is removed then the texture memory is released.
Are you positive its the 5th image load? Just to test you should downscale all 5 image to something tiny like 100x100 and then run the program. If that works then you know its definatly the texture memory. If it doesnt you have some other problem! [import]uid: 8872 topic_id: 7129 reply_id: 25263[/import]
Yeah it’s definitely the textureMemoryUsed limit. I was prototyping something using graphics scaled up for the iPad. When scaled down, or loading fewer, they load fine. Although when loading the large images with isFullResolution set to false the app still crashed, as if it’s uploading the full-scale image to memory. idk if that’s to be expected.
[import]uid: 4596 topic_id: 7129 reply_id: 25327[/import]
It should be scaling it down then dropping the original, but maybe thats not the case. I know newImageRect doesnt actually do that and loads the image full size!
You should probably keep a scaled down version for smaller devices. Generally speaking any image larger than the screen size of the device takes a LONG time to load. Especially on small devices.
I support all iOS devices and all android devices in one app. I use one set of graphics for 320x480 devices, one for 800x480 and one for 1024x768.
iphone 4g and ipad use the 1024x768, droid and nexus etc share the 800x480, and other devices use the 320x480.
Its the best compramise i found. [import]uid: 8872 topic_id: 7129 reply_id: 25328[/import]
afaik the texture memory limit on 2.3.3 (aka nexus s) is 24mb (and the performance is as terrible as on other samsung devices) [import]uid: 11772 topic_id: 7129 reply_id: 26907[/import]
The texture memory used in Corona (and iOS and Android) is an uncompressed bitmap of the loaded image. Each pixel requires 32 bits (4 bytes): red, green, blue, and alpha channels. It doesn’t matter if the image file was a jpg or png.
You can determine how much memory an image is going to consume as follows. Take the width and height and round it up to the next higher power of 2 (256, 512, 1024, 2048). Multiple the two numbers together and than by 4. This is the amount of memory (in bytes) used to store the uncompressed image.
Here are some examples:
320 x 480 image. Round up to 512 x 512 x 4 = 1,048,576 or 1 MB
800 x 480 image. Round up to 1024 x 1024 x 4 = 2 MB
1024 x 768 image. Round up to 1024 x 1024 x 4 = 4 MB
2048 x 2048 image. 2048 x 2048 x 4 = 16 MB
It seems like the maximum openGL texture memory size is 2048 so this limits the maximum displayed image to 2048 pixels for the height and width. Some devices may be less.
You can use system.getInfo( “textureMemoryUsed” ) to return the amount of texture memory used by the device.
Images consume Texture memory when the image is loaded and the memory is released when the image object is removed (using object:removeSelf). Loading the image multiple times only loads one copy of image in memory. Setting the object to invisible or off screen doesn’t affect the amount of memory used on the device.
Loading large multiple images should be avoided because of the limited amount of memory available on a device for each app. Typically, this is around 24 MB on an iPhone and higher on an iPad. This number may vary for Android devices.
Update: I modified my posting and changed GB to MB.
[import]uid: 7559 topic_id: 7129 reply_id: 26914[/import]
Thanks Tom, this info is very helpful.
Should the value returned by system.getInfo( “textureMemoryUsed” ) be identical on Android, iOS, and the Simulator? [import]uid: 4596 topic_id: 7129 reply_id: 26925[/import]
Yes, the value returned from the simulator for “textureMemoryUsed” SHOULD be the same as on the device but in my testing yesterday I found that both the iOS and Android devices return 0 bytes. This is another bug that we need to fix. [import]uid: 7559 topic_id: 7129 reply_id: 26930[/import]
Thanks Tom this was really helpful,
yes you should stay below 24MB however all Apple devices from the 3GS on, have shared memory so you can actually allocate more texture memory (but your app may get removed if you constantly push this limit).
I thought Android has a 24Mb heap limit (16Mb on G1/Dream and other older devices), but I too thought OpenGL texture memory does not count towards that limit - bitmaps however do (if using the android.graphics.BitmapFactory) After some reading I discovered that the OEM might limit this texture memory too (on the Nexus S 24Mb sharp, on the Galaxy Tab 2.2 i can allocate images till all your memory are belong to us now ;))
I am currently trying to play a short fullscreen animation in the game and can’t play a video since local videos are not supported on Android, I cant use the movieclip api since it will eat 60mb of texture memory and loading - showing - deleting each image does not look really look fluent. Ideas?
[import]uid: 11772 topic_id: 7129 reply_id: 27047[/import]