{"action":"created","issue":{"url":"https://api.github.com/repos/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148","labels_url":"https://api.github.com/repos/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148/labels{/name}","comments_url":"https://api.github.com/repos/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148/comments","events_url":"https://api.github.com/repos/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148/events","html_url":"https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148","id":80887322,"number":148,"title":"Frequent crashes on resuming from phone call","user":{"login":"eirikurorri","id":1096637,"avatar_url":"https://avatars.githubusercontent.com/u/1096637?v=3","gravatar_id":"","url":"https://api.github.com/users/eirikurorri","html_url":"https://github.com/eirikurorri","followers_url":"https://api.github.com/users/eirikurorri/followers","following_url":"https://api.github.com/users/eirikurorri/following{/other_user}","gists_url":"https://api.github.com/users/eirikurorri/gists{/gist_id}","starred_url":"https://api.github.com/users/eirikurorri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eirikurorri/subscriptions","organizations_url":"https://api.github.com/users/eirikurorri/orgs","repos_url":"https://api.github.com/users/eirikurorri/repos","events_url":"https://api.github.com/users/eirikurorri/events{/privacy}","received_events_url":"https://api.github.com/users/eirikurorri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-26T09:50:32Z","updated_at":"2015-08-20T01:55:37Z","closed_at":null,"body":"I get frequent crashes in renderCallback when resuming from a phone call. The crash occurs in renderCallback.\r\n\r\nBackground info: The sounds are coming from AUAudioFilePlayers. I have to activate the session manually by listening to UIApplicationDidBecomeActiveNotification.\r\n\r\nMore specifically, I am creating AEAudioUnitFilePlayers and adding them to a channel.\r\n\r\nWhen resuming from a phone call, i tried to play a file and got a rate limit error message (\"Update graph result -10861 FFFFD593 ˇˇ’\") when trying to add a player to a channel.\r\n\r\nI´d appreciate any insight into this crash; I've been looking at it for quite a while with little results."},"comment":{"url":"https://api.github.com/repos/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/comments/132849240","html_url":"https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148#issuecomment-132849240","issue_url":"https://api.github.com/repos/TheAmazingAudioEngine/TheAmazingAudioEngine/issues/148","id":132849240,"user":{"login":"jureflander","id":13878797,"avatar_url":"https://avatars.githubusercontent.com/u/13878797?v=3","gravatar_id":"","url":"https://api.github.com/users/jureflander","html_url":"https://github.com/jureflander","followers_url":"https://api.github.com/users/jureflander/followers","following_url":"https://api.github.com/users/jureflander/following{/other_user}","gists_url":"https://api.github.com/users/jureflander/gists{/gist_id}","starred_url":"https://api.github.com/users/jureflander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jureflander/subscriptions","organizations_url":"https://api.github.com/users/jureflander/orgs","repos_url":"https://api.github.com/users/jureflander/repos","events_url":"https://api.github.com/users/jureflander/events{/privacy}","received_events_url":"https://api.github.com/users/jureflander/received_events","type":"User","site_admin":false},"created_at":"2015-08-20T01:55:37Z","updated_at":"2015-08-20T01:55:37Z","body":"Hi, I am experiencing the same issue. Little bit more details: \r\n\r\nAs mentioned above, `inside renderCallback`:\r\n`__unsafe_unretained AEAudioController * THIS = (__bridge AEAudioController*)channel->audioController;`\r\n\r\nwhen the crash happens `THIS` and `channel` is referencing an invalid pointer i.e. from my loggings it appears that `channel` is referencing an instance that has been deallocated. \r\n\r\nI created the following scenario, in which I got the crash pretty much every time. *Note: this is just for reproduction purposes.\r\n1.) Stop running engine\r\n2.) Remove a channel\r\n3.) Add a channel\r\n4.) Repeat step 2) and 3) 100 times\r\n5.) Start engine\r\n\r\n\r\nAnd, I think I might find the solution to that problem(below). Would just like you to confirm if it makes sense? \r\n\r\nFrom my observations, `renderCallback` doesn't stops triggering until we call `AUGraphDisconnectNodeInput` and `AUGraphUpdate`. And then there is this code:\r\n```\r\n- (OSStatus)updateGraph {\r\n    // Only update if graph is running\r\n    if ( self.running ) {\r\n        // Retry a few times (as sometimes the graph will be in the wrong state to update)\r\n        OSStatus err;\r\n        for ( int retry=0; retry<6; retry++ ) {\r\n            err = AUGraphUpdate(_audioGraph, NULL);\r\n            if ( err != kAUGraphErr_CannotDoInCurrentContext ) break;\r\n            [NSThread sleepForTimeInterval:0.01];\r\n        }\r\n        \r\n        return err;\r\n    }\r\n    return noErr;\r\n}\r\n```\r\nWhich doesn't call `AUGraphUpdate` if the engine is not running. Which would mean that in the above test scenario `renderCallback` with already deallocated `channel` parameter would be triggered.\r\n\r\nSo to fix this, would it make sense to update graph every time regardless of engine running or not? This seems to solve my crashes. Or would that cause any other issues?"}}