<?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>1408</bug_id>
          
          <creation_ts>2019-12-04 21:02:09 +0100</creation_ts>
          <short_desc>GNU/Linux DRM Freezes when manipulating the PointerIcon (setting &amp; visibility)</short_desc>
          <delta_ts>2019-12-05 07:52:02 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>embedded</component>
          <version>2.4.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>blocker</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>1156</dependson>
          <blocked>1405</blocked>
    
    <blocked>1406</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>xerxes</cc>
          
          <cf_type>DEFECT</cf_type>
          <cf_scm_refs>d5ba4cae824087879a4857e20961a95da04eaebb
66976571abed5f14db5de9975ce08d62cfecc2c8
c7778616ef7706461ee0b09e20591f5a6e4ea363
59fe721a926ff66e98b716a25a08bdfa584ca6fa
eaa81d524e9be6af9867c8b6750505c8660a6651
bfc152be4203eeceebea919aff9513d33213c802
ea23776919eff10dee57519ce72354bbaea3544e
84a2e5a250148d600d48a0dd58e07286a375f616
033ee4cad3493038480b06f6caf3de015a3e8de7</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>6405</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-04 21:02:09 +0100</bug_when>
    <thetext>Triaging instability of DRM/GBM on Raspberry Pi 3B+ and 4B,
disclosed stability issues (freeze) when changing the PointerIcon or making it visible/invisible.

Potentially we have missed using a device lock here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6407</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-04 21:04:27 +0100</bug_when>
    <thetext>Reproduced this freeze on a GNU/Linux x86_64 Intel Broadwell device,
besides Raspberry Pi 3B+ and 4B.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6408</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-04 21:51:52 +0100</bug_when>
    <thetext>(In reply to Sven Gothel from comment #0)
&gt; 
&gt; Potentially we have missed using a device lock here.

We are using the ResourceToolkitLock, 
but did not put pointer manipulation within a locked block.

However, after adding lock/unlock decoration the freeze still appears.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6409</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-04 21:54:32 +0100</bug_when>
    <thetext>Test is run as follows on Raspberry Pi:

cd projects/JogAmp/jogl/make
bash scripts/test-demo-launcher0.sh `which java` ../build-linux-armv6hf
 -time 10000 -noanim -vsync 0


and on x86_64


cd projects/JogAmp/jogl/make
bash scripts/test-demo-launcher0.sh `which java` ../build-x86_64
 -time 10000 -noanim -vsync 0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6410</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-04 22:46:26 +0100</bug_when>
    <thetext>d5ba4cae824087879a4857e20961a95da04eaebb
NEWT: Align DisplayImpl.createPointerIcon(..) behavior; PointerIconImpl.validatedHandle() shall not create native resource.

66976571abed5f14db5de9975ce08d62cfecc2c8
Bug 1408: NEWT DRM/GBM DisplayDriver: Add device locking/unlocking decoration for PointerIcon operations

c7778616ef7706461ee0b09e20591f5a6e4ea363
Bug 1408: NEWT DisplayImpl PointerIcon: Property &apos;newt.disable.PointerIcon&apos; disables PointerIcon usage in general.

59fe721a926ff66e98b716a25a08bdfa584ca6fa
Bug 1408: NEWT DRM/GBM WindowDriver: Adding glFinish() before eglSwapBuffers(..) just in case ..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6411</commentid>
    <comment_count>5</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-04 23:03:00 +0100</bug_when>
    <thetext>(In reply to Sven Gothel from comment #4)

Looks like we have finally a winner:
&gt; c7778616ef7706461ee0b09e20591f5a6e4ea363
&gt; Bug 1408: NEWT DisplayImpl PointerIcon: Property &apos;newt.disable.PointerIcon&apos;
&gt; disables PointerIcon usage in general.

Disabling the PointerIcon (and hence DRM Cursor manipulation)
makes _the_ difference. Enabling it (dropping the property from the commandline) reproduces the freezes.

This is regardless whether we use VSYNC or the animator thread.

Note: The generic device locking occurs throughout NEWT display and JOGL,
i.e. during DRM cursor manipulation or GL rendering and swapSurface.

The freeze even occurs at startup on Raspi-3b+

Needs a good investigation now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6414</commentid>
    <comment_count>6</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-05 07:51:24 +0100</bug_when>
    <thetext>eaa81d524e9be6af9867c8b6750505c8660a6651
Bug 1406, Bug 1405: demos.Launcher0: Allow passing GLEventListener via &apos;-demo classname&apos;

bfc152be4203eeceebea919aff9513d33213c802
NEWTDemoListener: Fix NPE

ea23776919eff10dee57519ce72354bbaea3544e
Bug 1406, Bug 1405: demos.Launcher0: Defaults to use multiple PointerIcons again
    
    launch script test-demo-launcher0.sh: Tested with &apos;-Xcheck:jni&apos;

84a2e5a250148d600d48a0dd58e07286a375f616
LinuxKeyEventTracker: Factor out &apos;sendKeyEvent(..)&apos; call with null check.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6415</commentid>
    <comment_count>7</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2019-12-05 07:52:02 +0100</bug_when>
    <thetext>The actual fix:

033ee4cad3493038480b06f6caf3de015a3e8de7

    Bug 1405, Bug 1406, Bug 1408: Resolution: Call ReleasePrimitiveArrayCritical(..) in GetPrimitiveArrayCritical(..) code path!
    
    Now that was quite a miss, causing the bugs in the first place!
    The freeze was caused in the JVM, as this open GetPrimitiveArrayCritical(..) disabled the GC.
    This was reported via &apos;-Xcheck:jni&apos;.
    Depending on the system/jvm, the freeze may happen early or only after a while.
    
    This code path was not executed with new property &apos;newt.disable.PointerIcon&apos; set,
    but from there to finding the missing critical release - a journey:
    
    - jstack showed
    
      &quot;main&quot; #1 prio=5 os_prio=0 cpu=275.71ms elapsed=51.93s allocated=9710K defined_classes=472 tid=0x00007f7084015000 nid=0x1a39 waiting on condition  [0x00007f
70897c2000]
         java.lang.Thread.State: RUNNABLE
              at jogamp.opengl.es3.GLES3Impl.dispatch_glUniformMatrix4fv1(Native Method)
              at jogamp.opengl.es3.GLES3Impl.glUniformMatrix4fv(GLES3Impl.java:2585)
              at jogamp.opengl.es3.GLES3Impl.glUniform(GLES3Impl.java:10713)
    
    -- said that this thread was no more running, waiting on condition ..
    -- glUniformMatrix4fv1 was given an array!
    
    - &apos;-Xcheck:jni&apos; gave:
    
      Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical
    
    -- Now it is clear that the lack of releasing the critical array, returning to Java and then calling other JNI methods
       caused the Warning - and eventually the freeze.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>