multiple objects sharing texture handles crash

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Wed Oct 05, 2011 4:41 pm

i construct each instance of the same sprite uses the same texturehandle. in the current plug I'm developing, if I have more than one object getting it's texture from the same handle, it crashes? any idea why? I'll try looking through the runtime code to figure out how sprite pulls it off, but any help would be appreciated.

I can't see why, but I'm fairly certain it's the problem. basically I have a line of code that copies the texture to a new handle each time a new object will use it. if i remove that code and make them both refer to the same handle it crashes

also, if it helps with the answer, the objects need to load an unknown amount of new textures off of disk at runtime, and share them amongst eachother
lucid2011-10-05 17:35:55
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Oct 05, 2011 9:42 pm

At what point does it crash? TextureHandles are reference counted, which is taken care of for you when creating a new textureHandle. But when manually setting a texture to an existing textureHandle it appears that you need to manually increment the reference.
http://www.google.com/codesearch#ri7jKR5oU44/Runtime/RenderLayer.cpp&q=AddTextureReference%20package:construct&type=cs&l=79
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Wed Oct 05, 2011 11:57 pm

thank you rojo
just recently changed something I can't seem to undo that made the problem worse. but when I debug.
it seems to set the textures fine one time, for a new object,
this is basically a modified sprite object that has localTex used for rendering instead of info.currenttexture

also I just added the line at the top to increment reference. Not sure if that's how it's supposed to be done

but it crashes on the highlighted line:
http://pastebin.com/Hmqgzz3K
lucid2011-10-06 14:16:17
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Oct 06, 2011 12:00 am

ok
update. if I remove the line from the previous post it doesn't crash. but I really need to be able to generate a collision mask.
while I wait for a reply, I'll try to search for some releasecollision mask or increment of that. thanks for your help so far though

I'll post back if I figure it out before you do


edit: also removed the increment texture thing and works the same, no crash unless I try to generate a collision mask:


localTex = (TextureHandle)param;
info.w=localTex->image_widthf;
info.h=localTex->image_heightf;
pRuntime->UpdateBoundingBox(this);


this works fine with no crashes
lucid2011-10-06 15:19:26
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Oct 10, 2011 7:54 am

There was a bug with GenerateCollisionMaskFromTexture() locking a texture region and not unlocking it. Is now in the SVN revision 283.
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Mon Oct 10, 2011 11:01 am

thanks again. I pm'd you back about the updated runtimes. Also, if you could phrase what you did in a changelog friendly way I'll add it to the cc changelog
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests