Bug 540 - Mac Os X Instability - Crashes when disposing NEWT Window (.. and after Applet shutdown)
Summary: Mac Os X Instability - Crashes when disposing NEWT Window (.. and after Apple...
Alias: None
Product: Jogl
Classification: JogAmp
Component: macosx (show other bugs)
Version: 2
Hardware: pc_all macosx
: --- normal
Assignee: Sven Gothel
Depends on:
Reported: 2011-12-21 00:23 CET by Sven Gothel
Modified: 2012-01-20 11:41 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
8a2c18cf210ee6465e00f88cecd3ef109421ff1d 5d437df5dc6f73f8a5aad760e9aeba5b5319b436
Workaround: ---

OSX-Crash-DisposeNEWTWindow (13.15 KB, text/plain)
2011-12-21 00:23 CET, Sven Gothel

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2011-12-21 00:23:37 CET
Created attachment 304 [details]

In some test runs at ending the life of a NEWT Window (dispose) we experience:

  - Assertion failure in -[NSThemeFrame lockFocus], /SourceCache/AppKit/AppKit-1138.23/AppKit.subproj/NSView.m:6053

  - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[NSThemeFrame(0x119ae50) lockFocus] failed with window=0x1185d20, windowNumber=1568, [self isHiddenOrHasHiddenAncestor]=0'

See the attached log file w/ detailed exception/assertion-failures,
as they happened multiple times in the same unit test run.

I assume this has something to do w/ NEWT's NSWindow / NSView management,
where we remove the NSView from the NSWindow and release it explicitly
before actually releasing the NSWindow destruction.
See src/newt/native/MacWindow.m - Line 654

It would be great if another person can review our 'NSObject' lifecycle usage,
ie. retain/release/dealloc/..

This is also true for 
  CALayer Attachment: src/nativewindow/native/macosx/OSXmisc.m 
  NSOpenGLLayer: src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m

.. since Applets seem to cause an exception after shutdown sometimes as well.
Comment 1 Sven Gothel 2011-12-23 05:05:40 CET
NEWT/OSX MacWindow.close(): More conservative closing approach.

- Java: Set handle to null

- Native:
  - Don't release the NSView explicit, but rely on NSWindow's release

  - Don't use NSWindow close() but simply call release() instead.
    The latter doesn't produce a crash SIGSEGV on exit in some cases.
    OSX 10.7.2, NV GPU

jogl commit: 04707d3c1c628d6bf493d6916621d5e34dfefc30