libSceAjm.native: Ratchet & Clank: Rift Apart hangs at the title screen because a run after the ATRAC9 gapless total decodes the last superframe's padding as a new segment #11700

Closed
opened 2026-10-27 04:05:21 +00:00 by Tamalero · 0 comments
Tamalero commented 2026-10-27 04:05:21 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-27T04:05:21Z.


Ratchet & Clank: Rift Apart freezes on its title screen ("Press X to start"): the main thread stops, and pressing X does nothing. The trace shows that AnyPS5 decodes 3 frames past an ATRAC9 sound's gapless total. The game's mixer then waits forever for input it never has. With the segment kept ended after the total, the title gets past the title screen to the save slot screen. This conflicts with the rule #2052 added for PPSA29141, so I'd like to know what the console does before proposing a fix.

Title: Ratchet & Clank: Rift Apart (PPSA01474 v01.005.003)
Where it stops: title screen, after the first ATRAC9 sound with a gapless total ends. main abed03546 plus #9749 (with #9633), #10906 and #10000, and one local change that skips the two compute dispatches whose recompile #9749 still refuses (GetImageResource dword 0). Without that skip it stops earlier, on those shaders.
Linux 7.3 (CachyOS), i9-14900K, RTX 4090 with NVIDIA 615.78.08. Froze in 2 of 2 runs without the change below (one of them on an older main), passed in 1 of 1 with it.

What the AJM trace shows

APS5_TRACE_AJM=1, the instance that plays the sound (codec 1, 2 channels, 48 kHz, 512-byte superframes of 4 frames; resampled at a ratio of about 1.28):

[ajm] instance 16425 set gapless decode: total 296960, skip 256, reset 0 (sideband 8 bytes)
...
[ajm] instance 16425 run flags 0x800000000000: 641 input bytes ... -> result 0x0, decoder status 0x0, 2 frames, consumed 260, produced 1964, total samples 296960, gapless total 296960 skip 256 skipped 256
[ajm] instance 16425 run flags 0x800000000000: 381 input bytes ... -> result 0x0, decoder status 0x0, 3 frames, consumed 381, produced 2048, total samples 297728, gapless total 296960 skip 256 skipped 256
[ajm] instance 16425 run flags 0x800000000000: 0 input bytes ... -> result 0x0, decoder status 0x0, 0 frames, consumed 0, produced 352, total samples 297728, ...
[ajm] instance 16425 run flags 0x800000000000: 0 input bytes ... -> result 0x0, decoder status 0x0, 0 frames, consumed 0, produced 0, total samples 297728, ...
  • The run that reaches the total stops there, as #2052 intended, and leaves 381 bytes of the last superframe unconsumed.
  • RunAt9 then resets segmentSamples (if (segmentEnded()) instance.segmentSamples = 0;), so the next run starts a new segment and decodes the 3 remaining frames of that superframe (768 samples past the total). 296960 + 256 skipped is 1161 frames, so the total ends after the first frame of the last superframe and the other 3 frames are the encoder's padding.
  • The game counts every output buffer against its own copy of the sound's length. In a gdb snapshot of the hang, the mixer thread loops in app.elf+0x2707e60–+0x2707eb3 with its read position equal to its limit, 296960 (0x48800), still owing 550–654 input samples for the extra buffer. It holds the mixer lock, and the main thread waits on that lock.

Local experiment

A local switch (not pushed) keeps the segment ended until a reset (SetGaplessDecode with the reset flag, ClearContext or initialization): with APS5_AJM_GAPLESS_END_HOLDS=1 the line above does not reset segmentSamples.

[ajm] instance 16424 set gapless decode: total 296960, skip 256, reset 0 (sideband 8 bytes)
[ajm] instance 16424 run flags 0x800000000000: 381 input bytes ... -> result 0x0, decoder status 0x0, 0 frames, consumed 0, produced 0, total samples 296960, gapless total 296960 skip 256 skipped 256

The title resubmits the 381 bytes a few times (6 in this run), gets no output, and stops asking. The mixer does not hang, and the title moves on from the title screen to the save slot screen.

What I don't know

#2052 added the reset because FMOD in PPSA29141 sets a total shorter than a sound's frames and reads the frames after it on later runs. Here the frames after the total are the padding of the superframe that holds the total, and the title wants nothing from them. I don't know what the console does after the total, so I haven't proposed a change that would break PPSA29141. @esatturan, do you know whether PPSA29141's later runs read frames in the same superframe as the total, or only from the next superframe on? If they only read from the next one, ending the segment until the next superframe would fit both titles.

A separate audio fault remains (a constant tone at the title in all three runs, with or without the switch). I'll report it separately once I've traced it.

Tested and written by Claude (AI assistant) on a contributor's machine.

Image Image Image
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6052666801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/11700). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-27T04:05:21Z. --- Ratchet & Clank: Rift Apart freezes on its title screen ("Press X to start"): the main thread stops, and pressing X does nothing. The trace shows that AnyPS5 decodes 3 frames past an ATRAC9 sound's gapless total. The game's mixer then waits forever for input it never has. With the segment kept ended after the total, the title gets past the title screen to the save slot screen. This conflicts with the rule #2052 added for PPSA29141, so I'd like to know what the console does before proposing a fix. **Title:** Ratchet & Clank: Rift Apart (PPSA01474 v01.005.003) **Where it stops:** title screen, after the first ATRAC9 sound with a gapless total ends. `main` abed03546 plus #9749 (with #9633), #10906 and #10000, and one local change that skips the two compute dispatches whose recompile #9749 still refuses (`GetImageResource dword 0`). Without that skip it stops earlier, on those shaders. Linux 7.3 (CachyOS), i9-14900K, RTX 4090 with NVIDIA 615.78.08. Froze in 2 of 2 runs without the change below (one of them on an older `main`), passed in 1 of 1 with it. ### What the AJM trace shows `APS5_TRACE_AJM=1`, the instance that plays the sound (codec 1, 2 channels, 48 kHz, 512-byte superframes of 4 frames; resampled at a ratio of about 1.28): ``` [ajm] instance 16425 set gapless decode: total 296960, skip 256, reset 0 (sideband 8 bytes) ... [ajm] instance 16425 run flags 0x800000000000: 641 input bytes ... -> result 0x0, decoder status 0x0, 2 frames, consumed 260, produced 1964, total samples 296960, gapless total 296960 skip 256 skipped 256 [ajm] instance 16425 run flags 0x800000000000: 381 input bytes ... -> result 0x0, decoder status 0x0, 3 frames, consumed 381, produced 2048, total samples 297728, gapless total 296960 skip 256 skipped 256 [ajm] instance 16425 run flags 0x800000000000: 0 input bytes ... -> result 0x0, decoder status 0x0, 0 frames, consumed 0, produced 352, total samples 297728, ... [ajm] instance 16425 run flags 0x800000000000: 0 input bytes ... -> result 0x0, decoder status 0x0, 0 frames, consumed 0, produced 0, total samples 297728, ... ``` - The run that reaches the total stops there, as #2052 intended, and leaves 381 bytes of the last superframe unconsumed. - `RunAt9` then resets `segmentSamples` (`if (segmentEnded()) instance.segmentSamples = 0;`), so the next run starts a new segment and decodes the 3 remaining frames of that superframe (768 samples past the total). 296960 + 256 skipped is 1161 frames, so the total ends after the first frame of the last superframe and the other 3 frames are the encoder's padding. - The game counts every output buffer against its own copy of the sound's length. In a gdb snapshot of the hang, the mixer thread loops in `app.elf+0x2707e60`–`+0x2707eb3` with its read position equal to its limit, 296960 (0x48800), still owing 550–654 input samples for the extra buffer. It holds the mixer lock, and the main thread waits on that lock. ### Local experiment A local switch (not pushed) keeps the segment ended until a reset (`SetGaplessDecode` with the reset flag, `ClearContext` or initialization): with `APS5_AJM_GAPLESS_END_HOLDS=1` the line above does not reset `segmentSamples`. ``` [ajm] instance 16424 set gapless decode: total 296960, skip 256, reset 0 (sideband 8 bytes) [ajm] instance 16424 run flags 0x800000000000: 381 input bytes ... -> result 0x0, decoder status 0x0, 0 frames, consumed 0, produced 0, total samples 296960, gapless total 296960 skip 256 skipped 256 ``` The title resubmits the 381 bytes a few times (6 in this run), gets no output, and stops asking. The mixer does not hang, and the title moves on from the title screen to the save slot screen. ### What I don't know #2052 added the reset because FMOD in PPSA29141 sets a total shorter than a sound's frames and reads the frames after it on later runs. Here the frames after the total are the padding of the superframe that holds the total, and the title wants nothing from them. I don't know what the console does after the total, so I haven't proposed a change that would break PPSA29141. @esatturan, do you know whether PPSA29141's later runs read frames in the same superframe as the total, or only from the next superframe on? If they only read from the next one, ending the segment until the next superframe would fit both titles. A separate audio fault remains (a constant tone at the title in all three runs, with or without the switch). I'll report it separately once I've traced it. *Tested and written by Claude (AI assistant) on a contributor's machine.* <img width="2232" height="1291" alt="Image" src="https://github.com/user-attachments/assets/a21e8ed7-6014-4448-8a83-0f0e7032856d" /> <img width="2236" height="1294" alt="Image" src="https://github.com/user-attachments/assets/5fc5eaa3-0dbb-41bd-aa13-d35774241cb6" /> <img width="2241" height="1289" alt="Image" src="https://github.com/user-attachments/assets/6dcf52aa-5251-467a-8726-f13f309668e5" />
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#11700
No description provided.