setStrokeColor: on SKShapeNode inside SKEffectNode causes no visual change

Number:rdar://16400219 Date Originated:2014-03-22
Status:Closed Resolved:2014-06-03
Product:iOS SDK Product Version:7.1
Classification:UI Reproducible:Always
When an SKShapeNode is inside an SKEffectNode, setStrokeColor: causes no visual change.

Steps to Reproduce:
1. Add an SKShapeNode to an SKEffectNode.
2. Call setStrokeColor:[SKColor redColor] to set its initial stroke color to red.
3. Wait for some event, such as with dispatch_after or touchesBegan:
4. Call setStrokeColor:[SKColor greenColor] to change the stroke color.

Create a new iOS Xcode project using the Sprite Kit template. Replace the scene class's implementation with the following code. Note the if-statement inviting you to test the workaround described further down.

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {
        SKEffectNode *container = [SKEffectNode node];
        [self addChild:container];

        SKShapeNode *shape = [SKShapeNode node];
        shape.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 200) cornerRadius:40].CGPath;
        shape.strokeColor = [SKColor redColor];
        [container addChild:shape];

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            NSLog(@"setting stroke color");

            if (0) { // <-- CHANGE ME
                CGFloat oldAlpha = shape.alpha;
                shape.alpha = 0;
                shape.alpha = oldAlpha;
            shape.strokeColor = [SKColor greenColor];
    return self;

Expected Results:
The shape node's stroke color changes to green.

Actual Results:
The shape node's stroke color does not change to green; it stays red.

iOS 7.1 (11D167)

You can work around this issue by setting the SKShapeNode's alpha to a different value. Perhaps this is causing an internal setNeedsDisplay: to fire, which updates the stroke color.

See also rdar://16400203

iPhone 5S
iOS Simulator




Attached a sample Xcode project to demonstrate the problem.

Tap the screen and observe that setStrokeColor: to green has no effect.

To test the workaround, change line 35 of RPGMyScene.m to if (1) {. Tap the screen to observe that adding in another (spurious) visual change causes setStrokeColor: to green to work.

Apple Developer Relations

Engineering has requested a test case/sample app in order to further investigate this issue.

Test Case/Sample App Requirements:

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!