coronalabs / corona

Solar2D Game Engine main repository (ex Corona SDK)
https://solar2d.com/
MIT License
2.54k stars 273 forks source link

[Simulator]: Crash on display.captureScreen and display.captureBounds on Mac OS simulators #735

Open alanflickgames opened 1 month ago

alanflickgames commented 1 month ago

On Mac (possibly just M1+ and not Intel Macs) the simulator suddenly crashes when you try to capture the screen. It happens around 75% of the time.

To reproduce you can use either of these in main.lua:

local obj = display.newRect(0, 0, 100, 100)
display.captureBounds({
            xMin = 0,
            xMax = 100,
            yMin = 0,
            yMax = 100,
        }  )

or

local obj = display.newRect(0, 0, 100, 100)
display.captureScreen()

It is essentially the same problem as in this solved issue: https://github.com/coronalabs/corona/issues/595

The fix for issue 595 was to add these 2 lines to display.capture after the call to display.CaptureDisplayObject:

    //Rerender and Invalidate to prevent errors on start up
    display.Invalidate();
    display.Render();

I suspect this just needs the same fix to be applied to display.captureScreen and display.captureBounds