<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1033</bug_id>
          
          <creation_ts>2014-07-15 04:09:14 +0200</creation_ts>
          <short_desc>Guarantee atomicity of high-level GLAutoDrawable operations, avoiding race conditions.</short_desc>
          <delta_ts>2014-07-27 23:26:06 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>core</component>
          <version>2</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>askinner</cc>
    
    <cc>sgothel</cc>
          
          <cf_type>DEFECT</cf_type>
          <cf_scm_refs>c77b8f586cb2553582a42f5b90aeee5ef85f1efe</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4028</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-15 04:09:14 +0200</bug_when>
    <thetext>Currently race-conditions are possible on the following 
high level utility method:

- GLDrawableUtil.swapGLContextAndAllGLEventListener(
                    GLAutoDrawable a, GLAutoDrawable b);

- GLEventListenerState.moveFrom(GLAutoDrawable src)
- GLEventListenerState.moveTo(GLAutoDrawable dest)

Their implementation lacks locking of
  [1] the GLAutoDrawable&apos;s NativeSurface, as well as of
  [2] the GLAutoDrawable&apos;s implementation own &apos;upstream&apos; lock.

Locking of the NativeSurface is mandatory to hinder other threads
of acquiring the OpenGL context (lock).

Since GLAutoDrawable implementations also employ their own 
&apos;high-level&apos; lock, e.g. for modifying their surface/drawable,
it is important to acquire a lock on such beforehand.

Actual locking order of GLAutoDrawable is:
  1) GLAutoDrawable Lock
  2) NativeSurface Lock

(Note: GLContext.makeCurrent() acquires the NativeSurface Lock 1st.)

Allowing proper locking requires our API to expose 
the GLAutoDrawable &apos;upstream&apos; lock!

Note: While holding the GLAutoDrawable locks, GLAutoDrawable.invoke(..) 
      cannot be issued, since it may be performed off-thread.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4033</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-27 23:26:06 +0200</bug_when>
    <thetext>c77b8f586cb2553582a42f5b90aeee5ef85f1efe

GLAutoDrawable (API CHANGE) allowing atomic operations:
    - Add class API-doc chapter about &apos;GLAutoDrawable Locking&apos;

    - Add method invoke(..) API-doc description about 
      throwing IllegalStateException in case of a 
      detected deadlock situation ahead
      (Note: Implemented in GLDrawableHelper.invoke(..) for all implementations)

    - Add new methods for proper multithread handling:
    - public RecursiveLock getUpstreamLock();
    - public boolean isThreadGLCapable();

+++

GLEventListenerState/GLDrawableUtil:

    - Perform operation in a atomic fashion,
    i.e. lock GLAutoDrawable during whole operations:
        - GLDrawableUtil.swapGLContext(..)
        - GLDrawableUtil.swapGLContextAndAllGLEventListener(..)
        - GLEventListenerState.moveFrom(..)
        - GLEventListenerState.moveTo(..)

    - ReshapeGLEventListener:
    - Moved from 
        GLEventListenerState.ReshapeGLEventListener 
        -&gt;  GLDrawableUtil.ReshapeGLEventListener
    - Takes &apos;displayAfterReshape&apos; case into account.

+++

javax.media.opengl.Threading Clarifications:
    - Public &apos;enum Mode&apos;, i.e. Threading.Mode

    - Public getMode()

    - Clarified &apos;isOpenGLThread()&apos;:
    - Take &apos;singleThreaded&apos; into account directly,
        i.e. always return &apos;true&apos; if singleThreaded == false</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>