[SKAction performSelector:onTarget:] fails to perform selector in iOS 11

Originator:karlvoskuil
Number:rdar://35772829 Date Originated:11/30/2017
Status:Open Resolved:
Product:iOS + SDK SpriteKit Product Version:11.1
Classification:Other Bug Reproducible:Always
 
Summary:

As of iOS 11.1, [SKAction performSelector:onTarget:] fails to perform a selector on an unretained object in a simple test case.

In iOS 10.3.1, the selector is performed.
Alternately, if either the action or the target are retained elsewhere in the app, the selector is performed.

(Note that `performSelector:onTarget:` is documented to retain its target strongly, and it does, if the action itself is retained.  Perhaps [SKNode runAction] is the culprit?)

Steps to Reproduce:

Starting with the Xcode "Game" template for iOS:

    @implementation GameScene

    - (void)didMoveToView:(SKView *)view {
      LifetimeLogger *lifetimeLogger = [[LifetimeLogger alloc] init];
      SKAction *performSelectorAction = [SKAction performSelector:@selector(aLifetimeLoggerMethod) onTarget:lifetimeLogger];
      [self runAction:performSelectorAction];
    }

    @end

The LifetimeLogger object is an NSObject with simple logging added to init and dealloc:

    @interface LifetimeLogger : NSObject
    - (void)aLifetimeLoggerMethod;
    @end

    @implementation LifetimeLogger

    - (instancetype)init {
      NSLog(@"LifetimeLogger: init");
      return [super init];
    }

    - (void)dealloc {
      NSLog(@"LifetimeLogger: dealloc");
    }

    - (void)aLifetimeLoggerMethod {
      NSLog(@"LifetimeLogger: aLifetimeLoggerMethod");
    }

    @end

Expected Results:

(These results logged using iPhone 6 Simulator iOS 10.3.1.)

  2017-11-30 11:05:57.651 TestPerformSelector[22086:2466019] LifetimeLogger: init
  2017-11-30 11:05:57.654 TestPerformSelector[22086:2466019] LifetimeLogger: aLifetimeLoggerMethod
  2017-11-30 11:05:57.655 TestPerformSelector[22086:2466019] LifetimeLogger: dealloc

Actual Results:

(These results logged using iPhone 6 Simulator iOS 11.1.  The selector is not performed on the target by the action.)

  2017-11-30 10:52:45.247456-0500 TestPerformSelector[21709:2445008] LifetimeLogger: init
  2017-11-30 10:52:45.247737-0500 TestPerformSelector[21709:2445008] LifetimeLogger: dealloc


Version/Build:

n/a

Configuration:

n/a

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com 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!