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 ..
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() -> swapHandleAndOwnership()
(In reply to Sven Gothel from comment #1) commit 18afa5200983bb158e631c81f2df1ca1a45cd882 Bug 1491: Add missing rename DefaultGraphicsDevice.swap{Device->}HandleAndOwnership()
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.
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.
See a demos w/ > 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