ravidavi / OpenFrames

Realtime interactive scientific visualization API
Apache License 2.0
32 stars 14 forks source link

NSWindow drag regions should only be invalidated on the Main Thread! #5

Open jacobwilliams opened 1 year ago

jacobwilliams commented 1 year ago

On an Apple M1 Mac (MacOS Ventura 13.1, clang 14.0.0), I can't get the examples to work.

For example, when running ofcones I get:

2023-02-28 15:33:31.630 ofcones[56746:18375509] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001874fb3f8 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x0000000187046ea8 objc_exception_throw + 60
    2   CoreFoundation                      0x0000000187524810 _CFBundleGetValueForInfoKey + 0
    3   AppKit                              0x000000018a722a18 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 320
    4   AppKit                              0x000000018a711524 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 816
    5   AppKit                              0x000000018a7111e8 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
    6   libosgViewer.3.6.5.dylib            0x0000000102cfe1f0 _ZN9osgViewer19GraphicsWindowCocoa21realizeImplementationEv + 1120
    7   libosgViewer.3.6.5.dylib            0x0000000102ca64b8 _ZN9osgViewer15CompositeViewer7realizeEv + 908
    8   libosgViewer.3.6.5.dylib            0x0000000102cf1acc _ZN9osgViewer10ViewerBase5frameEd + 108
    9   libOpenFrames.dylib                 0x000000010259d9e0 _ZN10OpenFrames11WindowProxy5frameEv + 356
    10  libOpenFrames.dylib                 0x000000010259d84c _ZN10OpenFrames11WindowProxy3runEv + 312
    11  libOpenThreads.3.3.1.dylib          0x0000000102499acc _ZN11OpenThreads20ThreadPrivateActions11StartThreadEPv + 236
    12  libsystem_pthread.dylib             0x00000001873a106c _pthread_start + 148
    13  libsystem_pthread.dylib             0x000000018739be2c thread_start + 8
)
libc++abi: terminating with uncaught exception of type NSException
zsh: abort      ./ofcones

If I run ofqt_demo.py I get a similar error (-[NSOpenGLContext setView:] must be called from the main thread.)

I'm compiling it with the following script (using conda for all the dependencies):

#!/bin/bash

# version numbers of dev tools:
export PYTHON_VERSION=3.9
export OSG_VERSION=3.6.5
export CMAKE_VERSION=3.25
export SWIG_VERSION=4.0
export NUMPY_VERSION=1.24
export PYQT_VERSION=5.15
export NINJA_VERSION=1.11

# magic to make conda work:
eval "$(conda shell.bash hook)"

# set up directories:
rm -rf ./build 
mkdir ./build

# create the conda environment and activate it:
conda create --channel nodefaults --channel conda-forge --prefix ./build/osgenv --solver libmamba python=$PYTHON_VERSION openscenegraph=$OSG_VERSION cmake=$CMAKE_VERSION swig=$SWIG_VERSION numpy=$NUMPY_VERSION PYQT=$PYQT_VERSION ninja=$NINJA_VERSION
cd build
conda activate ./osgenv

# configure:
cmake -G Ninja \
      -D CMAKE_BUILD_TYPE=Release \
      -D OSG_DIR=./osgenv \
      -D OF_BUILD_DEMOS=ON \
      -D OF_PYTHON_MODULE=ON \
      -D SWIG_EXECUTABLE=./osgenv/bin/swig \
      ..

# build:
ninja
ninja install
ravidavi commented 1 year ago

This is expected on macOS 10.14+ (since 2018). It's only an issue if you use OpenFrames' built-in window manager (via OSG). It is not an issue if using your own window manager, e.g. wxWidgets, Qt, etc, since those do event handling in the main thread.

However, it should not be happening in the PyQt demo (ofqt_demo.py). I'll look into that.

jacobwilliams commented 1 year ago

Don't know if this helps, but here is the full script that can be used to reproduce the problem:

#!/bin/bash

# version numbers of dev tools:
export PYTHON_VERSION=3.9
export OSG_VERSION=3.6.5
export CMAKE_VERSION=3.25
export SWIG_VERSION=4.0
export NUMPY_VERSION=1.24
export PYQT_VERSION=5.15
export NINJA_VERSION=1.11

# magic to make conda work:
eval "$(conda shell.bash hook)"

# set up directories:
rm -rf ./build 
rm -rf ./install
mkdir ./build
mkdir ./install

# create the conda environment and activate it:
conda create --channel nodefaults --channel conda-forge --prefix ./build/osgenv --solver libmamba python=$PYTHON_VERSION openscenegraph=$OSG_VERSION cmake=$CMAKE_VERSION swig=$SWIG_VERSION numpy=$NUMPY_VERSION PYQT=$PYQT_VERSION ninja=$NINJA_VERSION
cd build
conda activate ./osgenv

# configure:
cmake -G Ninja \
      -D CMAKE_BUILD_TYPE=Release \
      -D CMAKE_INSTALL_PREFIX=`readlink -f ../install` \
      -D OSG_DIR=./osgenv \
      -D OF_BUILD_DEMOS=ON \
      -D OF_PYTHON_MODULE=ON \
      -D SWIG_EXECUTABLE=./osgenv/bin/swig \
      ..

# build:
ninja
ninja install

# set up paths for the shared libs
export DYLD_LIBRARY_PATH=$CONDA_DEFAULT_ENV/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=`readlink -f ../install/lib`:$DYLD_LIBRARY_PATH

# run an example:
cd ../install/bin
python ofqt_demo.py

(Note that you can delete the --solver libmamba part if you don't have the mamba solver installed, it will still work fine.)

The core dump I get is this:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               python3.9 [78065]
Path:                  /Users/USER/*/python
Identifier:            python3.9
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        zsh [69502]
Responsible:           Terminal [69500]
User ID:               501

Date/Time:             2023-03-02 05:57:10.1115 -0600
OS Version:            macOS 13.1 (22C65)
Report Version:        12
Anonymous UUID:        32495592-F84B-28AB-B0AD-8664A1EF3C70

Sleep/Wake UUID:       D06FA13C-AD6A-4EDB-9250-E90A82940779

Time Awake Since Boot: 940000 seconds
Time Since Wake:       1577 seconds

System Integrity Protection: enabled

Crashed Thread:        4

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x000000018a9b2158

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [78065]

Application Specific Information:
-[NSOpenGLContext setView:] must be called from the main thread.

Thread 0::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x1873627c8 __open + 8
1   libsystem_kernel.dylib                 0x18736d430 open + 64
2   Foundation                             0x18834fc2c _NSReadBytesFromFileWithExtendedAttributes + 152
3   Foundation                             0x18834faa8 -[NSData(NSData) initWithContentsOfFile:options:maxLength:error:] + 132
4   Foundation                             0x18835e1bc +[NSArray(NSArray) newWithContentsOf:immutable:] + 100
5   AppKit                                 0x18a8256e8 -[NSDocumentController(NSInternal) _autoreopenRecordsBeingReopened] + 72
6   AppKit                                 0x18a82568c -[NSDocumentController(NSInternal) _autoreopenDocumentsIgnoringExpendable:withCompletionHandler:] + 640
7   AppKit                                 0x18a705850 -[NSApplication _reopenWindowsAsNecessaryIncludingRestorableState:completionHandler:] + 220
8   AppKit                                 0x18a70564c -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 480
9   AppKit                                 0x18a705260 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 492
10  Foundation                             0x18835e9d8 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 316
11  Foundation                             0x18835e838 _NSAppleEventManagerGenericHandler + 80
12  AE                                     0x18d7ca874 0x18d7bf000 + 47220
13  AE                                     0x18d7ca1a0 0x18d7bf000 + 45472
14  AE                                     0x18d7c3240 aeProcessAppleEvent + 488
15  HIToolbox                              0x190b6550c AEProcessAppleEvent + 68
16  AppKit                                 0x18a700730 _DPSNextEvent + 1412
17  AppKit                                 0x18a6ff5b4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
18  libqcocoa.dylib                        0x107fd8844 0x107fac000 + 182340
19  python3.9                              0x1045303f8 cfunction_call + 80
20  python3.9                              0x1044e13c4 _PyObject_MakeTpCall + 616
21  python3.9                              0x1045d1464 call_function + 668
22  python3.9                              0x1045cdbcc _PyEval_EvalFrameDefault + 26332
23  python3.9                              0x1044e20a0 function_code_fastcall + 116
24  python3.9                              0x1044e4f24 method_vectorcall + 516
25  sip.cpython-39-darwin.so               0x104c96b34 sip_api_call_procedure_method + 116
26  QtGui.abi3.so                          0x10714c5d0 sipVH_QtGui_41(PyGILState_STATE, void (*)(_sipSimpleWrapper*, PyGILState_STATE), _sipSimpleWrapper*, _object*, QExposeEvent*) + 56
27  QtGui.abi3.so                          0x1071e13d4 sipQWindow::exposeEvent(QExposeEvent*) + 120
28  libQt5Gui.5.15.8.dylib                 0x105b4e7fc QWindow::event(QEvent*) + 584
29  libQt5Widgets.5.15.8.dylib             0x1056f0104 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 232
30  libQt5Core.5.15.8.dylib                0x105fe071c QCoreApplication::notifyInternal2(QObject*, QEvent*) + 176
31  AppKit                                 0x18a7aacb4 -[_NSViewBackingLayer display] + 532
32  QuartzCore                             0x18eb29e88 CA::Layer::display_if_needed(CA::Transaction*) + 788
33  QuartzCore                             0x18ec8e2d8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 456
34  QuartzCore                             0x18eb0c404 CA::Transaction::commit() + 652
35  AppKit                                 0x18a828d58 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 272
36  AppKit                                 0x18af06ce0 ___NSRunLoopObserverCreateWithHandler_block_invoke + 64
37  CoreFoundation                         0x18747fdc8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
38  CoreFoundation                         0x18747fcb4 __CFRunLoopDoObservers + 532
39  CoreFoundation                         0x18747f2ec __CFRunLoopRun + 784
40  CoreFoundation                         0x18747e888 CFRunLoopRunSpecific + 612
41  HIToolbox                              0x190b53fa0 RunCurrentEventLoopInMode + 292
42  HIToolbox                              0x190b53c30 ReceiveNextEventCommon + 236
43  HIToolbox                              0x190b53b2c _BlockUntilNextEventMatchingListInModeWithFilter + 72
44  AppKit                                 0x18a700424 _DPSNextEvent + 632
45  AppKit                                 0x18a6ff5b4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
46  AppKit                                 0x18a6f39e4 -[NSApplication run] + 464
47  libqcocoa.dylib                        0x107fd8a64 0x107fac000 + 182884
48  python3.9                              0x104530478 cfunction_call + 208
49  python3.9                              0x1044e13c4 _PyObject_MakeTpCall + 616
50  python3.9                              0x1045d1464 call_function + 668
51  python3.9                              0x1045cdbcc _PyEval_EvalFrameDefault + 26332
52  python3.9                              0x1045c6e98 _PyEval_EvalCode + 2804
53  python3.9                              0x104620bdc run_mod + 216
54  python3.9                              0x10461e728 pyrun_file + 264
55  python3.9                              0x10461df50 PyRun_SimpleFileExFlags + 1332
56  python3.9                              0x1046408c0 Py_RunMain + 2148
57  python3.9                              0x104641a40 pymain_main + 1252
58  python3.9                              0x104494770 main + 56
59  dyld                                   0x187077e50 start + 2544

Thread 1:
0   libsystem_pthread.dylib                0x18739be18 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib                0x18739be18 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib                0x18739be18 start_wqthread + 0

Thread 4 Crashed:
0   AppKit                                 0x18a9b2158 -[NSOpenGLContext setView:] + 212
1   AppKit                                 0x18a9b2158 -[NSOpenGLContext setView:] + 212
2   libqcocoa.dylib                        0x107fedf00 0x107fac000 + 270080
3   python3.9                              0x104530478 cfunction_call + 208
4   python3.9                              0x1044e13c4 _PyObject_MakeTpCall + 616
5   python3.9                              0x1045d1464 call_function + 668
6   python3.9                              0x1045cdbcc _PyEval_EvalFrameDefault + 26332
7   python3.9                              0x1044e20a0 function_code_fastcall + 116
8   python3.9                              0x1044e3490 object_vacall + 272
9   python3.9                              0x1044e32b8 PyObject_CallMethodObjArgs + 108
10  _PyOF.so                               0x106e169f8 SwigDirector_GraphicsContextCallback::makeCurrent() + 76
11  libOpenFrames.dylib                    0x106a5d7bc OpenFrames::EmbeddedGraphics::makeCurrentImplementation() + 40
12  libosg.3.6.5.dylib                     0x107798200 osg::GraphicsContext::makeCurrent() + 40
13  libosgViewer.3.6.5.dylib               0x1079de4dc osgViewer::CompositeViewer::realize() + 944
14  libosgViewer.3.6.5.dylib               0x107a29acc osgViewer::ViewerBase::frame(double) + 108
15  libOpenFrames.dylib                    0x106a619e0 OpenFrames::WindowProxy::frame() + 356
16  libOpenFrames.dylib                    0x106a6184c OpenFrames::WindowProxy::run() + 312
17  libOpenThreads.3.3.1.dylib             0x104bf1acc OpenThreads::ThreadPrivateActions::StartThread(void*) + 236
18  libsystem_pthread.dylib                0x1873a106c _pthread_start + 148
19  libsystem_pthread.dylib                0x18739be2c thread_start + 8

Thread 4 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x5d4324cdb7380071   x9: 0x5d4324cdb7380071  x10: 0x000000000000002c  x11: 0x0000000000000001
   x12: 0x000000016bb9a502  x13: 0x0000000000000000  x14: 0x00000001047b77ce  x15: 0x00000001080bdd58
   x16: 0xfffffffffffffff4  x17: 0x00000001e7549360  x18: 0x0000000000000000  x19: 0x0000600000da90a0
   x20: 0x000000011ae9f680  x21: 0x00000001d747c328  x22: 0x000000011ae9f680  x23: 0x0000000000000000
   x24: 0x0000000000000001  x25: 0x0000000104b41a38  x26: 0x0000000104b41a30  x27: 0x00000001045303a8
   x28: 0x0000000000000001   fp: 0x000000016bb9a750   lr: 0xba1000018a9b2158
    sp: 0x000000016bb9a700   pc: 0x000000018a9b2158 cpsr: 0x60001000
   far: 0x0000000118ae4000  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x187361000 -        0x187399ff3 libsystem_kernel.dylib (*) <aebf397e-e2ef-3a49-be58-23d4558511f6> /usr/lib/system/libsystem_kernel.dylib
       0x18832b000 -        0x188d63fff com.apple.Foundation (6.9) <f1f5f857-8c3c-36d5-bc27-7702d6795468> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
       0x18a6c7000 -        0x18b5d1fff com.apple.AppKit (6.9) <dbbd4dea-6c68-3200-a81b-79b6a62f4669> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x18d7bf000 -        0x18d831ff3 com.apple.AE (946) <2370b854-34d9-3e85-8ea6-c5e2c032d47e> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
       0x190b22000 -        0x190e55fff com.apple.HIToolbox (2.1.1) <f1e0f4f6-dd7b-3d16-a622-5ee94a20fcaa> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
       0x107fac000 -        0x1080a7fff libqcocoa.dylib (*) <271a6c0c-dd22-3807-96e6-aceb0b152a33> /Users/USER/*/libqcocoa.dylib
       0x104490000 -        0x104753fff python3.9 (*) <6411e155-c8c9-3449-b234-255d791c8a20> /Users/USER/*/python3.9
       0x104c8c000 -        0x104ca3fff sip.cpython-39-darwin.so (*) <187abe78-9010-3ed1-8fba-cc1806324361> /Users/USER/*/sip.cpython-39-darwin.so
       0x107144000 -        0x1072f3fff QtGui.abi3.so (*) <f1da1ddf-1dbf-33c0-a70c-4b3b3d407834> /Users/USER/*/QtGui.abi3.so
       0x105b28000 -        0x105d97fff libQt5Gui.5.15.8.dylib (*) <a742ecbe-93bf-3e0f-ac80-b21f6df0530d> /Users/USER/*/libQt5Gui.5.15.8.dylib
       0x1056e4000 -        0x1059affff libQt5Widgets.5.15.8.dylib (*) <e7359903-e88c-32a4-8571-03129fe25b71> /Users/USER/*/libQt5Widgets.5.15.8.dylib
       0x105eb8000 -        0x10625bfff libQt5Core.5.15.8.dylib (*) <e0bb6926-59d2-3e08-80a7-c092ca057d67> /Users/USER/*/libQt5Core.5.15.8.dylib
       0x18eb0a000 -        0x18ee6efff com.apple.QuartzCore (1.11) <8ccb450e-ab2b-3fce-931e-70986187d2e0> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
       0x1873ff000 -        0x1878d6fff com.apple.CoreFoundation (6.9) <fd16d6d9-10c0-323b-b43b-9781c4a4d268> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x187072000 -        0x1870fcb63 dyld (*) <487cfdeb-9b07-39bf-bfb9-970b61aea2d1> /usr/lib/dyld
       0x18739a000 -        0x1873a6ffb libsystem_pthread.dylib (*) <132084c6-c347-3489-9ac2-fcaad21cdb73> /usr/lib/system/libsystem_pthread.dylib
       0x106e10000 -        0x106efffff _PyOF.so (*) <73438b31-88ef-3119-bdb1-3d992f8e93c3> /Users/USER/*/_PyOF.so
       0x106a10000 -        0x106a73fff libOpenFrames.dylib (*) <43a5c993-1764-3438-81e9-a69386c64344> /Users/USER/*/libOpenFrames.dylib
       0x107720000 -        0x1078dbfff libosg.3.6.5.dylib (*) <1ffaf8a0-dd03-32a3-944a-0ab3178fd1be> /Users/USER/*/libosg.3.6.5.dylib
       0x1079c8000 -        0x107a53fff libosgViewer.3.6.5.dylib (*) <a9d2c6ad-f9a8-3798-97ff-e059ef9562a9> /Users/USER/*/libosgViewer.3.6.5.dylib
       0x104bec000 -        0x104bf3fff libOpenThreads.3.3.1.dylib (*) <9a964b2f-8733-3bb7-9a35-5d003a069563> /Users/USER/*/libOpenThreads.3.3.1.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=1.0G resident=0K(0%) swapped_out_or_unallocated=1.0G(100%)
Writable regions: Total=1.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.1G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               128K        1 
Activity Tracing                   256K        1 
CG image                            48K        2 
ColorSync                          512K       25 
CoreGraphics                        16K        1 
CoreUI image data                  240K        2 
Foundation                          16K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           228.3M       39 
MALLOC guard page                  192K       10 
MALLOC_MEDIUM (reserved)         480.0M        4         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                         80K        5 
Stack                             18.1M        5 
VM_ALLOCATE                       6240K       30 
__AUTH                             651K      166 
__AUTH_CONST                      11.3M      323 
__CTF                               756        1 
__DATA                            5132K      357 
__DATA_CONST                      16.6M      366 
__DATA_DIRTY                       718K      110 
__FONT_DATA                        2352        1 
__GLSLBUILTINS                    5174K        1 
__LINKEDIT                       780.8M       45 
__OBJC_CONST                      1346K      139 
__OBJC_RO                         65.4M        1 
__OBJC_RW                         1986K        1 
__TEXT                           285.8M      382 
dyld private memory                256K        1 
mapped file                       81.7M       27 
shared memory                      864K       15 
===========                     =======  ======= 
TOTAL                              2.3G     2064 
TOTAL, minus reserved VM space     1.5G     2064 

-----------
Full Report
-----------

{"app_name":"python3.9","timestamp":"2023-03-02 05:57:10.00 -0600","app_version":"","slice_uuid":"6411e155-c8c9-3449-b234-255d791c8a20","build_version":"","platform":1,"share_with_app_devs":0,"is_first_party":1,"bug_type":"309","os_version":"macOS 13.1 (22C65)","roots_installed":0,"incident_id":"D0726126-4901-4CB5-AB0A-50D68D4B7955","name":"python3.9"}
{
  "uptime" : 940000,
  "procRole" : "Background",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro17,1",
  "coalitionID" : 129920,
  "osVersion" : {
    "train" : "macOS 13.1",
    "build" : "22C65",
    "releaseType" : "User"
  },
  "captureTime" : "2023-03-02 05:57:10.1115 -0600",
  "incident" : "D0726126-4901-4CB5-AB0A-50D68D4B7955",
  "pid" : 78065,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-03-02 05:57:09.0888 -0600",
  "procStartAbsTime" : 22743216677500,
  "procExitAbsTime" : 22743241195831,
  "procName" : "python3.9",
  "procPath" : "\/Users\/USER\/*\/python",
  "parentProc" : "zsh",
  "parentPid" : 69502,
  "coalitionName" : "com.apple.Terminal",
  "crashReporterKey" : "32495592-F84B-28AB-B0AD-8664A1EF3C70",
  "responsiblePid" : 69500,
  "responsibleProc" : "Terminal",
  "wakeTime" : 1577,
  "sleepWakeUUID" : "D06FA13C-AD6A-4EDB-9250-E90A82940779",
  "sip" : "enabled",
  "exception" : {"codes":"0x0000000000000001, 0x000000018a9b2158","rawCodes":[1,6620389720],"type":"EXC_BREAKPOINT","signal":"SIGTRAP"},
  "termination" : {"flags":0,"code":5,"namespace":"SIGNAL","indicator":"Trace\/BPT trap: 5","byProc":"exc handler","byPid":78065},
  "os_fault" : {"process":"python3.9"},
  "asi" : {"libsystem_c.dylib":["-[NSOpenGLContext setView:] must be called from the main thread."]},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 4,
  "threads" : [{"id":18595498,"queue":"com.apple.main-thread","frames":[{"imageOffset":6088,"symbol":"__open","symbolLocation":8,"imageIndex":0},{"imageOffset":50224,"symbol":"open","symbolLocation":64,"imageIndex":0},{"imageOffset":150572,"symbol":"_NSReadBytesFromFileWithExtendedAttributes","symbolLocation":152,"imageIndex":1},{"imageOffset":150184,"symbol":"-[NSData(NSData) initWithContentsOfFile:options:maxLength:error:]","symbolLocation":132,"imageIndex":1},{"imageOffset":209340,"symbol":"+[NSArray(NSArray) newWithContentsOf:immutable:]","symbolLocation":100,"imageIndex":1},{"imageOffset":1435368,"symbol":"-[NSDocumentController(NSInternal) _autoreopenRecordsBeingReopened]","symbolLocation":72,"imageIndex":2},{"imageOffset":1435276,"symbol":"-[NSDocumentController(NSInternal) _autoreopenDocumentsIgnoringExpendable:withCompletionHandler:]","symbolLocation":640,"imageIndex":2},{"imageOffset":256080,"symbol":"-[NSApplication _reopenWindowsAsNecessaryIncludingRestorableState:completionHandler:]","symbolLocation":220,"imageIndex":2},{"imageOffset":255564,"symbol":"-[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:]","symbolLocation":480,"imageIndex":2},{"imageOffset":254560,"symbol":"-[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]","symbolLocation":492,"imageIndex":2},{"imageOffset":211416,"symbol":"-[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]","symbolLocation":316,"imageIndex":1},{"imageOffset":211000,"symbol":"_NSAppleEventManagerGenericHandler","symbolLocation":80,"imageIndex":1},{"imageOffset":47220,"imageIndex":3},{"imageOffset":45472,"imageIndex":3},{"imageOffset":16960,"symbol":"aeProcessAppleEvent","symbolLocation":488,"imageIndex":3},{"imageOffset":275724,"symbol":"AEProcessAppleEvent","symbolLocation":68,"imageIndex":4},{"imageOffset":235312,"symbol":"_DPSNextEvent","symbolLocation":1412,"imageIndex":2},{"imageOffset":230836,"symbol":"-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]","symbolLocation":728,"imageIndex":2},{"imageOffset":182340,"imageIndex":5},{"imageOffset":656376,"symbol":"cfunction_call","symbolLocation":80,"imageIndex":6},{"imageOffset":332740,"symbol":"_PyObject_MakeTpCall","symbolLocation":616,"imageIndex":6},{"imageOffset":1315940,"symbol":"call_function","symbolLocation":668,"imageIndex":6},{"imageOffset":1301452,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":26332,"imageIndex":6},{"imageOffset":336032,"symbol":"function_code_fastcall","symbolLocation":116,"imageIndex":6},{"imageOffset":347940,"symbol":"method_vectorcall","symbolLocation":516,"imageIndex":6},{"imageOffset":43828,"symbol":"sip_api_call_procedure_method","symbolLocation":116,"imageIndex":7},{"imageOffset":34256,"symbol":"sipVH_QtGui_41(PyGILState_STATE, void (*)(_sipSimpleWrapper*, PyGILState_STATE), _sipSimpleWrapper*, _object*, QExposeEvent*)","symbolLocation":56,"imageIndex":8},{"imageOffset":644052,"symbol":"sipQWindow::exposeEvent(QExposeEvent*)","symbolLocation":120,"imageIndex":8},{"imageOffset":157692,"symbol":"QWindow::event(QEvent*)","symbolLocation":584,"imageIndex":9},{"imageOffset":49412,"symbol":"QApplicationPrivate::notify_helper(QObject*, QEvent*)","symbolLocation":232,"imageIndex":10},{"imageOffset":1214236,"symbol":"QCoreApplication::notifyInternal2(QObject*, QEvent*)","symbolLocation":176,"imageIndex":11},{"imageOffset":933044,"symbol":"-[_NSViewBackingLayer display]","symbolLocation":532,"imageIndex":2},{"imageOffset":130696,"symbol":"CA::Layer::display_if_needed(CA::Transaction*)","symbolLocation":788,"imageIndex":12},{"imageOffset":1589976,"symbol":"CA::Context::commit_transaction(CA::Transaction*, double, double*)","symbolLocation":456,"imageIndex":12},{"imageOffset":9220,"symbol":"CA::Transaction::commit()","symbolLocation":652,"imageIndex":12},{"imageOffset":1449304,"symbol":"__62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke","symbolLocation":272,"imageIndex":2},{"imageOffset":8649952,"symbol":"___NSRunLoopObserverCreateWithHandler_block_invoke","symbolLocation":64,"imageIndex":2},{"imageOffset":527816,"symbol":"__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__","symbolLocation":36,"imageIndex":13},{"imageOffset":527540,"symbol":"__CFRunLoopDoObservers","symbolLocation":532,"imageIndex":13},{"imageOffset":525036,"symbol":"__CFRunLoopRun","symbolLocation":784,"imageIndex":13},{"imageOffset":522376,"symbol":"CFRunLoopRunSpecific","symbolLocation":612,"imageIndex":13},{"imageOffset":204704,"symbol":"RunCurrentEventLoopInMode","symbolLocation":292,"imageIndex":4},{"imageOffset":203824,"symbol":"ReceiveNextEventCommon","symbolLocation":236,"imageIndex":4},{"imageOffset":203564,"symbol":"_BlockUntilNextEventMatchingListInModeWithFilter","symbolLocation":72,"imageIndex":4},{"imageOffset":234532,"symbol":"_DPSNextEvent","symbolLocation":632,"imageIndex":2},{"imageOffset":230836,"symbol":"-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]","symbolLocation":728,"imageIndex":2},{"imageOffset":182756,"symbol":"-[NSApplication run]","symbolLocation":464,"imageIndex":2},{"imageOffset":182884,"imageIndex":5},{"imageOffset":656504,"symbol":"cfunction_call","symbolLocation":208,"imageIndex":6},{"imageOffset":332740,"symbol":"_PyObject_MakeTpCall","symbolLocation":616,"imageIndex":6},{"imageOffset":1315940,"symbol":"call_function","symbolLocation":668,"imageIndex":6},{"imageOffset":1301452,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":26332,"imageIndex":6},{"imageOffset":1273496,"symbol":"_PyEval_EvalCode","symbolLocation":2804,"imageIndex":6},{"imageOffset":1641436,"symbol":"run_mod","symbolLocation":216,"imageIndex":6},{"imageOffset":1632040,"symbol":"pyrun_file","symbolLocation":264,"imageIndex":6},{"imageOffset":1630032,"symbol":"PyRun_SimpleFileExFlags","symbolLocation":1332,"imageIndex":6},{"imageOffset":1771712,"symbol":"Py_RunMain","symbolLocation":2148,"imageIndex":6},{"imageOffset":1776192,"symbol":"pymain_main","symbolLocation":1252,"imageIndex":6},{"imageOffset":18288,"symbol":"main","symbolLocation":56,"imageIndex":6},{"imageOffset":24144,"symbol":"start","symbolLocation":2544,"imageIndex":14}]},{"id":18595510,"frames":[{"imageOffset":7704,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":15}]},{"id":18595511,"frames":[{"imageOffset":7704,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":15}]},{"id":18595537,"frames":[{"imageOffset":7704,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":15}]},{"triggered":true,"id":18595538,"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":6720255534927708273},{"value":6720255534927708273},{"value":44},{"value":1},{"value":6102295810},{"value":0},{"value":4370167758},{"value":4429962584},{"value":18446744073709551604},{"value":8176046944},{"value":0},{"value":105553130590368},{"value":4746507904},{"value":7906771752,"objc-selector":"view"},{"value":4746507904},{"value":0},{"value":1},{"value":4373879352},{"value":4373879344},{"value":4367516584,"symbolLocation":0,"symbol":"cfunction_call"},{"value":1}],"flavor":"ARM_THREAD_STATE64","lr":{"value":13407216097302356312},"cpsr":{"value":1610616832},"fp":{"value":6102296400},"sp":{"value":6102296320},"esr":{"value":4060086273,"description":"(Breakpoint) brk 1"},"pc":{"value":6620389720,"matchesCrashFrame":1},"far":{"value":4709040128}},"frames":[{"imageOffset":3060056,"symbol":"-[NSOpenGLContext setView:]","symbolLocation":212,"imageIndex":2},{"imageOffset":3060056,"symbol":"-[NSOpenGLContext setView:]","symbolLocation":212,"imageIndex":2},{"imageOffset":270080,"imageIndex":5},{"imageOffset":656504,"symbol":"cfunction_call","symbolLocation":208,"imageIndex":6},{"imageOffset":332740,"symbol":"_PyObject_MakeTpCall","symbolLocation":616,"imageIndex":6},{"imageOffset":1315940,"symbol":"call_function","symbolLocation":668,"imageIndex":6},{"imageOffset":1301452,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":26332,"imageIndex":6},{"imageOffset":336032,"symbol":"function_code_fastcall","symbolLocation":116,"imageIndex":6},{"imageOffset":341136,"symbol":"object_vacall","symbolLocation":272,"imageIndex":6},{"imageOffset":340664,"symbol":"PyObject_CallMethodObjArgs","symbolLocation":108,"imageIndex":6},{"imageOffset":27128,"symbol":"SwigDirector_GraphicsContextCallback::makeCurrent()","symbolLocation":76,"imageIndex":16},{"imageOffset":317372,"symbol":"OpenFrames::EmbeddedGraphics::makeCurrentImplementation()","symbolLocation":40,"imageIndex":17},{"imageOffset":492032,"symbol":"osg::GraphicsContext::makeCurrent()","symbolLocation":40,"imageIndex":18},{"imageOffset":91356,"symbol":"osgViewer::CompositeViewer::realize()","symbolLocation":944,"imageIndex":19},{"imageOffset":400076,"symbol":"osgViewer::ViewerBase::frame(double)","symbolLocation":108,"imageIndex":19},{"imageOffset":334304,"symbol":"OpenFrames::WindowProxy::frame()","symbolLocation":356,"imageIndex":17},{"imageOffset":333900,"symbol":"OpenFrames::WindowProxy::run()","symbolLocation":312,"imageIndex":17},{"imageOffset":23244,"symbol":"OpenThreads::ThreadPrivateActions::StartThread(void*)","symbolLocation":236,"imageIndex":20},{"imageOffset":28780,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":15},{"imageOffset":7724,"symbol":"thread_start","symbolLocation":8,"imageIndex":15}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6563434496,
    "size" : 233460,
    "uuid" : "aebf397e-e2ef-3a49-be58-23d4558511f6",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6579990528,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.Foundation",
    "size" : 10719232,
    "uuid" : "f1f5f857-8c3c-36d5-bc27-7702d6795468",
    "path" : "\/System\/Library\/Frameworks\/Foundation.framework\/Versions\/C\/Foundation",
    "name" : "Foundation",
    "CFBundleVersion" : "1953.300"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6617329664,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.AppKit",
    "size" : 15773696,
    "uuid" : "dbbd4dea-6c68-3200-a81b-79b6a62f4669",
    "path" : "\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/AppKit",
    "name" : "AppKit",
    "CFBundleVersion" : "2299.30.116"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6668677120,
    "CFBundleShortVersionString" : "946",
    "CFBundleIdentifier" : "com.apple.AE",
    "size" : 471028,
    "uuid" : "2370b854-34d9-3e85-8ea6-c5e2c032d47e",
    "path" : "\/System\/Library\/Frameworks\/CoreServices.framework\/Versions\/A\/Frameworks\/AE.framework\/Versions\/A\/AE",
    "name" : "AE",
    "CFBundleVersion" : "946"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6722560000,
    "CFBundleShortVersionString" : "2.1.1",
    "CFBundleIdentifier" : "com.apple.HIToolbox",
    "size" : 3358720,
    "uuid" : "f1e0f4f6-dd7b-3d16-a622-5ee94a20fcaa",
    "path" : "\/System\/Library\/Frameworks\/Carbon.framework\/Versions\/A\/Frameworks\/HIToolbox.framework\/Versions\/A\/HIToolbox",
    "name" : "HIToolbox"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4428840960,
    "size" : 1032192,
    "uuid" : "271a6c0c-dd22-3807-96e6-aceb0b152a33",
    "path" : "\/Users\/USER\/*\/libqcocoa.dylib",
    "name" : "libqcocoa.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4366860288,
    "size" : 2899968,
    "uuid" : "6411e155-c8c9-3449-b234-255d791c8a20",
    "path" : "\/Users\/USER\/*\/python3.9",
    "name" : "python3.9"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4375232512,
    "size" : 98304,
    "uuid" : "187abe78-9010-3ed1-8fba-cc1806324361",
    "path" : "\/Users\/USER\/*\/sip.cpython-39-darwin.so",
    "name" : "sip.cpython-39-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4413734912,
    "size" : 1769472,
    "uuid" : "f1da1ddf-1dbf-33c0-a70c-4b3b3d407834",
    "path" : "\/Users\/USER\/*\/QtGui.abi3.so",
    "name" : "QtGui.abi3.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4390551552,
    "size" : 2555904,
    "uuid" : "a742ecbe-93bf-3e0f-ac80-b21f6df0530d",
    "path" : "\/Users\/USER\/*\/libQt5Gui.5.15.8.dylib",
    "name" : "libQt5Gui.5.15.8.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4386078720,
    "size" : 2932736,
    "uuid" : "e7359903-e88c-32a4-8571-03129fe25b71",
    "path" : "\/Users\/USER\/*\/libQt5Widgets.5.15.8.dylib",
    "name" : "libQt5Widgets.5.15.8.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4394287104,
    "size" : 3817472,
    "uuid" : "e0bb6926-59d2-3e08-80a7-c092ca057d67",
    "path" : "\/Users\/USER\/*\/libQt5Core.5.15.8.dylib",
    "name" : "libQt5Core.5.15.8.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6688907264,
    "CFBundleShortVersionString" : "1.11",
    "CFBundleIdentifier" : "com.apple.QuartzCore",
    "size" : 3559424,
    "uuid" : "8ccb450e-ab2b-3fce-931e-70986187d2e0",
    "path" : "\/System\/Library\/Frameworks\/QuartzCore.framework\/Versions\/A\/QuartzCore",
    "name" : "QuartzCore",
    "CFBundleVersion" : "1042.24.1"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6564081664,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 5079040,
    "uuid" : "fd16d6d9-10c0-323b-b43b-9781c4a4d268",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "1953.300"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6560358400,
    "size" : 568164,
    "uuid" : "487cfdeb-9b07-39bf-bfb9-970b61aea2d1",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6563667968,
    "size" : 53244,
    "uuid" : "132084c6-c347-3489-9ac2-fcaad21cdb73",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4410376192,
    "size" : 983040,
    "uuid" : "73438b31-88ef-3119-bdb1-3d992f8e93c3",
    "path" : "\/Users\/USER\/*\/_PyOF.so",
    "name" : "_PyOF.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4406181888,
    "size" : 409600,
    "uuid" : "43a5c993-1764-3438-81e9-a69386c64344",
    "path" : "\/Users\/USER\/*\/libOpenFrames.dylib",
    "name" : "libOpenFrames.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4419878912,
    "size" : 1818624,
    "uuid" : "1ffaf8a0-dd03-32a3-944a-0ab3178fd1be",
    "path" : "\/Users\/USER\/*\/libosg.3.6.5.dylib",
    "name" : "libosg.3.6.5.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4422664192,
    "size" : 573440,
    "uuid" : "a9d2c6ad-f9a8-3798-97ff-e059ef9562a9",
    "path" : "\/Users\/USER\/*\/libosgViewer.3.6.5.dylib",
    "name" : "libosgViewer.3.6.5.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4374577152,
    "size" : 32768,
    "uuid" : "9a964b2f-8733-3bb7-9a35-5d003a069563",
    "path" : "\/Users\/USER\/*\/libOpenThreads.3.3.1.dylib",
    "name" : "libOpenThreads.3.3.1.dylib"
  }
],
  "sharedCache" : {
  "base" : 6559711232,
  "size" : 3434283008,
  "uuid" : "00a1fbb6-43e1-3c11-8483-faf0db659249"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=1.0G resident=0K(0%) swapped_out_or_unallocated=1.0G(100%)\nWritable regions: Total=1.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.1G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nAccelerate framework               128K        1 \nActivity Tracing                   256K        1 \nCG image                            48K        2 \nColorSync                          512K       25 \nCoreGraphics                        16K        1 \nCoreUI image data                  240K        2 \nFoundation                          16K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           228.3M       39 \nMALLOC guard page                  192K       10 \nMALLOC_MEDIUM (reserved)         480.0M        4         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                         80K        5 \nStack                             18.1M        5 \nVM_ALLOCATE                       6240K       30 \n__AUTH                             651K      166 \n__AUTH_CONST                      11.3M      323 \n__CTF                               756        1 \n__DATA                            5132K      357 \n__DATA_CONST                      16.6M      366 \n__DATA_DIRTY                       718K      110 \n__FONT_DATA                        2352        1 \n__GLSLBUILTINS                    5174K        1 \n__LINKEDIT                       780.8M       45 \n__OBJC_CONST                      1346K      139 \n__OBJC_RO                         65.4M        1 \n__OBJC_RW                         1986K        1 \n__TEXT                           285.8M      382 \ndyld private memory                256K        1 \nmapped file                       81.7M       27 \nshared memory                      864K       15 \n===========                     =======  ======= \nTOTAL                              2.3G     2064 \nTOTAL, minus reserved VM space     1.5G     2064 \n",
  "legacyInfo" : {
  "threadTriggered" : {

  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "5fb4245a1bbfe8005e33a1e1",
      "factorPackIds" : {

      },
      "deploymentId" : 240000021
    },
    {
      "rolloutId" : "62699e1ec1ff2978b47f6c3b",
      "factorPackIds" : {
        "SIRI_FIND_MY_CONFIGURATION_FILES" : "631f72d1de559130376df1fb"
      },
      "deploymentId" : 240000023
    }
  ],
  "experiments" : [

  ]
}
}

Also note that I'm getting these warnings at runtime:

swig/python detected a memory leak of type 'OpenFrames::CoordinateAxes *', no destructor found.
swig/python detected a memory leak of type 'OpenFrames::FrameManager *', no destructor found.
swig/python detected a memory leak of type 'OpenFrames::Sphere *', no destructor found.
swig/python detected a memory leak of type 'OpenFrames::FrameManager *', no destructor found.

This is all with the latest develop commit (67cce87f1ccd23df91d6d070d86c06ceb180dadb).

jacobwilliams commented 11 months ago

Looks like this same issue has affected other OpenGL applications:

Examples:

Seems to have been caused by something apple changed (maybe in macOS 10.15 or so?)

jacobwilliams commented 3 months ago

See this: https://gitlab.com/EmergentSpaceTechnologies/OpenFramesInterface/-/commit/e53f2dabb04bb069d69b85415fd79ef748d217b7

Can we do a similar thing when using from Python?