Note that there are some explanatory texts on larger screens.

plurals
  1. POGKSession displayNameForPeer prevents releasing the session (iOS 4.0, 4.1)
    primarykey
    data
    text
    <p>I can reliably crash the simulator with this when releasing the GKSession after calling displayNameForPeer for another peer (not self), and I'm not sure if it's something I'm doing wrong or if it's a bug with Apple's Gamekit framework (and whether I need to worry about it, since I only see the crash under 4.0 and 4.1, not 4.2+).</p> <p>The output is:</p> <pre><code>found available peer; checking name and ID... m4, 26176566 *** -[GKSessionInternal lock]: message sent to deallocated instance 0x7508900 </code></pre> <p>Here's the minimal reproducible code set -- note that another GKSession must be visible on the network (so that there's an available peer found to call displayNameForPeer on) to trigger the crash. Running this same code on another device but without the makeUnavailable and killSession calls is adequate.</p> <pre><code>- (void)viewDidLoad { [self createSession]; [self makeAvailable]; peerListAvailable = [[NSMutableArray alloc] initWithArray:[currentSession peersWithConnectionState:GKPeerStateAvailable]]; for (NSString *peer in peerListAvailable) { // this method guarantees the crash on session release NSLog(@"found available peer; checking name and ID... %@, %@",[currentSession displayNameForPeer:peer], peer); } [peerListAvailable release]; peerListAvailable = nil; [self makeUnavailable]; [self killSession]; [super viewDidLoad]; } - (void) createSession { if (!currentSession) { currentSession = [[GKSession alloc] initWithSessionID:@"GKTester" displayName:nil sessionMode:GKSessionModePeer]; currentSession.delegate = self; currentSession.disconnectTimeout = 30; [currentSession setDataReceiveHandler: self withContext:nil]; } } -(void) killSession { if (currentSession) { [currentSession disconnectFromAllPeers]; [currentSession setDelegate:nil]; [currentSession setDataReceiveHandler:nil withContext:nil]; [currentSession release]; // crash occurs after this currentSession = nil; } } -(void) makeAvailable { while (currentSession &amp;&amp; !currentSession.available) { [currentSession setAvailable:YES]; [NSThread sleepForTimeInterval:.5]; } } -(void) makeUnavailable { while (currentSession &amp;&amp; currentSession.available) { [NSThread sleepForTimeInterval:.5]; [currentSession setAvailable:NO]; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload