21
Stack Exchange
votes

Metal crash upon adding SKSpriteNode to SKEffectNode

Posted on 2/21/2017
UQ ID:381
Technology
Stack Overflow
Original
> -[MTLDebugRenderCommandEncoder setScissorRect:]:2028: failed assertion (rect.x(0) + rect.width(1080))(1080) must be <= 240

I am getting this crash when adding a simple SKSpriteNode to a SKEffectNode with the following code

    SKSpriteNode *warpSprite = [SKSpriteNode spriteNodeWithImageNamed:@"art.scnassets/symbol.png"];
    SKEffectNode *entryEffectsNode = [[SKEffectNode alloc] init];
    [entryEffectsNode addChild:warpSprite];
    [self addChild:entryEffectsNode];

I have not touched these nodes anywhere else in my project, when i change the sprite the value in (must be <=value) changes within the error.

Edit: I have replaced the sprite image with a simple spriteNodeWithColor:Size: and the (<=value) is always twice size of the sprite. Also it should be noted that the SKScene is being used as a overlay in a SceneKit scene.

I have created a seperate SKScene with the following code, which still results in the same error.

@implementation testScene
    
    -(id)initWithSize:(CGSize)size {
        if (self = [super initWithSize:size]) {
            
            SKSpriteNode *testSprite = [SKSpriteNode spriteNodeWithColor:[SKColor purpleColor] size:CGSizeMake(100, 100)];
            SKEffectNode *testEffect = [[SKEffectNode alloc] init];
            [testEffect addChild:testSprite];
            [self addChild:testEffect];
            
        }
        return self;
    }
@end

Edit 2: I have just tested the above scene as an overlay on a default SceneKit Project and it crashes with the same error.

Edit 3: I have reproduced this using swift. Bug report summited to Apple.

Keywords & Tags
ios
objective-c
sprite-kit
swift3
skeffectnode
Model Answers (9)
Submitted answers from various AI models
Unsolved
No reviews yet

K2-Think

Pending UQ Validation
Needs Human Verification
MBZUAI-IFM
Qwen2.5-32B
Sep 18, 2025, 01:50 PM

The crash occurs due to a Metal assertion related to the scissor rect when using SKEffectNode in a SpriteKit scene overlaid on a SceneKit scene. Here's the breakdown and solution:

Issue Analysis:

The error -[MTLDebugRenderCommandEncoder setScissorRect:]: ... must be <= 240 indicates that the scissor rect's calculated width exceeds the allowed render target width. This happens when the `SK...

0 model reviews
0 human reviews
No reviews yet

GPT-5

Failed UQ Validation
Needs Human Verification
OpenAI
Sep 2, 2025, 06:56 AM

This isn’t a bug in your code. It’s a SpriteKit/SceneKit issue that shows up when an SKScene (used as SCNView.overlaySKScene) contains an SKEffectNode and SceneKit is rendering with Metal. The Metal validation layer asserts because the scissor rect SpriteKit sets is computed in a different scale (points) than the temporary render target (pixels), hence the “must be <= …” value that tracks roughly ...

0 model reviews
0 human reviews
No reviews yet

Claude Opus 4

Failed UQ Validation
Needs Human Verification
Anthropic
Aug 1, 2025, 12:00 AM

This appears to be a Metal rendering issue that occurs when using SKEffectNode as an overlay in a SceneKit scene. The error message indicates that the scissor rectangle is being set incorrectly, with dimensions that exceed the allowed bounds.

Root Cause

The crash occurs because there's a mismatch between the coordinate systems or render target sizes when SpriteKit is used as an overlay on S...

0 model reviews
0 human reviews
No reviews yet

o3 Pro

UQ Validated
Needs Human Verification
OpenAI
Aug 1, 2025, 12:00 AM

What you’re seeing is not a problem with the way you create the nodes – it is a SceneKit / SpriteKit / Metal bug that appears as soon as an SKEffectNode finds itself inside an SKScene that SceneKit renders with Metal (which is the default in iOS 10).
The numbers in the assertion tell the story:

rect.x 0 + rect.width 1080  -> 1080   (SpriteKit asks Metal to draw 1080 px wide)
must be <= ...
0 model reviews
0 human reviews
No reviews yet

o4 mini

Failed UQ Validation
Needs Human Verification
OpenAI
Aug 1, 2025, 12:00 AM

This isn’t anything you’ve done wrong – it turns out to be a bug in SpriteKit’s Metal‐based renderer, specifically in the code that SKEffectNode uses to render its children into an off–screen texture and set up a scissor-rect. In your case (a SceneKit overlay) SpriteKit winds up creating a tiny backing texture (≈240 px wide) but then asks Metal to set a scissor rect that is the size of your sprit...

0 model reviews
0 human reviews
No reviews yet

Gemini 2.5 Pro

Failed UQ Validation
Needs Human Verification
Google
Aug 1, 2025, 12:00 AM

Hello! Based on the detailed information and excellent debugging you've done, I can provide a clear explanation and a common workaround for this issue.

Diagnosis of the Problem

You have correctly identified this as a framework bug. Specifically, it's a well-known issue that arises from the interaction between SceneKit's rendering loop and SpriteKit's SKEffectNode when used in an `SCNView.o...

0 model reviews
0 human reviews
No reviews yet

o3

Failed UQ Validation
Needs Human Verification
OpenAI
Aug 1, 2025, 12:00 AM

You are not doing anything wrong.
The problem is a framework bug that appears when an SKEffectNode is rendered by SpriteKit through the overlaySKScene property of an SCNView (or of an ARSCNView).
During the off-screen pass that SKEffectNode performs, SpriteKit builds a scissor rectangle that is expressed in the scene’s point coordinates, but it hands that rectangle to Metal for a render ta...

0 model reviews
0 human reviews
No reviews yet

DeepSeek R1

Failed UQ Validation
Needs Human Verification
DeepSeek
deepseek-ai/DeepSeek-R1
Aug 1, 2025, 12:00 AM
<think> We are given a crash report from Metal when adding an SKSpriteNode to an SKEffectNode in a SpriteKit scene that is used as an overlay in a SceneKit scene. The error message is:
-[MTLDebugRenderCommandEncoder setScissorRect:]:2028: failed assertion (rect.x(0) + rect.width(1080))(1080) must be <= 240

The error indicates that the scissor rectangle being set in Metal has a width that is ...

0 model reviews
0 human reviews
No reviews yet

Claude 3.7 Sonnet

Failed UQ Validation
Needs Human Verification
Anthropic
Aug 1, 2025, 12:00 AM

Metal Crash When Adding SKSpriteNode to SKEffectNode

This error indicates a sizing issue in Metal when rendering your SKEffectNode with its child sprite. The specific error:

-[MTLDebugRenderCommandEncoder setScissorRect:]:2028: failed assertion (rect.x(0) + rect.width(1080))(1080) must be <= 240

Suggests that Metal is trying to set a scissor rectangle that exceeds the allowed bounds...

0 model reviews
0 human reviews
Submit Your Model's Answer
Your submission will be validated by our LLM validator and then by human experts

You need to be logged in to submit an answer