Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: NevilleKemp

26. May 2012, 04:28:12 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Crash in TextureImage2D.getData()
Pages: [1]
Print
Author Topic: Crash in TextureImage2D.getData()  (Read 424 times)
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« on: 10. January 2011, 10:37:45 pm »

Marvin,

Discovered an interesting crash in Xith. Now, I'm going to preface this by saying that the cause might be external manipulation of the Swing object my canvas is the child of. This might cause a loss of the OpenGL context, which is unfortunate, and loses us the textures. However, that doesn't cause an issue when not using textured objects, which makes me think this is a legitimate bug with the texture units; read on.

The crash occurs in TextureImage2D.getData, as the "data" member array is null. The array seems to be getting set to null (along with the "dataBuffer" array) in the freeLocalData() function (line 303 in TextureImage2D.java). This would be fine, but the member boolean "hasData" is still set to true.

My suspicion is that, while "hasData" should be used to signal to Xith that a texture may need reloading (a check for this occurs on line 305 of TextureUnitStateUnitPeer.java), it never actually is set to prevent Xith from loading from a bogus array.

On a related note, I'm curious how Xith knows that its OpenGL names have become invalid--I've seen the check in the texture unit code to use cached names, but I wonder how the notification is happening.

I think that, if this actually is a valid bug, it should be easy enough to fix: just make sure that freeing the local resources sets the "hasData" flag correctly (i.e., sets it to false), and add an "else" clause to the "if" statement on line 305 that provides reloading of the texture somehow.

Thanks!

-Chris

EDIT: Fixed typo.
« Last Edit: 11. January 2011, 09:33:06 pm by ChrisE » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 11. January 2011, 08:37:08 pm »

Could it be, that you're using an outdated code base? TextureUnitStateUnit.java deosn't have 305 lines of code.

I guess, it would be best, if you'd post a test case.

Sometimes OpenGL loses textures when in a Swing environment. In these cases you need to use OpenGLLayer.JOGL_SWING.

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #2 on: 11. January 2011, 09:25:32 pm »

Sorry, meant to put TextureUnitStateUnitPeer.java.
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #3 on: 11. January 2011, 09:30:27 pm »

So, doing that calls this code:

Code:
throw new IllegalArgumentException( "You can only use JOGL_AWT and LWJGL_AWT as OpenGLLayer" );

Is this fixed in a newer release, or is that functionality disabled, or what?

-Chris

Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #4 on: 17. January 2011, 08:29:56 pm »

Prior to posting a test-case (again, I'm not sure that I can adequately reproduce the exact operating environment causing the canvas to be jerked out from under Xith), would you mind looking at that section of code and seeing if the "hasData" boolean is being handled correctly over the lifecycle of the TextureUnitStateUnitPeer object? I'm relatively sure that the logic is not as intended.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 17. January 2011, 08:42:37 pm »

I'm sorry. I am just too busy atm. But feel free to suggest a fix.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic