UnstableChanges

Summary

  1. Bug 1398: Importing Jani's native test, attempting to reproduce the crash using XCode 11 and JOGL 2.3.2 as well as current tip (details)
  2. Bug 1398: Fixing native test allowing its execution using JOGL 2.3.2 and latest tip using XCode 11 (details)
  3. Bug 1398: Refine test case: Make classpath and libpath runtime configurable + show JOGL version (details)
  4. Bug 1398: Crash only occurs @ -[NSOpenGLContext setView:] when using XCode 11 _and_ its default SDK 'macosx10.15' (details)
  5. Bug 1398: MacOS: Perform [NSOpenGLContext setView:] on main-thread async w/o blocking (details)
  6. IOSUtil.IsMainThread(): Utilize caching ThreadLocal<Boolean> like OSXUtil's variant. (details)
  7. TestSharedContextVBOES2*3: Properly validateBuffers and setSyncObjects(..) in concurrent async test case. (details)
  8. OSX/SWT Testing: Drop using 'com.jogamp.newt.util.MainThread' enforcing default test behavior (details)
  9. Bug 1398: Expose NativeSurface implementation's RecursiveLock if utilized (details)
  10. Bug 1398: Ensure CGLContext lock will be acquired before leaving user makeCurrent() call (details)
  11. Add missing SWTTestUtil, missed in commit 36ca7245653b1a0897f2070b9acbe0f0898f5949 (details)
Commit 4fad4869d4a929739c830f6ce3ac171d8dd5427a by Sven Gothel
Bug 1398: Importing Jani's native test, attempting to reproduce the crash using XCode 11 and JOGL 2.3.2 as well as current tip

This change imports 'jani@nexcus.com' patch as
reported and provided in Bug 1398.

I can not execute this patch properly,
as received a error message regarding missing Info.plist at start.
The file was addedsrc/test-native/bug1398/make-bug1398.sh
The file was addedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java
The file was addedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c
Commit f4f92cdc0eb89c62070a865601527097e6d5cc72 by Sven Gothel
Bug 1398: Fixing native test allowing its execution using JOGL 2.3.2 and latest tip using XCode 11

Changes to test
- Using own 'NSApplicationMain' entry to avoid the 'missing Info.plist' message!

- Configurable CLASSPATH and LIBPATH at compile time.
  Note that the java.library.path is now hardcoded as well.

- Don't close stderr in test, just fflush

- Don't close the JVM after launch via 'die(env)', let it run.

- Java: Add GLEventListener RedSquareES2 to see something in action @ 30fps

- Java: GLCanvase visible bounds
The file was addedsrc/test-native/bug1398/shader/RedSquareShader.vp
The file was addedsrc/test-native/bug1398/shader/RedSquareShader2.fp
The file was modifiedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java (diff)
The file was addedsrc/test-native/bug1398/shader/RedSquareShader.fp
The file was modifiedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c (diff)
The file was addedsrc/test-native/bug1398/test1398-jogamp240rc-01.log
The file was addedsrc/test-native/bug1398/run-bug1398.sh
The file was addedsrc/test-native/bug1398/RedSquareES2.java
The file was addedsrc/test-native/bug1398/test1398-jogamp232-01.log
The file was modifiedsrc/test-native/bug1398/make-bug1398.sh (diff)
Commit ff780fc11602fb79a7ce1dcf879fdaeb865b9fa8 by Sven Gothel
Bug 1398: Refine test case: Make classpath and libpath runtime configurable + show JOGL version
The file was modifiedsrc/test-native/bug1398/run-bug1398.sh (diff)
The file was modifiedsrc/test-native/bug1398/make-bug1398.sh (diff)
The file was removedsrc/test-native/bug1398/test1398-jogamp240rc-01.log
The file was addedsrc/test-native/bug1398/test1398-jogamp240rc_java08-01.log
The file was modifiedsrc/test-native/bug1398/RedSquareES2.java (diff)
The file was addedsrc/test-native/bug1398/test1398-jogamp232_java11-01.log
The file was addedsrc/test-native/bug1398/test1398-jogamp232_java08-01.log
The file was modifiedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java (diff)
The file was modifiedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c (diff)
The file was removedsrc/test-native/bug1398/test1398-jogamp232-01.log
Commit 78b96b89a68ff35969aea83de294cd3cc1178f26 by Sven Gothel
Bug 1398: Crash only occurs @ -[NSOpenGLContext setView:] when using XCode 11 _and_ its default SDK 'macosx10.15'

This patch demonstrates that using the SDK 'macosx10.11' does not cause the crash @ -[NSOpenGLContext setView:].

SDK 'macosx10.15' enforces Apple's own Cargo Cult of 'main-thread' by throwing a SIGILL signal (or SIGABRT)
- essentially an exception.

This surely renders our code officially invalid due to this policy,
i.e. we are not allowed to issue [* setView] on any non main-thread.

+++

The crash occurs independently of used Java version on Java 8 - 11,
as well as on JogAmp 2.3.2 - current master tip.

+++

The initial remedy to issue said action on the main-thread in a blocking/wait
manner has the risk to deadlock, due to

1) [NSOpenGLContext setView:] itself using a mutex (Thanks to Ken Harris's analysis)

and

(2) in case where we are 'thread hopping':
- [main-thread] Event like 'window ready' -> kick off action on EDT-thread *blocking*
- [EDT-thread] Create stuff incl OpenGLContext -> kick off setView on main-thread *blocking*

This has to be further investigated.

This crash finally has been reliably reproduced now.
The file was addedsrc/test-native/bug1398/log/hs_err_pid2328.log
The file was removedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.java
The file was addedsrc/test-native/bug1398/log/run-bug1398-sdk1011.log
The file was modifiedsrc/test-native/bug1398/run-bug1398.sh (diff)
The file was modifiedsrc/test-native/bug1398/make-bug1398.sh (diff)
The file was removedsrc/test-native/bug1398/Bug1398macOSContextOpsOnMainThread.c
The file was removedsrc/test-native/bug1398/test1398-jogamp240rc_java08-01.log
The file was removedsrc/test-native/bug1398/test1398-jogamp232_java08-01.log
The file was addedsrc/test-native/bug1398/log/run-bug1398-sdk1015.log
The file was addedsrc/test-native/bug1398/Bug1398MainClass.java
The file was addedsrc/test-native/bug1398/Bug1398Launcher.c
The file was removedsrc/test-native/bug1398/test1398-jogamp232_java11-01.log
Commit d1a4d790c89934616fa1883312b4064bda9fa420 by Sven Gothel
Bug 1398: MacOS: Perform [NSOpenGLContext setView:] on main-thread async w/o blocking

Set NSOpenGLContext's NSView via [NSOpenGLContext setView:]
on the main-thread as enforced since XCode 11 using SDL macosx10.15, using Runnable SetNSViewCmd.

This operation must be performed async w/o blocking to allow
other tasks locking the NativeSurface on main-thread to complete.

Further, since [NSOpenGLContext setView:] acquired the CGLContext lock,
it can't be locked until this task has been completed.

Worst case scenario for a late [NSOpenGLContext setView:] issuance
might be corrupt initial frame(s) displayed.

Since all concurrent locking is performed within JOGL,
the unlocked CGLContext window risk is only academic.
However, if native 3rd party toolkits take share control,
we might have a situation.

+++

SetNSViewCmd is issued @ makeCurrent() now as opposed to createContext(..)
and associateDrawable(true). The latter was actually late as well,
as it also happened after makeCurrent when updating the drawable
association. It also missed setting a null NSView when detached!

release() will also set a null NSView if called after associateDrawable(false).

SetNSViewCmd will only be issued if the NSView has been changed,
i.e. first makeCurrent() or changing the drawable.
If issued, makeCurrent() will not lock the underlying CGLContext
and hence allow SetNSViewCmd to perform - see above.

+++

NSViewDescriptor class structure replaces the less convenient method 'getNSViewHandle(..)',
exposing all collected drawable characteristics as fields.
NSViewDescriptor also respects a ProxySurface's OPT_UPSTREAM_SURFACELESS mode,
which results in not using any underlying NSView - similar to OPT_UPSTREAM_WINDOW_INVISIBLE.

This change ensures that all surfaceless GL operations will not use any NSView.
The file was modifiedsrc/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java (diff)
The file was modifiedmake/config/jogl/cgl-macosx-CustomJavaCode.java (diff)
The file was modifiedmake/config/jogl/cgl-macosx.cfg (diff)
The file was modifiedmake/scripts/tests.sh (diff)
The file was modifiedsrc/test-native/bug1398/Bug1398Launcher.c (diff)
The file was modifiedmake/stub_includes/opengl/macosx-window-system.h (diff)
The file was modifiedsrc/jogl/native/macosx/MacOSXWindowSystemInterface.m (diff)
Commit 0fc0b0d5da38bc3a73689b95626861ca9d70e5de by Sven Gothel
IOSUtil.IsMainThread(): Utilize caching ThreadLocal<Boolean> like OSXUtil's variant.
The file was modifiedsrc/nativewindow/classes/jogamp/nativewindow/ios/IOSUtil.java (diff)
Commit 8ccea1f0ff48a39e806839330ebeb5369bc0c79a by Sven Gothel
TestSharedContextVBOES2*3: Properly validateBuffers and setSyncObjects(..) in concurrent async test case.
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java (diff)
Commit 36ca7245653b1a0897f2070b9acbe0f0898f5949 by Sven Gothel
OSX/SWT Testing: Drop using 'com.jogamp.newt.util.MainThread' enforcing default test behavior

SWT and OSX's UI TK have their strict threading policy we require to comply with, e.g. see Bug 1398 lately.

It doesn't help using our own MainThread vehicle to move the unit test on the OS main thread,
as this removes potential causes of deadlocks - which we intend to find and resolve.

This patch removed using MainThread altogether from our ant unit testing recipe
as well from our manual test scripts.

Unit tests are no more executed on the 'main thread'.

SWT tests are patched to comply with SWT's UI threading policy.

We also catch violations within NewtCanvasSWT and our SWT GLCanvas
to provide same behavior on all platforms.
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java (diff)
The file was modifiedmake/scripts/tests.sh (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestGLCanvasSWTNewtCanvasSWTPosInTabs.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor01.java (diff)
The file was modifiedsrc/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java (diff)
The file was modifiedsrc/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java (diff)
The file was modifiedsrc/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java (diff)
The file was modifiedmake/build-test.xml (diff)
Commit 3e141416ea6c85c14dc622dae57f071d5fd0ff4f by Sven Gothel
Bug 1398: Expose NativeSurface implementation's RecursiveLock if utilized

This prepares proper release of the acquired NativeSurface lock to cure the missing CGLContext lock, see followup commit.
The file was modifiedsrc/newt/classes/jogamp/newt/WindowImpl.java (diff)
The file was modifiedsrc/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java (diff)
The file was modifiedsrc/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java (diff)
The file was modifiedsrc/newt/classes/com/jogamp/newt/opengl/GLWindow.java (diff)
The file was modifiedsrc/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java (diff)
The file was modifiedsrc/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java (diff)
Commit d88ca606f67e16c144b36f8fd1f188fdf8531ee0 by Sven Gothel
Bug 1398: Ensure CGLContext lock will be acquired before leaving user makeCurrent() call

Command SetNSViewCmd sets NSOpenGLContext's NSView via [NSOpenGLContext setView:]
on the main-thread as enforced since XCode 11 using SDK macosx10.15, see Bug 1398.

This command is injected into OSX's main-thread @ NSOpenGLImpl.makeCurrent(long) only if required,
i.e. issued only for a newly bound NSView and skipped for surface-less or offscreen 'surfaces'.

This operation must be performed w/o blocking other tasks locking the NativeSurface on main-thread to complete.

Since [NSOpenGLContext setView:] acquires the CGLContext lock on the main-thread,
it can't be locked by the calling thread until this task has been completed.
Command issuer NSOpenGLImpl.makeCurrent(long) will not acquire the CGLContext lock if this command is pending.

contextMadeCurrent(true) cures the potential unlocked CGLContext by issuing
a whole GLContext.release() and GLContext.makeCurrent() cycle while waiting for this command to be completed in-between.
This GLContext cycle also ensures an unlocked NativeSurface.getLock() in-between,
allowing potentially blocked other tasks on the main-thread to complete and hence this queued command to execute.

Notable test provoking critical multithreading issues is com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT.
Notable test exposing issues with an unlocked CGLContext is com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT.
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java (diff)
The file was modifiedmake/scripts/tests.sh (diff)
The file was modifiedsrc/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java (diff)
The file was modifiedsrc/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java (diff)
Commit 0779f229b0e9538c640b18b9a4e095af1f5a35b3 by Sven Gothel
Add missing SWTTestUtil, missed in commit 36ca7245653b1a0897f2070b9acbe0f0898f5949
The file was addedsrc/test/com/jogamp/opengl/test/junit/util/SWTTestUtil.java