# Using pygame on mac, strange errors

I am using pygame on a mac, and when the app runs, it draws a frame of the screen fine, and then crashes with the following error:

Assertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay() != currentlyBuildingLayerTree),
function NSViewSetCurrentlyBuildingLayerTreeForDisplay,
file /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.10.101/AppKit.subproj/NSView.m,
line 14480.


Everything was working fine, but I did switch to multi-threading, and I think this might be related. Has anyone a clue as to what might be going wrong?

I call:

pygame.init()
pygame_size = 1280, 960  # image dimensions
pygame_screen = pygame.display.set_mode(pygame_size)


in the main thread, and then I have many pygame draw calls.

• Do you touch any pygame functions from a non-main thread? – Tyyppi_77 Dec 8 '17 at 13:46
• Yes. So, Thinking this might be the problem now. I am actually using it as part of running tests and trying to save screen captures of the tests. I am not actually trying to run a multi-threaded game. – nycynik Dec 8 '17 at 13:49
• YES! I moved the screen creation into the main thread, and now it is not crashing! – nycynik Dec 8 '17 at 14:01