mupen64plus / mupen64plus-core

Core module of the Mupen64Plus project
1.25k stars 255 forks source link

M64CORE_STATE_SAVECOMPLETE callback happens too early with M64P_PARALLEL #1031

Open alice-mkh opened 10 months ago

alice-mkh commented 10 months ago

The problem is that savestates_save_m64p() is further queueing savestates_save_m64p_work(), and yet the callback in savestates_save() happens immediately once savestates_save_m64p() exits, without waiting for the work function to finish.

So if you, say, immediately shut down the core after that callback, it will break.

This only happens with savestates_type_m64p savestates, the pj64 ones are fine, since they aren't async.

And of course since without M64P_PARALLEL there's no work queue and it just calls the function instead, the bug disappears in that case

The simplest solution would be to just do the StateChanged() call in savestates_save_m64p_work(), savestates_save_pj64_zip() or savestates_save_pj64_unc(). (or savestates_save_m64p() too if it exits immediately), instead of savestates_save(). If it's fine, I'll open a PR, not sure if there are implications I'm not aware of.

alice-mkh commented 5 months ago

Ping?

richard42 commented 4 months ago

Yes I think your suggestion is the best way to correct this problem; please file a pull request with this change.