Author Topic: textures are gone after some time  (Read 5349 times)

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
textures are gone after some time
« on: October 20, 2009, 04:53:08 pm »
hi,

i've adapted new version of jPCT to karga. (not online yet) and been playing with mipmapping and multi threading. multi threading definetely increases fps one multi core machines :) mipmapping works almost identical to previous external MipMapper and i guess performs slightly better. and of course much easier to use. great job :)

however after some time, some of my textures are gone. it's like we have added an object with a missing texture. below are two shots:



i cannot regularly reproduce it, but i can say it happens with multi cores, mipmapping enabled and MOSTLY while resizing the window (creating a new FrameBuffer). i guess it's a multi-threading issue

any ideas ?

r a f t

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #1 on: October 20, 2009, 06:32:16 pm »
Strange...i'm pretty sure that it's a multi-threading problem. I just can't figure it out ATM. Obviously, the textures are there, just blank. Because otherwise, it would give you a null pointer or similar. Are you by any chance getting some messages like "Could not grab pixels from image!" or something similar?

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #2 on: October 20, 2009, 06:40:27 pm »
i've just retried it, it happened again and no, nothing is printed.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #3 on: October 20, 2009, 07:00:55 pm »
Does it go away without multi threading and/or mip mapping used?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #4 on: October 20, 2009, 07:18:59 pm »
And are you calling dispose() on the old framebuffer and/or are disabling the renderer on it before it goes out of scope when creating a new one? If not, please add that. If it still doesn't help, please give this jar a try: http://www.jpct.net/download/beta/jpct.jar

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #5 on: October 20, 2009, 07:30:46 pm »
it happened single threaded and mipmapping disabled :/

are both FrameBuffer.dispose and disable renderer necessary ? looking at the code, i call most of the time dispose but not disable renderer..

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #6 on: October 20, 2009, 07:46:21 pm »
onfortunately neither helped. i also tried the new jar. i dispose the buffer with:
Code: [Select]
        buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
        buffer.dispose();
        buffer = null;

maybe this may give you a clue: once this happens, recreating the buffer doesnt help, missing textures remains missing..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #7 on: October 20, 2009, 07:58:18 pm »
Are you using that advanced blitting method (that one what supports scaling and such)? It looks like as if somehow the textures are replaced by the dummy texture. Can you replace the dummy texture with something else (for example a Texture with the word "dummy" on it) by using setDummyTexture(<Texture>) in the TextureManager to see, if this really is the dummy texture or something else!?

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #8 on: October 20, 2009, 08:18:39 pm »
no, i do not use blitting at all. i'm happy with swing for such things :)

it's definetely the dummy texture, i replaced the dummu texture with:
Code: [Select]
    BufferedImage image = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = image.createGraphics();
    g2d.setColor(Color.WHITE);
    g2d.fillRect(0, 0, 256, 256);
    g2d.setColor(Color.BLACK);
    for (int i = 0; i < 120; i+= 10) {
            g2d.drawRect(i, i, 256-2*i, 256-2*i);
    }
    g2d.dispose();
    return new com.threed.jpct.Texture(image);

and the result is:


an interesting detail is, it always happens to same objects. seldomly on the village to center area and to banks over there, and mostly all of the mushroom club itself.

hope this helps..
r a f t

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #9 on: October 20, 2009, 09:01:15 pm »
How are you handling textures in Karga? Are they loaded once at the beginning, are they added at runtime or even removed? Actually, there aren't much locations in the code that make use of the dummy texture. replaceTexture() is one of them. Any chance that your own mip mapping code is still active somehow (just to be sure...)?
« Last Edit: October 20, 2009, 09:06:17 pm by EgonOlsen »

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #10 on: October 20, 2009, 09:47:03 pm »
Quote
How are you handling textures in Karga? Are they loaded once at the beginning, are they added at runtime or even removed?
both. scene textures are loaded when world is first created, avatar textures are created/added/replaced on demand.  remember, users can change dress in karga, most of which is done by creating texture combinations on the fly..

Quote
Any chance that your own mip mapping code is still active somehow (just to be sure...)?
i didnt remove my MipMapper code. but it's disabled. to make sure i put some breakpoints and none suspended..

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #11 on: October 20, 2009, 09:47:32 pm »
i've found it :) i had overriden World.dispose() and there clear textures specific to that world by name. World.dispose is called when the scene changes. you had a finalizer method in World and you call dispose there too. when that finalizer runs, textures with same name of current world is replaced by dummy texture ::) that mostly happens when resizing window since a call System.gc() after disposing previous FrameBuffer. that's the whole story ;)

i can put a guard to prevent double disposing, but i guess you should do the same. ie: put an internal disposed flag to world.

regards,
r a f t

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #12 on: October 20, 2009, 10:00:53 pm »
I dimly remember adding that finalize-method, because there was some memory leak otherwise when people forget to dispose the world. Too bad that i can't use weak references to stay compatible with 1.1. I've updated the jar above with a version that hopefully prevents double disposing.
Nice bug btw... ;D

Edit: This is the source of all problems: http://www.jpct.net/forum2/index.php/topic,1110.0.html (well, maybe not of all...)
« Last Edit: October 20, 2009, 10:02:48 pm by EgonOlsen »

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: textures are gone after some time
« Reply #13 on: October 20, 2009, 10:23:27 pm »
thanks. i've also prevented it in my code. well if i were you, i had dismissed 1.1 support long time ago. lucky jPCT users i'm not you ;)

btw, is there a lighting change ? looking at the change log, i can only see a default ambient ligt change which shouldn't effect me, since i explicitly set ambient light.

this is how village looks before (not sure but i guess jPCT 1.17) this is still the online version


this is how it looks with 1.19.


especially the skybox looks darker. it's another world instance rendered to same frame buffer with an ambient light 255,255,255.

what do you think, my fault or ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: textures are gone after some time
« Reply #14 on: October 20, 2009, 11:24:51 pm »
Actually no...i did a comparision of the light calculations back to mid-2007 and i can't find anything that should cause this. Maybe you are calling compile() on objects? That will implicitly set Config.lightMul to 1 (instead of 10, which is default) and doesn't make any sense when using the software renderer either.