mojira.dev
MC-35714

Sounds loop/restart when exiting screens

When a jukebox playing music is broken, the music initially stops, but when I opened up my inventory then closed it again, the song plays again. This works with any disc in creative and survival, and in both single- and multiplayer.

1. Get Jukebox and disc of any kind
2. Play the disc
3. Break jukebox BEFORE song ends
4. Open your inventory
5. Close Inventory
6. Song plays without a jukebox

More generally, sounds can replay when a GUI is closed, when they shouldn't. This includes block breaking sounds, button sounds, and music. It also includes any GUI closing besides the pause menu in single player – your inventory, the chat GUI, or a chest all work.

Debug info

I recently figured out how to get minecraft to output sound debug logs by following this wiki.vg tutorial. Using the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="net.minecraft,com.mojang">
    <Appenders>
        <Console name="SysOut" target="SYSTEM_OUT">
            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <filters>
                <MarkerFilter marker="SOUNDS" onMatch="ACCEPT" onMismatch="DENY" />
            </filters>
            <AppenderRef ref="SysOut"/>
        </Root>
    </Loggers> 
</Configuration>

This is what the logs look like when the bug is reproduced:

[12:18:50] [Sound Library Loader/INFO]: Sound engine started
[12:19:01] [Client thread/DEBUG]: Playing sound minecraft:sounds/random/click.ogg for event minecraft:gui.button.press as channel 231386e6-ecda-431b-a2e7-12f936caedb2
[12:19:02] [Client thread/DEBUG]: Removed channel 231386e6-ecda-431b-a2e7-12f936caedb2 because it's not playing anymore
[12:19:06] [Client thread/DEBUG]: Skipped playing sound minecraft:sounds/music/menu/menu2.ogg, volume was zero.
[12:19:10] [Client thread/DEBUG]: Playing sound minecraft:sounds/random/click.ogg for event minecraft:gui.button.press as channel 229f3257-5902-4b42-bcae-eee3d53ec16c
[12:19:11] [Client thread/DEBUG]: Removed channel 229f3257-5902-4b42-bcae-eee3d53ec16c because it's not playing anymore
[12:19:22] [Client thread/DEBUG]: Skipped playing sound minecraft:sounds/music/game/calm2.ogg, volume was zero.
[12:19:37] [Client thread/DEBUG]: Playing sound minecraft:sounds/step/stone4.ogg for event minecraft:step.stone as channel 07f5ef05-28e9-4d6d-8f31-d0a7df0fe69b
[12:19:38] [Client thread/DEBUG]: Removed channel 07f5ef05-28e9-4d6d-8f31-d0a7df0fe69b because it's not playing anymore
[12:19:38] [Client thread/DEBUG]: Playing sound minecraft:sounds/step/grass3.ogg for event minecraft:step.grass as channel 1a781d6d-ab09-425b-bb92-7f6009b42362
[12:19:39] [Client thread/DEBUG]: Removed channel 1a781d6d-ab09-425b-bb92-7f6009b42362 because it's not playing anymore
[12:19:45] [Client thread/DEBUG]: Playing sound minecraft:sounds/dig/stone1.ogg for event minecraft:dig.stone as channel c16bccae-f170-44fc-8082-f1567ddcd783
[12:19:46] [Client thread/DEBUG]: Removed channel c16bccae-f170-44fc-8082-f1567ddcd783 because it's not playing anymore
[12:19:47] [Client thread/DEBUG]: Playing sound minecraft:sounds/dig/stone1.ogg for event minecraft:dig.stone as channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Resuming channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Resuming channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Resuming channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Resuming channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Resuming channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Resuming channel 73f94183-6a17-4355-b356-2374cd71ed68
[12:19:48] [Client thread/DEBUG]: Removed channel 73f94183-6a17-4355-b356-2374cd71ed68 because it's not playing anymore

For 73f94183-6a17-4355-b356-2374cd71ed68, I was mashing open/close inventory (which is how the bug is reproduced). As you can see, it's getting resumed multiple times, despite never getting paused. It only replays the sound once (since resuming the sound is simply playing it again), but probably the sound is getting played before it is removed.

Programmatic cause

Note: MCP names for Minecraft 1.8 (mcp910) are used here. Obfuscated names as of 1.9-pre1 appear at the bottom.

The reason that this bug occurs is that sounds are replayed whenever a GUI is closed. The most likely reason why sounds were replayed is that they are paused when certain GUIs open (such as the ingame pause menu) in single player. However, the sounds are played even if they were never paused (IE, they are played when any GUI is closed).

net.minecraft.client.Minecraft, lines 964 - 1005

/**
 * Sets the argument GuiScreen as the main (topmost visible) screen.
 */
public void displayGuiScreen(GuiScreen guiScreenIn)
{
    if (this.currentScreen != null)
    {
        this.currentScreen.onGuiClosed();
    }

    if (guiScreenIn == null && this.theWorld == null)
    {
        guiScreenIn = new GuiMainMenu();
    }
    else if (guiScreenIn == null && this.thePlayer.getHealth() <= 0.0F)
    {
        guiScreenIn = new GuiGameOver();
    }

    if (guiScreenIn instanceof GuiMainMenu)
    {
        this.gameSettings.showDebugInfo = false;
        this.ingameGUI.getChatGUI().clearChatMessages();
    }

    this.currentScreen = (GuiScreen)guiScreenIn;

    if (guiScreenIn != null)
    {
        this.setIngameNotInFocus();
        ScaledResolution var2 = new ScaledResolution(this, this.displayWidth, this.displayHeight);
        int var3 = var2.getScaledWidth();
        int var4 = var2.getScaledHeight();
        ((GuiScreen)guiScreenIn).setWorldAndResolution(this, var3, var4);
        this.skipRenderWorld = false;
    }
    else
    {
        this.mcSoundHandler.resumeSounds();
        this.setIngameFocus();
    }
}

When guiScreenIn is null, mcSoundHandler.resumeSounds is called. The SoundHandler methods simply call the same methods on the SoundManager.

net.minecraft.client.audio.SoundManager, lines 467 - 495

/**
 * Pauses all currently playing sounds
 */
public void pauseAllSounds()
{
    Iterator var1 = this.playingSounds.keySet().iterator();

    while (var1.hasNext())
    {
        String var2 = (String)var1.next();
        logger.debug(LOG_MARKER, "Pausing channel {}", new Object[] {var2});
        this.sndSystem.pause(var2);
    }
}

/**
 * Resumes playing all currently playing sounds (after pauseAllSounds)
 */
public void resumeAllSounds()
{
    Iterator var1 = this.playingSounds.keySet().iterator();

    while (var1.hasNext())
    {
        String var2 = (String)var1.next();
        logger.debug(LOG_MARKER, "Resuming channel {}", new Object[] {var2});
        this.sndSystem.play(var2);
    }
}

Note that resumeAllSounds works simply by calling play on all of the currently playing sounds. This works in most cases, as calling play while a sound is currently playing doesn't do anything. However, if the sound has finished playing but has not been cleaned up yet, calling play on it will cause it to play again, from the start. This is the core cause of this bug.

The simplest way to fix it is to create a list of sounds that were paused when pauseAllSounds is called, and then only play the sounds in that list when resumeAllSounds is called (and then clear the list).

Something like this:

Replacement for code in net.minecraft.client.audio.SoundManager

private List<String> pausedSounds = new ArrayList<String>();

/**
 * Pauses all currently playing sounds
 */
public void pauseAllSounds()
{
    Iterator var1 = this.playingSounds.keySet().iterator();

    while (var1.hasNext())
    {
        String var2 = (String)var1.next();
        logger.debug(LOG_MARKER, "Pausing channel {}", new Object[] {var2});
        this.sndSystem.pause(var2);
        
        pausedSounds.add(var2);
    }
}

/**
 * Resumes playing all currently playing sounds (after pauseAllSounds)
 */
public void resumeAllSounds()
{
    Iterator var1 = this.pausedSounds.iterator();

    while (var1.hasNext())
    {
        String var2 = (String)var1.next();
        logger.debug(LOG_MARKER, "Resuming channel {}", new Object[] {var2});
        this.sndSystem.play(var2);
    }
    
    this.pausedSounds.clear();
}

(It may be necessary to make pauseAllSounds and resumeAllSounds synchronized depending on if it's called from a separate thread, but I'm guessing not since it isn't currently needed; also, don't blame me for the ugly syntax there; that's MCP's fault)

I've tested this and found that it eliminates all of the looping sound issues, which is the main part of this bug.

Here are the code snippets from above with 1.9-pre1's obfuscation (jd is used to decompile):

The place where resumeSounds is called in displayGuiScreen:

bce, lines 864 to 893

public void a(bfa ) {
    if (this.m != null) {
      this.m.m();
    }
    
    if (( == null) && (this.f == null)) {
       = new bfh();
    } else if (( == null) && (this.h.bP() <= 0.0F)) {
       = new bel(null);
    }
    
    if ((( instanceof bfh)) || (( instanceof bgq))) {
      this.u.aq = false;
      this.r.d().a();
    }
    
    this.m = ;
    
    if ( != null) {
      p();
      bcw  = new bcw(this);
      int  = .a();
      int  = .b();
      .a(this, , );
      this.s = false;
    } else {
      this.aL.e(); // This is resumeAllSounds, line 890
      o();
    }
  }

Here is the code for resumeAllSounds and pauseAllSounds:

byu, lines 409 to 421

public void e() {
    for (String  : this.i.keySet()) {
      b.debug(a, "Pausing channel {}", new Object[] {  });
      this.f.pause();
    }
  }
  
  public void f() {
    for (String  : this.i.keySet()) {
      b.debug(a, "Resuming channel {}", new Object[] {  });
      this.f.play();
    }
  }

And here are resumeAllSounds and pauseAllSounds with the bug fixed:

byu

List<String> pausedSounds = new ArrayList<String>();
  
  public void e() {
    for (String  : this.i.keySet()) {
      b.debug(a, "Pausing channel {}", new Object[] {  });
      this.f.pause();
      pausedSounds.add();
    }
  }
  
  public void f() {
    for (String  : this.pausedSounds) {
      b.debug(a, "Resuming channel {}", new Object[] {  });
      this.f.play();
    }

    pausedSounds.clear();
  }

Obfuscation as of earlier versions can be found here.

There are other ways it could be fixed, but this is the simplest way.


Some additional oddities with jukeboxes that aren't necessarily part of this (from MC-35896):
a) In survival mode, ejecting a disc while breaking the jukebox block may make the jukebox music permanent (Goes off after exiting the world). (Both survival and creative mode). (separate bug?)
b) Sometimes, when destroying the jukebox block (After a) ALL music can go off (Not any music until exiting Minecraft). (Creative mode).
c) Sometimes, when playing jukebox exiting the world, jukebox music can stay on (Does not go off until exiting Minecraft). (Creative mode).

Related issues

MC-37451 music MC-37439 Two songs play at once MC-35775 Music Discs continue to play even after being ejected from Jukebox MC-35896 "Permanent" jukebox music MC-35969 i put the music record strad in the juke box when i took it out it didnt stop playing MC-36377 Jukeboxes infinitely loop record, even after being broken. Also, music overlap. MC-36379 Music Disks Play over each other MC-36382 Two musics playing at the same time MC-36400 Background Music Looping MC-36406 Music discs continue playing when removed/ play double MC-36452 When you put a music disk in a jukebox, take it out, and put it in a chest, the song is played through the jukebox even when the music disk is not in it. MC-36457 Jukeboxes will repeat same song even if disk it out of jukebox or broken, songs will also overlap. MC-36490 Music disc keeps playing MC-36565 music disks NEVER stop playing MC-36603 Sound replays after closing inventory window MC-36608 Chest Sound Bug MC-36621 Music Disc's sound file played when in chest. MC-36628 Closing inventory sometimes reset music loops MC-36630 Background Music Repeats MC-36660 Music doesn't stop. MC-36671 Music Loops after ejecting disc MC-36693 Jukebox can play several discs at once. MC-36736 Same music plays straight after it plays the first time MC-36738 Infinite Music! MC-36745 Minecraft Freezes When Playing Records MC-36757 2 default music playing at same time MC-36759 The jukebox still playing when it is destroyed MC-36787 Two songs can play at the same time MC-36851 Door sound when unpausing MC-36878 songs and sounds were playing all at once MC-36931 Closing a chest plays the opening and closing sounds MC-36944 1.7.1 Bugs MC-36969 Any sound plays twice MC-36975 Music playing all the time MC-36981 Chest sound duplication MC-37007 Odd music bug MC-37022 Music playing two times at once MC-37045 Musical Starting Errors MC-37053 2 Musics or more played at the same time . MC-37097 Two background music stack each other MC-37136 Multiple environment music pieces play simultaniously. MC-37146 minecraft 1.7.2 multiple songs play at once MC-37149 Two melody at the same time MC-37193 Sound duplication with chest MC-37232 Sounds play twice when opening inventory. MC-37235 Placing a redstone torch down then going into a Command block or Game menu then pressing esc to get out makes the redstone torch placing sound again MC-37248 Music on map open MC-37267 Recurring sounds MC-37268 Music Bug MC-37281 Screwed-Up Music MC-37292 Multiple default in-game songs playing at the same time MC-37359 Music Crossover MC-37393 Multiple music tracks play simultaneously in title screen MC-37412 the sound of clicking on a option plays when your in the option menu when you hit esc MC-37608 Tracks of background music overlap MC-37631 Music Glitch MC-37646 Sounds will duplicate when opening inventory while they play MC-37713 The sound effect for a closing chest plays twice if you go to inventory MC-37727 Chest opening sound plays twice if closing quickly MC-37816 Multiple Music tracks playing simultaneously MC-37824 Sounds are played twice sometimes MC-37927 Multiple music tracks play simultaneously MC-38054 Double Song MC-38119 Music Plays At Same Time MC-38145 Multiple music tracks play at same time. MC-38166 Multiple music simultaneously MC-38229 Music bug MC-38586 Chest sounds MC-38599 Music in 1.7.2: the music was playing twice at the same time, slightly out of time; also, once I turned music off and it kept playing MC-38601 chest MC-38684 Chests close sound plays twice MC-38722 Duplicated Chest Sound MC-38791 Multiple music at once MC-38810 Sound repeating bug MC-38813 When you break a block (try stone first) and immediately press "E" and after 1-2 seconds press "E" again and the break block sound will repeat. MC-38888 Chests playing open sound and close when closing MC-38892 Blocks sometimes make double sounds MC-38946 Sound MC-39252 Sounds glitch [1.7.2] MC-39317 Chest sound bug MC-39845 sound dublicate when exit inventory MC-40294 Sound Delay Glitch MC-40723 Chest Sound MC-41241 Sounds playing twice when closing inventory MC-41244 Door Closing Occasionally Produces 2 Sounds. MC-41538 Chest sounds duplicating MC-41707 double chest/door sound MC-41723 Minecraft sound bug MC-41782 Single/double chest sound played twice MC-41995 Command Block Sound Glitch MC-42224 Twice door sound playing MC-42337 duplication sound after pause MC-44508 Chest opening sound plays again when closing if mouse is not moved MC-45319 Sound playing twice. MC-45850 Command "playsound" plays when exit a command block MC-45901 Noise Copying MC-46407 If you close a chest then spam open and close a crafting table, furnace, or any inventory then it will continue to use the chest sounds MC-47295 Extra Sounds MC-47802 Sounds reapeat when the player opens the inventory and close it MC-48308 Dispencers refresh on closing container MC-49078 Double noise MC-50909 Sounds are derpy when pausing MC-51542 extra sounds played after closing a book MC-51584 Sound repetition MC-51933 double sounds MC-51935 Sound MC-52131 opening and closing the inventory after breaking blocks causes the block breaking sound to play again MC-52494 Duplicate Sounds MC-54994 Music would overlap. MC-55171 sound bug when closing UI MC-55174 Duplicated sound when pressing "E" MC-55203 Chest audio - Duplication of "Open" sound when opening and closing to quickly MC-56297 Double Sounds MC-59084 Chest sounds are broken when you close it. MC-61516 Sound Bug MC-62042 Repeatedly closing menus plays all nearby sounds (e.g. villagers) MC-63467 Repeated chest sound effects MC-64015 Sound Repeating Glitches MC-66936 Sound glitch: Menu + Breaking block MC-68076 Pick-up sound replays occasionally MC-68927 Sounds that are playing when the inventory is opened will repeat when the inventory is closed. MC-69398 Sound dont stop MC-70148 Chest close sound replays MC-70300 Sounds can be repeated forever MC-70610 Chest closing sound plays when closing player inventory after closing chests MC-71222 Minecraft Bug :: Signs Duplicating Sounds MC-72776 Jukebox will sometimes restart song. MC-73405 Extra XP sound MC-73727 Command block plays a sound twice if powered by a trapped chest MC-74325 Inventory Sound Repeating MC-74568 Sound Bug MC-75785 Sound repeats when closing GUI MC-77162 Picking up sound plays twice MC-77392 Chest closing sound plays when exiting inventory. MC-77468 Note blocks acting weird when opening GUIs MC-78161 Chest plays sound twice MC-79045 When you close an inventory the last sound is played. MC-79795 playsound plays sound twice if used too quick MC-80063 Chest Bug MC-81093 duplicate sound bug MC-81115 Clicking sounds in books MC-81116 Sounds reapeat in menus MC-81376 Certain sounds repeat when esc is spammed. MC-81458 Chest opening sound sometimes plays before chest closing sound when getting out of chest menu MC-82225 /playsound inventory sound repeat MC-84192 Sound repeating x3 MC-84808 Sound repeat after closing second GUI MC-85437 block breaking sound replays (opening inventory) MC-87280 Chest closing sound duplicates MC-87791 Commandblocks repeat sounds MC-90369 commandblock sound bug MC-90972 sound errors in chests MC-94964 Progressive sounds repeat when using command block. MC-96204 Audio GUI Repeats Sound MC-96346 Chest Opening sound repeats on chest closing MC-96353 Record plays again after closing book and quill MC-97265 Noteblock bug MC-69756 duplicating sound with GUI's/(Graphical User Interface)'s

Comments

CubeTheThird

Can confirm. It didn't always work, but it did indeed occur.

kumasasa

Can not confirm in 13w42b

migrated

I get this with every music disc, and it does not happen because of opening and closing the inventory. I simply removed the disc from the jukebox and the song stopped for a few seconds, then continued.

Jeuv

This is one of the most annoying bugs in minecraft in my opinion, especially together with MC-35860.

migrated

Can confirm in 13w43a. Jukebox don't stop music.

migrated

STILL OCCURRING in 1.7! Come'on Mojang, don't release partially made games like EA or Rockstar. We expect better. Just saying.

migrated

I can still replicate in 1.7.1 by breaking/placing a block or open/close a chest (MC-36603 and MC-36608).

migrated

This is happening to me when placing blocks too, if I place dirt, and go into my inventory immediately to grab more, it plays again. It doesn't happen all the time.

migrated

I just want to confirm... this bug ticket is in existence not JUST for the jukebox music but also for the normal background music too right?

migrated

Windows 7, Java 1.7.0_45, Minecraft 1.7.1
I can confirm this with opening/closing chests, apparently closing it quickly triggers the opening sound.

migrated

Issue still occurs in 1.7.2

migrated

Confirmed. Issue persists in 1.7.2. Background music looping appears to be fixed and is no longer an issue, but duplicate chest sounds still persist.

migrated

Yup. I also made a video showing two Minecraft music tracks playing at the same time. I was going to post a bug report but obviously I was a good person and went and searched to see if someone else had already posted the bug. 😛

http://www.youtube.com/watch?v=io68pyzP6s8

migrated

@Zach: The background music looping is still there in 1.7.2. I just had it happen.

migrated

Still present in the latest snapshots, currently using 13w47e.

pokechu22

This bug kills my ears. Actually, a different one that is similar. It's made the game unplayable.

migrated

Pretty sure this relates to a bug I'm having where bringing up a menu (like your inventory) while a sound is playing causes the sound to play again when the menu is closed.

pokechu22

@Djome Kinoshita
I've noticed that too; it is easies to notice when you, say, place a block then immediately open a command block. I'm pretty sure it is only single player.

migrated

Still occurs in 13w49a.

EDIT: And in 1.7.3 pre-release.

migrated

Affects 1.7.4. Unpausing the game replays the last raised sound event. It's very annoying.

It appears to be related to timing — if I pause the game just as the sound is ending, I can reliably reproduce.

migrated

I also have another bug where, if I change the time using /time set, it loops through songs for if I hadn't used /time set to change the time, and also through a new ambient music loop created by a slightly off day-night cycle. It's hard to explain in words.

pokechu22

@@unknown:
Try a screen recorder. (I use windows media encoder: http://www.microsoft.com/en-us/download/details.aspx?id=17792)
Or maybe the twitch streaming thing. Or something. Not quite sure what.

migrated

I have something for this bug.
You can make it play twice (first time for a few seconds, then second time fully)
If you place the music disc in and at the same time pause the game, it plays the disc for a little while.
Once you unpause, it starts again, as if you just placed it in.
Also, if you eject the disc then pause the game at the same time, it doesn't play, but once you unpause, it plays the disc as if it was still in the jukebox.
These will not yield loops, but are a quicker way of seeing these bugs (also, you can play two or more music discs at a time with the eject and pause one).
They also don't need to be ending.

migrated

Confirming in latest snapshots (14w02a) 14w02b.

migrated

NEW for SMP:
This only works if there are 2 or more people in the world. One person must have a music disc, while the other has nothing. Simply follow these steps:
1. Have the second person hold down their right-click on the jukebox
2. Have the first person place the music disc in the jukebox
3. The music disc will pop out immediately
4a. The music will play fully with no music disc inside
OR
4b. The music will play, but finish early with no disc inside

migrated

I'd like to add this bug affects mostly every event that produces sounds. Examples:

  • Run, the footsteps sound is played, stop, the sound is still in execution for a tic further. (this one confuses me a lot, it seems a creeper is approaching me but in fact I'm still hearing my own footsteps even if I have just stopped);

  • Open a chest, the chest opening sound is played, just when the chest is fully open hit ESC, resume the game, the sound is still in execution for a tic further;

  • Skeleton shoots an arrow and it hits the floor, the arrow hit sound is played, you can hear the sound is played twice and one of them a tic ahead;

  • and so on...

It seems there's a desynch between the event and the sound or the latter is being executed twice. The sound was supposed to be played only within the duration of the event (run, open, hit) but it's noticeable the sound is being played a tic further.

migrated

Confirmed in 14w10c

migrated

Please for the love of god update the description. I believe why this bug has never been fixed is because of the instructions. You can't duplicate this bug with those instructions so please update the description!!!!!!!!

migrated

I was really hoping this would have gotten fixed in 1.7 still, because I will be playing 1.7.x for a long time to come because of mods.
I just tried it in the 1.7.10-pre2, and it is still present :/
The problem based on in-game experiences is, that sounds play an extra time when the player opens his inventory while a sound is still playing, and then closes the inventory again pretty quickly. This often happens when browsing chests and opening and closing the inventory/chests a lot, and it gets really confusing and annoying quickly.
I recorded a short video demonstration in the just released 1.7.10-pre2: http://youtu.be/7f6X4cuPRGA

migrated
migrated

Issue still persists in 14w30c.

migrated

Issue much more noticeable in latest snapshot's remote multiplayer.

migrated

14w33a:
Changing gamemodes will stop background music, and at one point there were 2 background songs playing at once (not sure how to reproduce).

migrated

Also part of this issue: Opening the Command-Block GUI freezes the game, but not the music. When exiting, the music often repeats

migrated

I have also been able to confirm this with the game chat.

migrated

confirm. everytime like i splash a potion on the ground, and then press esc, and resume and press esc again the sound resume and it is a little bit weird

migrated

Confirmed for 1.8-pre1.

Sonicwave

Confirmed for 1.8-pre2.

migrated

Confirmed for 1.8-pre3.

Sonicwave

Confirmed for 1.8.

migrated

At 1.8:

The same goes for every sound, and opening and closing the inventory. Breaking grass, footsteps, getting objetcs, increasing exp, etc. You break something, press E before the sound stop, and then press E again, and you hear the sound.

I can understand that it happens presing 'Esc', because of some kind of sound bug or problem pausing and replaying a sound.

But opening the inventory? Why?

The amazing and lovely misteries of Minecraft.

migrated

Why do so many people keep posting very similar comments? There is no need to keep commenting that the record sounds can be replayed, or opening and closing a chest or the inventory repeats sounds.

Sonicwave

A mod should remove some of the older/unimportant affected versions so that the list isn't quite so long 😉

migrated

No, it's relevant for basic record keeping. You don't need the list to be easy to read. Checking the latest affected version is easy to do.
By the way Aaron Rhodes, comments like that never help either...

kumasasa

@@unknown: Exactly (both)

migrated

It is not only the inventory screen, it is the chat window as well.

migrated

@Nicholas Braden
Can we just clear this up here? This works with EVERY SINGLE GUI and EVERY SINGLE sound.

Sonicwave

Confirmed for 1.8.1-pre1.

migrated

Confirmed for 1.8.2-pre1.

Also affects any sound played in a certain time limit before opening inventory. Even affect normal music game, if your volume is set to 0%, the music that was playing continues to play but at a lower volume, if put back the music in a 100% a music frame it's listen very strong and the initial volume is returned.

Bentroen

Confirmed for 1.8.2-pre2, pre3 and pre4.

migrated

Confirmed for 1.8.2-pre6 so that means it is in pre5 aswell. https://www.youtube.com/watch?v=iTYaiIlSo0E

migrated

Could the reporter or a mod edit the description, because this bug affects ALL sounds (afaik). It is not just the jukebox.
For example block breaking and placing and walking sounds and chest sounds loop when you quickly open and close your inventory after the sound started playing. It gets really confusing at times.

Sonicwave

MC-80063 confirms 1.8.4

migrated

Confirmed for 1.8.5 and 1.8.6

migrated

I wonder if it could occur before the sound file is not actually over, but is silent to make it sound better (less abrupt). If there are a few frames where the sound hasn't ended yet, and the chest or your inventory is opened, it may trigger the sound again. Just a thought, and I don't mean to be annoying. I mean to be helpful.

migrated

Confirmed for 1.8.7

pokechu22

Alright, let me give the cause of this programmatically. It's in the displayGuiScreen method of net.minecraft.client.Minecraft (these are mcp910 mappings). Here's the code at the end of that method:

net.minecraft.client.Minecraft at the end of displayGuiScreen(GuiScreen guiScreenIn)

if (guiScreenIn != null) {
    this.setIngameNotInFocus();
    ScaledResolution var2 = new ScaledResolution(this,
            this.displayWidth, this.displayHeight);
    int var3 = var2.getScaledWidth();
    int var4 = var2.getScaledHeight();
    guiScreenIn.setWorldAndResolution(this, var3, var4);
    this.skipRenderWorld = false;
} else {
    this.mcSoundHandler.resumeSounds();
    this.setIngameFocus();
}

Now, the second to last line is what matters here:

this.mcSoundHandler.resumeSounds();

Now, when the ingame pause menu is opened (and the game is in singleplayer and not open to lan), it pauses all current sounds, but no other GUIs do so. But it resumes sounds regardless of whether it paused them when a GUI is closed.

Now, that wouldn't be that bad, except that resumeSounds doesn't actually resume sounds.

The SoundHandler (net.minecraft.client.audio.SoundHandler)'s pauseSounds and resumeSounds just call the SoundManager (net.minecraft.client.audio.SoundManager)'s pauseAllSounds and resumeAllSounds methods respectively. But...

net.minecraft.client.audio.SoundManager

/**
 * Pauses all currently playing sounds
 */
public void pauseAllSounds() {
    Iterator var1 = this.playingSounds.keySet().iterator();

    while (var1.hasNext()) {
        String var2 = (String) var1.next();
        logger.debug(LOG_MARKER, "Pausing channel {}",
                new Object[] { var2 });
        this.sndSystem.pause(var2);
    }
}

/**
 * Resumes playing all currently playing sounds (after pauseAllSounds)
 */
public void resumeAllSounds() {
    Iterator var1 = this.playingSounds.keySet().iterator();

    while (var1.hasNext()) {
        String var2 = (String) var1.next();
        logger.debug(LOG_MARKER, "Resuming channel {}",
                new Object[] { var2 });
        this.sndSystem.play(var2);
    }
}

The code in resumeAllSounds is perfectly fine if it paused them in the first place. But if it isn't, this appears to allow it to play multiple times, if the timing is good. Otherwise, it'll just resume an already-playing sound (which is, more or less, fine, since it won't start it from the beginning again). You probably could get better info by enabling debug-level logging (which there is for the SoundManager, but I couldn't get it enabled).

I think the required timing is that you need to unpause it before updateAllSounds removes it.

The simple fix that isn't very good is to just remove the call to resumeAllSounds, which will mess up the pause menu resuming sounds. Alternatively, more thorough logic could be used to see if sounds were already paused, but I feel like this would be prone to failure. But the best solution is just to track what sounds were paused, and only resume those.

Something like this:

private List<String> pausedSounds = Lists.newArrayList();

/**
 * Pauses all currently playing sounds
 */
public void pauseAllSounds() {
    Iterator var1 = this.playingSounds.keySet().iterator();

    while (var1.hasNext()) {
        String var2 = (String) var1.next();
        logger.debug(LOG_MARKER, "Pausing channel {}",
                new Object[] { var2 });
        pausedSounds.add(var2);
        this.sndSystem.pause(var2);
    }
}

/**
 * Resumes playing all currently playing sounds (after pauseAllSounds)
 */
public void resumeAllSounds() {
    Iterator var1 = this.pausedSounds.iterator();

    while (var1.hasNext()) {
        String var2 = (String) var1.next();
        
        logger.debug(LOG_MARKER, "Resuming channel {}",
                new Object[] { var2 });
        this.sndSystem.play(var2);
        
        pausedSounds.clear();
    }
}

Or more humanly-readable (this is a guess on what it should look like if it weren't decompiled):

private List<String> pausedSounds = Lists.newArrayList();

/**
 * Pauses all currently playing sounds
 */
public void pauseAllSounds() {
    for (String channel : playingSounds.keySet()) {
        logger.debug(LOG_MARKER, "Pausing channel {}",
                new Object[] { channel });
        pausedSounds.add(channel);
        this.sndSystem.pause(channel);
    }
}

/**
 * Resumes playing all currently playing sounds (after pauseAllSounds)
 */
public void resumeAllSounds() {
    for (String channel : pausedSounds) {
        logger.debug(LOG_MARKER, "Resuming channel {}",
                new Object[] { channel });
        this.sndSystem.play(channel);
    }
    
    pausedSounds.clear();
}

Hopefully this is helpful.

Also, note that this doesn't fix the jukebox being broken when the disk is inserted glitch, but it does fix the repeated block sounds when closing GUIs glitch.

EDIT: It also would make sense to have the sound pausing/resuming logic moved from Minecraft.java to the ingame pause screen GUI (IE, pausing it on open if the conditions are right and resuming it when the GUI is closed). That, combined with the pausedSounds list, would make this code much clearer. (It still won't fix the left+right click on jukebox glitches)


EDIT 2: Here's the code I referenced with the obfuscated mappings (and actual line numbers).

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = bsu.a(bxf), quoting lines 804 to 814.

this.mcSoundHandler.resumeSounds(); is this.aD.e() (line 812). aD is a czh.

SoundHandler.pauseSounds() is czh.a(), line 182. SoundHandler.resumeSounds() is czh.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager of type cza.

SoundManager.pauseAllSounds() is cza.e() (lines 369-372), and SoundManager.resumeAllSounds() is cza.f() (lines 376-378).

The previous fix with these mappings and line numbers:

cza, lines 369 - 378 (ish)

public void e()
    {
        for (String str : this.h.keySet()) {
            b.debug(a, "Pausing channel {}", new Object[] { str });
            this.e.pause(str);
        }
    
        pausedSounds.addAll(this.h.keySet());
    }
    
    public void f()
    {
        for (String str : pausedSounds) {
            b.debug(a, "Resuming channel {}", new Object[] { str });
            this.e.play(str);
        }
    
        pausedSounds.clear();
    }

Is this helpful?

migrated

Your solution seems very clear and easy to deploy. The jukebox issue is another problem, less important than this one (for me).

migrated

Sorry for the duplicate thread. i could not find any correct matches using the keyword "Sound"

migrated

Would the sounds of mobs/events in general restarting/stacking-and-being-louder when exiting out of the inventory, pause menu, and command block menus count as the same glitch? I'd rather ask here than make a duplicate and waste moderator's time. What I mean is that if a lot of sounds are playing, and you go into any of those menus, then exit out, they all stack on each other and can be pretty loud sometimes, and can restart long sounds like the cave warning and such.

migrated

@Wyatt Boyle

Yes.

pokechu22

Reproduced in 1.8.8 (both the jukebox portion and repeating audio portion).


EDIT: 1.8.8 mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = bsu.a(axu), quoting lines 814 to 824.

this.mcSoundHandler.resumeSounds(); is this.aH.e() (line 822). aH is a bpz.

SoundHandler.pauseSounds() is bpz.a(), line 182. SoundHandler.resumeSounds() is bpz.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager of type bpx.

SoundManager.pauseAllSounds() is bpx.e() (lines 369-372), and SoundManager.resumeAllSounds() is bpx.f() (lines 376-378).

pokechu22

Both portions reproduced in 15w31a.

15w31a mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = axc.a(azu), quoting lines 801 to 811.

this.mcSoundHandler.resumeSounds(); is this.aG.e() (line 809). aH is a bsr.

SoundHandler.pauseSounds() is bsr.a(), line 182. SoundHandler.resumeSounds() is bsr.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager of type bsp.

SoundManager.pauseAllSounds() is bsp.e() (lines 369-372), and SoundManager.resumeAllSounds() is bsp.f() (lines 376-378).

Sonicwave

Confirmed for 15w31b.

pokechu22

Confirmed for 15w31c. Same obf as previous comment.

pokechu22

Confirmed for 15w32a.

15w32a mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = axz.a(bar), quoting lines 801 to 811.

this.mcSoundHandler.resumeSounds(); is this.aG.e() (line 809). aG is a bto.

SoundHandler.pauseSounds() is bto.a(), line 182. SoundHandler.resumeSounds() is bto.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager (btm).

SoundManager.pauseAllSounds() is btm.e() (lines 369-372), and SoundManager.resumeAllSounds() is btm.f() (lines 376-378).

Sonicwave

Confirmed for 15w32b.

pokechu22

15w32b mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = ayh.a(bax), quoting lines 801 to 811.

this.mcSoundHandler.resumeSounds(); is this.aG.e() (line 809). aG is a bua.

SoundHandler.pauseSounds() is bua.a(), line 182. SoundHandler.resumeSounds() is bua.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager (bty).

SoundManager.pauseAllSounds() is bty.e() (lines 369-372), and SoundManager.resumeAllSounds() is bty.f() (lines 376-378).

pokechu22

Confirmed in 15w33a, 15w33b, and 15w33c. Sorry for the delay.


15w33a and 15w33b mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = ayt.a(bbj), quoting lines 804 to 814.

this.mcSoundHandler.resumeSounds(); is this.aH.e() (line 812). aH is a buo.

SoundHandler.pauseSounds() is buo.a(), line 182. SoundHandler.resumeSounds() is buo.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager (bum).

SoundManager.pauseAllSounds() is bum.e() (lines 369-372), and SoundManager.resumeAllSounds() is bum.f() (lines 376-378).


15w33c mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = ayy.a(bbo), quoting lines 806 to 816.

this.mcSoundHandler.resumeSounds(); is this.aH.e() (line 814). aH is a buu.

SoundHandler.pauseSounds() is buu.a(), line 182. SoundHandler.resumeSounds() is buu.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager (bus).

SoundManager.pauseAllSounds() is bus.e() (lines 369-372), and SoundManager.resumeAllSounds() is bus.f() (lines 376-378).

pokechu22

Confirmed in 15w34a.


15w34a mappings for this comment:

net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) = azc.a(bbs), quoting lines 806 to 816.

this.mcSoundHandler.resumeSounds(); is this.aH.e() (line 814). aH is a buz.

SoundHandler.pauseSounds() is buz.a(), line 182. SoundHandler.resumeSounds() is buz.e(), line 199. Both call the corresponding methods on the f field, which is the SoundManager (bux).

SoundManager.pauseAllSounds() is bux.e() (lines 369-372), and SoundManager.resumeAllSounds() is bux.f() (lines 376-378).

migrated

Giving you this ticket too, original reporter seems inactive.

migrated

Can confirm for 15w39c.

Please fix this. It's getting very irritating!

pokechu22

@@unknown It should be in the effects versions list already. I probably could actually write a mod for 1.8.8 and / or snapshot versions if I wanted to (it's a relatively small change to fix it) but I've had issues getting things to recompile.

migrated

Confirmed for 15w42a. A sound also replays when executing a command just after the sound played.

migrated

Confirmed for 15w44a and 15w44b

pokechu22

Yep, I put 15w44b in the list of versions (plus I also updated the obfuscation info).

migrated

@Pokechu22 Yes, I'm sorry, I saw it right after I made the edit, but I thought I shouldn't edit it again, since an extra mail would be sent.

migrated

Confirmed for 15w45a

migrated

The summary should say this also happens when executing a command or talking using the chat.

pokechu22

@@unknown: Done.

migrated

Confirmed for 15w47a and 15w47c

tryashtar

In case we need one, I've can confirm 15w51b.

migrated

This also happens with some mob sounds, notably pigs and villagers.

migrated

Affects 16w06a.

migrated

Affects 16w07a.

migrated

Affects 16w07b.

Erik Broes

Very well described issue, I can indeed get a sound replaying but not the actual song.

The main issue seems to be that sounds can get stopped but when you pause them you should only keep track of the ACTUALLY playing sounds at that moment.

It is doing this now, this should fix this bug.

migrated

Cool thanks 🙂

migrated

I tested it, and it's indeed fixed in the pre-release 2. Awesome!

pokechu22

Erik Broes

Confirmed

audio, chest, inventory, jukebox, loop, music, music-disc, overlap, record, restart

Minecraft 13w42a, Minecraft 13w42b, Minecraft 13w43a, Minecraft 1.7, Minecraft 1.7.1, ..., Minecraft 16w05b, Minecraft 16w06a, Minecraft 16w07a, Minecraft 16w07b, Minecraft 1.9 Pre-Release 1

Minecraft 1.9 Pre-Release 2

Retrieved