GMS 2 Output message Audio_PlaySound Attempting to play sound on inactive emitter

Discussion in 'Programming' started by MeltingCat, Sep 14, 2019.

  1. MeltingCat

    MeltingCat Member

    Jul 20, 2018
    I've been getting game freezes lately a lot and didn't know what to look for as I'm not getting an error message. I've realized now that this message shows in the output, possibly just before it freezes.
    The thing is, I'm using a deactivation code deactivating objects far outside view. But I thought that this code would also prevent any of those objects running any code that plays a sound from its emitter. So this doesn't make sense to me. There is no code in any object trying to play sound from a different object's emitter, so I don't know what to look for.
    Any ideas what kind of issue this could be?
    Grateful for any tips.
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Apr 13, 2016
    You could try adding in breakpoints to all the places where a sound is being played from an emitter then run the game in debug mode and see which one gives the error.This would help you to narrow down the issue to a specific object or script. It's probably worth noting that instance deactivation takes a step to be completed, which might also be an issue. By that I mean, deactivation works like this:

    1) You call deactivation.
    2) The instance is taken off the internal active instances list BUT still isn't on the inactive instance list (it's in a kind of "limbo" state)
    3) The current step ends
    4) the deactivated instance is added into the inactive instance list at the start of the next step

    So, if you have a call to a sound to play on an emitter somewhere in between the deactivation of the instance and the end of the step, it could be that this is giving you the error, as the instance isn't technically active any more, but still present within the room and not yet on the inactive instance list. If this is the case, you'll want to think about the activation/deativation routines and probably want to move them into the end step event so that all the game code runs correctly before anything is actually deactivated.
    MeltingCat likes this.
  3. MeltingCat

    MeltingCat Member

    Jul 20, 2018
    Thanks a lot for your answer.
    I wasn't aware of these details of how deactivation works, so that's really helpful to know.
    I've moved all the deactivation to the end step event and haven't gotten any crashes since, fingers crossed that that is the fix, as the crashes were quite irregular and unpredictable.
    Thanks again for helping!
    Nocturne likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice