CC: Tweaked

CC: Tweaked

57M Downloads

Ticking player crash when shutting down a Noisy Pocket Computer that's playing PCM audio

BigBarza opened this issue ยท 1 comments

commented

Minecraft Version

1.16.x

Version

1.100

Details

Forge: 36.2.22
Other mods: Journeymap, JEI, The One Probe (This is a testing setup)
Config changes: None

Description:
A Noisy Pocket Computer can cause a crash when shutoff while playing the newly supported pcm audio.
Doesn't seem to be 100% consistent. Sometimes the music resumes playing for a split moment. Doesn't also seem to be the case with block computers, whether by breaking or shutting off via gui, or breaking a modem connection to the speaker.

How to reproduce:

  1. Get a Noisy Pocket Computer (Either type)
  2. Run the builtin speaker program with an url to a dfpwm file (downloaded file should also work)
  3. Shutoff the pocket computer with the gui button.
  4. Crash, usually.

Logs:
Crash Report

commented
dan200.computercraft.api.peripheral.NotAttachedException: You are not attached to this computer
	at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.getAttachmentName(PeripheralAPI.java:156) ~[computercraft:1.100.0] {re:classloading}
	at dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral.update(SpeakerPeripheral.java:146) ~[computercraft:1.100.0] {re:classloading}
	at dan200.computercraft.shared.pocket.peripherals.PocketSpeaker.update(PocketSpeaker.java:45) ~[computercraft:1.100.0] {re:classloading}
	at dan200.computercraft.shared.pocket.items.ItemPocketComputer.tick(ItemPocketComputer.java:112) ~[computercraft:1.100.0] {re:classloading}

In case the paste expires.

This is probably critical enough it merits a 1.100.1 :/. Wonder why this happens, but doesn't for other peripherals.

Note to future self

We need a lock on the attack/detach methods and the computer iterator. We're currently doing Collections.newSetFromMap( new HashMap<>() ) (which I guess was meant to be a ConcurrentHashMap), but this isn't sufficient, as we need a guarantee that detach hasn't completed when looping over computers.