<?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>1491</bug_id>
          
          <creation_ts>2024-01-25 09:41:23 +0100</creation_ts>
          <short_desc>GLMediaPlayer: Remove resource restrictions and locking with shared GLContext (*GraphicsDevice)</short_desc>
          <delta_ts>2024-01-25 11:46:11 +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>video</component>
          <version>2.6.0</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>P4</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>805</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>FEATURE</cf_type>
          <cf_scm_refs>76487cd34ba706bee6c122a1cbbc75f5639eb4a4
18afa5200983bb158e631c81f2df1ca1a45cd882
78812de21182e32f86a823321b017f7f6cf52ae3</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7066</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2024-01-25 09:41:23 +0100</bug_when>
    <thetext>In a use case with hundreds of GLMediaPlayer instances, 
this causes the application to bail out due to running out of resources.

+++

GLMediaPlayer exposes resource restrictions and locking related
with the created off-thread shared GLContext 
due to its newly created NativeWindow *GraphicsDevice instance (on X11).

On the X11 platform, the *GraphicsDevice actually uses a native resource (X11 Display handle) and hence creating such device is costly and limited.

To operate an off-thread GLContext w/o actual X11 input handling, 
it is *NOT* required to use a new instance.

+++

Further more, the device is using locking.
To operate an off-thread GLContext, it is *NOT* required to use locking on it
as it does not perform actual X11 input handling etc.
All operations are performed on the shared GL context.

+++

Solution is to create a shared non-locking device clone 
compatible with the source.
A share counter shall determine that the last one actually gets destructed.
The usual ..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7067</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2024-01-25 09:42:17 +0100</bug_when>
    <thetext>commit 76487cd34ba706bee6c122a1cbbc75f5639eb4a4

    NativeWindowFactory.createDevice(..) w/ unitID for cloning; DefaultGraphicsDevice: Move ownership (Object) code into base class ensuring same code
    
    NativeWindowFactory.createDevice(..) w/ unitID
    - Allows cloning a device instance with same parameter.
    
    DefaultGraphicsDevice: Move ownership (Object) code final into base class ensuring same code
    - Rename DefaultGraphicsDevice.swapDeviceHandleAndOwnership() -&gt; swapHandleAndOwnership()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7068</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2024-01-25 09:44:02 +0100</bug_when>
    <thetext>(In reply to Sven Gothel from comment #1)
commit 18afa5200983bb158e631c81f2df1ca1a45cd882

    Bug 1491: Add missing rename DefaultGraphicsDevice.swap{Device-&gt;}HandleAndOwnership()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7069</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2024-01-25 09:50:31 +0100</bug_when>
    <thetext>commit 78812de21182e32f86a823321b017f7f6cf52ae3
Bug 1491: FFMPEGMediaPlayer: Lock moviePtr lifecycle phase in-between [initStreamImpl - destruction]

initStreamImpl() calls ffmpeg natives.setStream0(..), which in turn callsback to the GLMediaPlayerImpl 
and FFMPEGPlayer and hence requires a valid moviePtr. In total, it covers a longer time period.

This patch uses a moviePtrLock object avoiding destruction while within initStreamImpl.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7070</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2024-01-25 09:55:13 +0100</bug_when>
    <thetext>commit 8fe39d3a524e5e580cf2667988965f1e27fed95b
Bug 1491: GLMediaPlayerImpl: Use a shared *GraphicsDevice for all compatible shared GLContext, removing resource restrictions

implemented as described.

+++

We may consider reusing this solution adding a GraphicsDevice shared resource handler class for other similar (if not same) cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7072</commentid>
    <comment_count>5</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2024-01-25 11:46:11 +0100</bug_when>
    <thetext>See a demos w/ &gt; 200 GLMediaPlayer instance running in a GraphUI Ranged Group,
having 36 instances being visible and displaying new decoded images.

https://jausoft.com/blog/wp-content/uploads/2024/01/UIMediaGrid01-norm-q1-s01-fsaa4-media-snap22b-1920x1080-1.jpg</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>