Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewind cleanups #16958

Merged
merged 4 commits into from
Feb 14, 2023
Merged

Rewind cleanups #16958

merged 4 commits into from
Feb 14, 2023

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Feb 13, 2023

Replaces #16955 .

Cleans up some code, switches to MeasureAndSavePtr everywhere for safety.

Also changes the setting to be based on wall-time seconds. Spamming rewind saves when fast-forwarding doesn't make that much sense, IMHO, and this is simply easier to understand when configuring and framerate-independent.

I guess could also be based on in-game seconds to keep the ease of configuration, but I think this is fine. Opinions?

@hrydgard hrydgard added the User Interface PPSSPP's own user interface / UX label Feb 13, 2023
@hrydgard hrydgard added this to the v1.15.0 milestone Feb 13, 2023
@hrydgard hrydgard mentioned this pull request Feb 13, 2023
Copy link
Collaborator

@unknownbrackets unknownbrackets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably fine if it's based on real seconds, although it does mean if you suffered some lag or got some notifications or something you might have some unnecessarily close states.

I've abused rewind to trap an event and export out the rewind state before last as an actual save state file, so as to make it easier to find things. I think that would still work using wall or game seconds.

-[Unknown]

Common/Serialize/Serializer.h Outdated Show resolved Hide resolved
_class.DoState(p);

if (p.error != PointerWrap::ERROR_FAILURE && (expected_end == ptr || expected_size == 0)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might still be nice to validate that the size we got to matched measuredSize, we've had bugs in the past so it's nice if it trips.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done internally in CheckAfterWrite.

Core/SaveState.cpp Outdated Show resolved Hide resolved
@@ -1054,8 +1054,8 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
return UI::EVENT_CONTINUE;
});
lockedMhz->SetZeroLabel(sy->T("Auto"));
PopupSliderChoice *rewindFreq = systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, sy->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (mem hog)"), screenManager(), sy->T("frames, 0:off")));
rewindFreq->SetZeroLabel(sy->T("Off"));
PopupSliderChoice *rewindInterval = systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindSnapshotInterval, 0, 30, sy->T("Rewind Snapshot Interval"), screenManager(), sy->T("seconds, 0:off")));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably no reason the max couldn't be 60, giving you one every minute.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that, changing.

if (!data)
return ERROR_BAD_ALLOC;

saved->resize(measuredSize);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think this was a problem before but it'd be more likely now (and especially if using zstd.)

If the compress thread is running and didn't finish before this one, the resize might relocate the memory and cause a crash. Before it would only resize up, which was still a problem, but perhaps less likely.

One solution would be to stall on compressThread_.join(); before starting a new Save().

Maybe this was the crash you saw before.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the flaky crash I saw before was just the iterator assert, which for whatever reason wasn't triggered every time.

But yes, we should join the compressThread_ before saving (or allow concurrent ones with their own buffers, but kinda overkill). Fixing.

@unknownbrackets unknownbrackets merged commit 5ce4321 into master Feb 14, 2023
@unknownbrackets unknownbrackets deleted the rewind-cleanups branch February 14, 2023 14:58
brianblakely added a commit to brianblakely/libretro-super that referenced this pull request Mar 2, 2023
Support was added on the PPSSPP side in 2021 (crashing bug fixed):
hrydgard/ppsspp@379f075
And further enhanced recently in 2023:
hrydgard/ppsspp#16958
However, this info file was never updated, so the 2021 update was made incompatible again after this RA update in 2022:
libretro/RetroArch@e541dd5

This commit should bring everything back in line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User Interface PPSSPP's own user interface / UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants