Created
August 3, 2018 18:29
-
-
Save matthewreagan/06719c22d01f1492f412e089f6d12aee to your computer and use it in GitHub Desktop.
SpriteKit macOS 10.13 Windowserver Crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following code reliably crashes windowserver on macOS 10.13, | |
// forcing logout of the current user. | |
// Setup: Create a simple, default SKView() and present an | |
// SKScene() and add it to a window on macOS | |
let sprite = SKSpriteNode(imageNamed: "mySpriteImage") | |
scene.addChild(sprite) | |
let warpGridSize = 100 | |
func geometryGridPositions(byWarping: Bool) -> [float2] { | |
var points = [float2]() | |
for y in 0...warpGridSize { | |
for x in 0...warpGridSize { | |
let shouldWarp = byWarping && x > 0 && y > 0 && x < warpGridSize && y < warpGridSize | |
let nx = Float(x) * (1.0 / Float(warpGridSize)) + (shouldWarp ? -50.0 : 0.0) | |
let ny = Float(y) * (1.0 / Float(warpGridSize)) + (shouldWarp ? -50.0 : 0.0) | |
points.append(float2(nx,ny)) | |
} | |
} | |
return points | |
} | |
let sourcePositions = geometryGridPositions(byWarping: false) | |
let destinationPositions = geometryGridPositions(byWarping: true) | |
let warpGeometryGrid = SKWarpGeometryGrid.init(columns: warpGridSize, | |
rows: warpGridSize, | |
sourcePositions: sourcePositions, | |
destinationPositions: destinationPositions) | |
if let warpAction = SKAction.warp(to: warpGeometryGrid, duration: 1.0) { | |
sprite.run(.sequence([warpAction])) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment