Open GoogleCodeExporter opened 9 years ago
I think I figured out what was causing the segfault.
In the cocoa `run` code, a `self.pool` is created and drained. However, the
last pool created never gets drained, even after `self.stop` is called. This is
dangerous -- I was running Pyglet code alongside some GLFW code, and GLFW must
also go through Cocoa -- at one point GLFW polled for events, and this caused a
segfault presumably because Cocoa tried to access the old pool, which had been
garbage collected by Python.
This fixes the segfault:
https://code.google.com/r/larsonericd-clone/source/detail?r=c84337d5292a469571bd
50e33302c7a231a9fb91
I'm not 100% sure this is the right fix. For example, if one calls `start()`
followed by `stop()` and then `start()` again, `start()` will not create a
pool. This makes me wonder if `self.pool` should be initialized in `start()`
instead of `__init__`. In any case, I'm pretty sure `stop` needs to clear
`self.pool` to avoid leaving it open.
The other change that's in there is that I commented out the `finishLaunching`
call. It seems like this can cause problems, e.g.:
http://stackoverflow.com/questions/7381345/cocoa-exception-createmenuref-called-
with-existing-principal-menuref-already-a
Again, not sure if this is the correct solution, but it seems to work on my
system with my examples, and gets rid of the ugly `_createMenuRef` warning.
Note that other packages that use Pyglet (e.g., PsychoPy) have noted this issue
if you google it.
So, I've made some progress, but it's important that someone (preferably much)
more familiar with Cocoa than me takes a look, and sees if this is a proper
fix. Cheers!
----------------
FYI the first silly line about `ApplePersistenceIgnoreState` can be dealt with
by doing:
defaults write org.python.python ApplePersistenceIgnoreState NO
This has something to do with Mavericks and its app restoring, and probably
isn't specific to Pyglet necessarily (although it looked like there was some
code in `cocoa.py` that was meant to deal with it already).
Original comment by larson.e...@gmail.com
on 20 Apr 2014 at 12:23
Original comment by useboxnet
on 20 Apr 2014 at 8:57
Patch is included in version 1.2.3 (to be released). For current progress see:
https://bitbucket.org/pyglet/pyglet/issue/37/crash-when-multiple-runs-on-macosx
Original comment by Silveste...@gmail.com
on 26 May 2015 at 4:59
Original issue reported on code.google.com by
larson.e...@gmail.com
on 4 Apr 2014 at 10:00