Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Bitmaps/Textures disappearing — Gideros Forum

Bitmaps/Textures disappearing

krisiskrisis Member
edited April 2013 in Bugs and issues
I'm finding that some bitmaps/textures displayed on one of my menus seem to disappear and show as white occasionally (see attachments). Multiple users of my app (including myself) have seen this. Changing scenes and coming back normally resolves it, but this is obviously a terrible user experience.

Any idea why this would be occurring?

e.g. code for the top button is pretty straight-forward:
local button = Button.new(Bitmap.new(Texture.new("images/cell_button_yellow.png")))
	button:addEventListener("click", function()
		stats:log("clickStartButton")
		--go to game scene
		sceneManager:changeScene("opponent", conf.transitionTime, sceneManager.fade, conf.easing) 
	end)
	local buttonText = TextField.new(conf.fonts.button, "Start New Game")
	buttonText:setTextColor(0x000000)
	buttonText:setPosition(math.floor(button:getWidth()/2 - buttonText:getWidth()/2), 43)
	button:addChild(buttonText)
	button.hasGame = false
	button.name = "startGame"
	button.matchId = 0
	button.index = 0
	self.slider:addChild(button)
missing_textures.png
360 x 586 - 105K
correct_textures.png
360 x 583 - 133K
[ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]

Comments

  • ar2rsawseenar2rsawseen Maintainer
    @krisis only idea that I have, is that you are providing only one Bitmap to button class, but it have multiple states (up and down).

    Maybe it is causing the problem and then the fix would be:
    local bitmap = Bitmap.new(Texture.new("images/cell_button_yellow.png"))
    local button = Button.new(bitmap, bitmap)
  • I have actually modified the Button class to allow only one state, and I just double-checked the code and it wouldn't be that change.

    Additionally, some of the other bitmaps showing as blank aren't buttons. Those two title background bitmaps are:
    local tcellTop = Bitmap.new(Texture.new("images/cell_top_blue_half.png", conf.textureFilter))
    		local ttitle = ShadowText.new("Their Turn", conf.fonts.button, 1)
    		ttitle:setTextColor(0xffffff)
    		ttitle:setPosition(math.floor(tcellTop:getWidth() - ttitle:getWidth() - 30), math.floor(tcellTop:getHeight()/2 - ttitle:getHeight()/2 + 25))
    		tcellTop:addChild(ttitle)
    		self.slider:addChild(tcellTop)
    As you can see from the screenshots, the text is showing up even as a child of the bitmap which disappears. It just seems as if the bitmap/texture gets garbage collected and appears white.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • I have same problem yesterday. In my case datasaver.Loadvalue was reason. I don't know why, because it was:
    "if datasaver.LoadValue~="add" then
    end"
    So it does nothing.
    It was resolved when i moved this code before any Bitmaps and Buttons.
  • I've had it happen on a couple of different scenes now, and it's just random bitmaps on each scene, not necessarily all of them. It really seems to be some kind of garbage collection gone bad.

    Only thing I can think of is to make them all globals and do my own garbage collection on scene change, but that is messy.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • i had also seen this problem in one of the examples downloaded from forum. i think that example is this one http://www.builtwithgideros.com/Family/Popo-dan-Pino-Mainan-Baru

    the bug was happening in my lg p500 after seeing few pages not sure for ios device.

    :)
  • bowerandybowerandy Guru
    edited April 2013
    @krisis, I have seen this before in my app too (it is iOS only). I assumed it was due to the device running out of texture memory and iOS freeing up this memory when switching away to another app and then not reloading it correctly when switching back.

    When I reorganized my sprite sheets so that not so much was loaded at once, the problem "went away". I haven't been too concerned with it because it only seemed to occur a) very rarely and b) in high memory use situations.

    Try rebooting your device and see if the problem goes away. If it does, it might lend credence to the above theory and we should ask @atilim to take a look.

    best regards

    PS: One other suggestion. Try hanging on to the button Texture in a separate field variable so that the only reference isn't the Bitmap. I don't know why but I had a feeing that the problem might only occur when a Texture was only referenced once - by the Bitmap that was using it.
  • I have this even in gideros player on PC. It is not about device.
  • ar2rsawseenar2rsawseen Maintainer
    @atilim is already aware and will look at this issue. The best thing that you could all do is to provide a reproducible test example (as attached Gideros project) that has this flaw. :)
  • tkhnomantkhnoman Member
    edited April 2013
    I remembered this case(and not occasion, but always), but don't know how to reproduce it.

    I get over it by giving timer before loading some sprites.
  • atilimatilim Maintainer
    oh I'll look at it. I agree with @bowerandy's insights. Can you execute this statement
    print(application:getTextureMemoryUsage())
    and check the texture memory usage?


  • Only thing I can think of is to make them all globals and do my own garbage collection on scene change, but that is messy.
    I very much doubt that it is the Lua garbage collector going wrong. If it's easy to do (perhaps all your texture loading goes through a single function) then why not try hanging on to every texture in a global table and never release it. If my hunch is correct I think this will make the problem occur more often rather than fix it.

    best regards

  • atilimatilim Maintainer
    edited April 2013
    (As an addition to @bowerandy's) If garbage collector incorrectly collects a Texture object, you'll get a crash instead of white texture. But if the system cannot create an OpenGL texture (because of insufficient memory or because of too large texture dimensions), you simply get a white texture.
  • @atilim, just as a matter of interest, if you get a failure to load an OGL texture do you try a few collectgarbage() calls and then try again?

    best regards
  • @bowerandy, there is a collectgarbage() that runs at the end of every scene change. Also, I get it to happen in app without switching away. That is, when I first load they all display fine, then after changing scenes and playing the game and returning to the menu it loses some textures ~20% of the time.

    @atilimi, texture memory usage is 18100kb (iphone5 [640x1136 retina graphics]) on the menu screens where I get white textures. In game it can get to 26500kb but I never lose textures there.

    To further support my theory on making the textures globals, the textures that are still showing on the screenshot (and didn't turn white) are the global ones - background and green square. I tried changing the textures for the button and the table headers/cells to also be global and I have since been unable to reproduce the issue.
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • As for my case, i don't think it was collectgarbage problem or memory problem.
    Mine happen on the start of the App, when there is no collectgarbage happened, and at minimal Texture memory usage.
    More like a clash happen on texture loading, or something like that (all of the sprite that load that one texture will become white).
    Instead of using timer at loading, i also can get over from it by doing a loading the texture from texturePack. So all of my GUI images are all on one texturePack now.

    If i can remember about it, i think this also happen on Corona. So i didn't report about it, as i think this was probably a usual thing.

  • atilimatilim Maintainer
    I'll definitely look into this issue.
    @atilim, just as a matter of interest, if you get a failure to load an OGL texture do you try a few collectgarbage() calls and then try again?
    great idea! I'll implement what you've suggested with the next version.


  • I caught the same problem :(

    oh I'll look at it. I agree with @bowerandy's insights. Can you execute this statement
    print(application:getTextureMemoryUsage())


    I have value from ~20 000 to ~40 000 Kbytes on my Samsung Galaxy S4 (resolution 1920x1080).

    Can someone help me to solve this problem? I tried to restart my device, but it's didn't help me. This problem can appear and disappear suddenly and I can't understand the reason why it's happens.
Sign In or Register to comment.