{"action":"created","issue":{"url":"https://api.github.com/repos/zmxv/react-native-sound/issues/168","repository_url":"https://api.github.com/repos/zmxv/react-native-sound","labels_url":"https://api.github.com/repos/zmxv/react-native-sound/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/zmxv/react-native-sound/issues/168/comments","events_url":"https://api.github.com/repos/zmxv/react-native-sound/issues/168/events","html_url":"https://github.com/zmxv/react-native-sound/pull/168","id":226797335,"number":168,"title":"Fix callback crashes - Guarantee that the RN callback is only ever called once","user":{"login":"ndbroadbent","id":139536,"avatar_url":"https://avatars1.githubusercontent.com/u/139536?v=3","gravatar_id":"","url":"https://api.github.com/users/ndbroadbent","html_url":"https://github.com/ndbroadbent","followers_url":"https://api.github.com/users/ndbroadbent/followers","following_url":"https://api.github.com/users/ndbroadbent/following{/other_user}","gists_url":"https://api.github.com/users/ndbroadbent/gists{/gist_id}","starred_url":"https://api.github.com/users/ndbroadbent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndbroadbent/subscriptions","organizations_url":"https://api.github.com/users/ndbroadbent/orgs","repos_url":"https://api.github.com/users/ndbroadbent/repos","events_url":"https://api.github.com/users/ndbroadbent/events{/privacy}","received_events_url":"https://api.github.com/users/ndbroadbent/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-06T19:26:24Z","updated_at":"2017-05-08T11:50:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/zmxv/react-native-sound/pulls/168","html_url":"https://github.com/zmxv/react-native-sound/pull/168","diff_url":"https://github.com/zmxv/react-native-sound/pull/168.diff","patch_url":"https://github.com/zmxv/react-native-sound/pull/168.patch"},"body":"I previously added the `synchronized` calls to make sure that the callbacks were only being called one at a time. That was actually not enough. I was developing some other RN libraries, and I realized that I should have paid more attention to the error message... these callbacks actually can only be called once. It doesn't matter if there is a race condition or not, if you call them twice, the app will crash. \r\n\r\nSo the `synchronized` calls did help to reduce the number of crashes in my app, but I still experienced one or two crashes, and this PR will completely stop them from happening.\r\n\r\nOn iOS, I am removing the callback from the pool as soon as it is called. On Android, I added an extra boolean flag inside the listener, so that the callback can only ever be called once.\r\n\r\n**Note:** I haven't looked at Windows yet, but I'm about to set up a development environment, so I will take a look soon."},"comment":{"url":"https://api.github.com/repos/zmxv/react-native-sound/issues/comments/299846324","html_url":"https://github.com/zmxv/react-native-sound/pull/168#issuecomment-299846324","issue_url":"https://api.github.com/repos/zmxv/react-native-sound/issues/168","id":299846324,"user":{"login":"ndbroadbent","id":139536,"avatar_url":"https://avatars1.githubusercontent.com/u/139536?v=3","gravatar_id":"","url":"https://api.github.com/users/ndbroadbent","html_url":"https://github.com/ndbroadbent","followers_url":"https://api.github.com/users/ndbroadbent/followers","following_url":"https://api.github.com/users/ndbroadbent/following{/other_user}","gists_url":"https://api.github.com/users/ndbroadbent/gists{/gist_id}","starred_url":"https://api.github.com/users/ndbroadbent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndbroadbent/subscriptions","organizations_url":"https://api.github.com/users/ndbroadbent/orgs","repos_url":"https://api.github.com/users/ndbroadbent/repos","events_url":"https://api.github.com/users/ndbroadbent/events{/privacy}","received_events_url":"https://api.github.com/users/ndbroadbent/received_events","type":"User","site_admin":false},"created_at":"2017-05-08T11:50:52Z","updated_at":"2017-05-08T11:50:52Z","body":"UPDATE: I just fixed this on Windows as well (and tested!). Windows was crashing whenever I played the same sound twice."}}
{"actor":{"display_login":"ndbroadbent"}}