07th-mod / 07th-mod/higurashi-assembly

Game Freeze due to while loop with no timeout

Aperta
#81 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
12
Fork
12
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I trying to deliberately trigger the stuck sprite bug, but instead caused the game to freeze (not crash). By printing out the stack trace, it seems this happens due to a while loop which never terminates.

On Matsuribayashi ch8, here an edited `_mats_op.txt` which causes the crash near the start (completely unreasonable script, but it probably shouldn't crash):

[_mats_op.txt](https://github.com/07th-mod/higurashi-assembly/files/9335411/_mats_op.txt)

The while loop appears in a couple places (there may be more than the below):

https://github.com/07th-mod/higurashi-assembly/blob/5e26440552ccf5d54a6ce2bfd68aca9f67dac9f3/Assets.Scripts.Core.Scene/SceneController.cs#L171-L183

https://github.com/07th-mod/higurashi-assembly/blob/5e26440552ccf5d54a6ce2bfd68aca9f67dac9f3/Assets.Scripts.Core.Scene/SceneController.cs#L210-L217

https://github.com/07th-mod/higurashi-assembly/blob/5e26440552ccf5d54a6ce2bfd68aca9f67dac9f3/Assets.Scripts.Core.Scene/SceneController.cs#L224-L231

It may be a good idea to add a timeout to the while loop, so at least the game doesn't crash, however doing so may put the game in an unknown state, so not sure what action should be taken if the timeout occurs.

----

The while loop relies on `layer.FadingOut` being set to false, which only happens once `ReleaseTextures()` is called (which is inside `HideLayer()`).

However, `ReleaseTextures()` won't set `layer.FadingOut` to false if `primary` (the primary texture for that layer) is `null`. primary is deliberately set to `null` in `ReleaseTextures()`, but I think it's also possible if the primary texture is destroyed or cleaned up by Unity for it to be set to `null`. So relying on `layer.FadingOut` to end the while loop seems dangerous.

https://github.com/07th-mod/higurashi-assembly/blob/5e26440552ccf5d54a6ce2bfd68aca9f67dac9f3/Assets.Scripts.Core.Scene/Layer.cs#L711-L732

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Examine the while loops in SceneController.cs at lines 171-183, 210-217, and 224-231. Understand how layer.FadingOut is set to false in Layer.cs's ReleaseTextures() method (lines 711-732). The bug occurs when the primary texture is null, preventing FadingOut from being cleared. Add a timeout mechanism to prevent infinite loops, but consider the game state after a timeout. Test with the provided _mats_op.txt script to reproduce the freeze.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, unity
Ambito
game-dev
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.