R87 audio plays repeatedly and crashes

0 favourites
  • 3 posts
From the Asset Store
In this template the music plays without looping in your game
  • Hi All,

    I'm pretty sure this is a bug, but please accept my apologies if I'm misunderstanding C2. I've tested this on FF 12 and Chrome 18. Specs are in the sig.

    The basic scenario is that I have a platformer land on a box. Normally, landing on the box produces a sound and animation event. However, when the player lands on a certain number of this type of box, a variable is set which triggers events to suspends player movement/scroll, then play a sound, then scroll to a new location.

    I've created a stripped down .capx to show the sequence with only one box (as though this box were the last one required to trigger the sequence). When the player lands on the box, there is a two second wait, but instead of playing the sound once, the sound is played repeatedly until the audio driver breaks or the browser is shut down.

    Interestingly, this problem happens whether you leave the sound in event 4 or drag it into event 5. It seems like it might be buffering two seconds worth of actions (120 sounds) and then trying to play them all at once, but this is just a guess.

    For safety, the .capx I've uploaded has the wait action disabled. In order to reproduce the problem, enable the wait action in event #4, then land the player on the box.

    WARNING!!: With the wait action enabled, this .capx has crashed my audio driver a couple of times. I've had to quickly close my browser once the sound starts to avoid more crashes.

    Here is the .capx:


  • You need to add 'Trigger once' to the event otherwise it is constantly true. Events are checked once a tick (about 60 times a second) and if you play a sound in an event which is constantly true you will play 60 sounds a second. Note the 'Wait' action does not block the event, you will still queue up waits 60 times a second.

    Browsers tend to have pretty bad audio support so if the browser/audio driver crashes that's the fault of the browser/audio driver, and we can't fix that for them! You just have to be more careful with how you play audio and not make events like this.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the quick reply, Ashley.

    All of what you say makes sense to me; I suspected something along those lines. I knew the 'wait' didn't block the event, but it didn't occur to me that 120 'wait' statements were queuing up. Now I understand why the crash happens even when I isolate the sound in its own event after the variable change. The wait cycles that are queued simply reset the variable. I moved the variable setter to before the 'wait' in the event and now the whole thing works perfectly and makes sense.

    I went ahead and posted a comment in the 'wait' tutorial to clarify this in case anyone else runs into it.

    Regarding the audio crashes: I truly hope you didn't see that as a criticism. Please know that I love C2 and am singing its praises to anyone who will listen. You guys are doing an absolutely wonderful job, and I can't wait for the browser folks to catch up to you! The only reason I highlighted the crashes in the post was to make sure that no one else inadvertently experienced them.

    Please feel free to move this whole thread to "How Do I?" and rename it if you think that's appropriate.


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)