I fixed a bug regarding the error: "EXC_BAD_ACCESS" which made the app crashed.
It occurs when playing sound short time at high frequency with fade out.
(at ObjectAL/ObjectAL/Actions/OALActionManager.m#L160)
When starting fade out, a fade action added to OALActionManager targetActions, and it removed when fade out was completed. However, there is a time lag between releasing ALSource and removing fade action from targetActions.
App crashes during the time lag when a new ALSource is generated with the same id as the released old AlSource one and when an action from the ALSource is added to the to the targetActions.
Regarding the OALActionManager step:timer, when a new fade action from the ALSource is attempting to be added, the id of the released ALSource however remains present in the targets. Therefore, the new fade action is added to the array of actions for old ALSource in targetActions. Next, the fade action of released ALSource is removed, but the id of released ALSource is not removed from targets because the fade action of new ALSource remains in the array of actions in targetActions. Hence the next time OALActionManager step:timer is called, the app will crash trying to reference the id of released ALSource in targets.
To fix it, I swapped the order of adding and removing actions in the code, and removed the master timer stop condition and placed it out, at the end of the adding/removing process.
The following code is for verification. It reproduces this bug.
I fixed a bug regarding the error: "EXC_BAD_ACCESS" which made the app crashed. It occurs when playing sound short time at high frequency with fade out. (at
ObjectAL/ObjectAL/Actions/OALActionManager.m#L160
)When starting fade out, a fade action added to
OALActionManager targetActions
, and it removed when fade out was completed. However, there is a time lag between releasingALSource
and removing fade action fromtargetActions
.App crashes during the time lag when a new
ALSource
is generated with the same id as the released oldAlSource
one and when an action from theALSource
is added to the to thetargetActions
.Regarding the
OALActionManager step:timer
, when a new fade action from theALSource
is attempting to be added, the id of the releasedALSource
however remains present in thetargets
. Therefore, the new fade action is added to the array of actions for oldALSource
intargetActions
. Next, the fade action of releasedALSource
is removed, but the id of releasedALSource
is not removed fromtargets
because the fade action of newALSource
remains in the array of actions intargetActions
. Hence the next timeOALActionManager step:timer
is called, the app will crash trying to reference the id of releasedALSource
intargets
.To fix it, I swapped the order of adding and removing actions in the code, and removed the master timer stop condition and placed it out, at the end of the adding/removing process.
The following code is for verification. It reproduces this bug.