Skip to content

Preserve refresh rates in protobuf saves - #1433

Merged
Eli Pinkerton (wallstop) merged 2 commits into
mainfrom
fix/proto-resolution-refresh-rate
Dec 5, 2026
Merged

Eli Pinkerton (wallstop) merged 2 commits into
mainfrom
fix/proto-resolution-refresh-rate

Conversation

@wallstop

Copy link
Copy Markdown
Collaborator

DISCLOSURE: LLM-GENERATED TEXT

Why

Protobuf saves lose the display refresh rate when loaded on modern Unity.

What

  • Preserve the exact refresh-rate ratio in protobuf-net and WallstopProto.
  • Keep the whole-hertz field readable on Unity 2021.3 and restore it from older saves.
  • Cover both binary backends, the hybrid serializer, and generated settings contracts.

Refs #1432

Modern Unity exposes a rational refresh rate, but the protobuf surrogate
discarded the rate on read. Keep the legacy whole-hertz field and append
the exact pair so both protobuf backends preserve modern display settings.

Cover historical payloads, cross-backend reads, older readers, and the
generated member and root paths.

Refs #1432
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Resolution protobuf saves now preserve exact refresh-rate ratios through two added fields while retaining the rounded whole-hertz field. Conversion and tests cover historical data, modern Unity versions, and serializer interoperability.

Changes: Display refresh-rate serialization

Layer / File(s) Summary
Shared rounding and JSON conversion
Runtime/Core/Serialization/ResolutionRefreshRate.cs, Runtime/Core/Serialization/ResolutionRefreshRate.cs.meta, Runtime/Core/Serialization/JsonConverters/ResolutionConverter.cs
A shared helper rounds ratios to whole hertz, returns zero for a zero denominator, and caps the result at int.MaxValue. The JSON converter uses the helper when reading or writing refresh-rate ratios.
Protobuf surrogate conversion
Runtime/Core/Serialization/ProtobufUnitySurrogates.cs, Runtime/Core/Serialization/WProtoUnitySurrogateMarshals.cs
ResolutionSurrogate adds numerator and denominator fields at protobuf tags 4 and 5. On Unity 2022.2 or newer, conversion stores the exact ratio and the rounded whole-hertz value. Conversion back restores the ratio when present, or uses a positive whole-hertz value as a denominator-1 ratio. Equality and hashing include both new fields. Marshal conversion remains unchanged; its obsolete remarks and warning directives are removed.
Compatibility tests and documentation
Generator~/WallstopStudios.UnityHelpers.Proto.Generator.Tests/Compatibility*.v1.json, Tests/Runtime/DataStructures/PublicStructEqualityBehaviorTests.cs, Tests/Runtime/Serialization/ResolutionProtobufTests.cs, Tests/Runtime/Serialization/WProtoSurrogateParityTests.cs, Tests/Runtime/Serialization/WProtoUnitySurrogateMarshalTests.cs, Tests/Runtime/Serialization/ResolutionProtobufTests.cs.meta, docs/features/serialization/serialization.md, CHANGELOG.md
Tests cover historical and modern saves, fractional and edge-case rates, generated contracts, field equality, and WProto/protobuf-net interoperability. The compatibility inventory and guide record the new fields and version-specific behavior. The changelog records the refresh-rate preservation change.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Resolution
  participant ResolutionSurrogate
  participant ProtobufBytes
  Resolution->>ResolutionSurrogate: ToSurrogate stores ratio and rounded refreshRate
  ResolutionSurrogate->>ProtobufBytes: Serialize dimensions and refresh-rate fields
  ProtobufBytes->>ResolutionSurrogate: Deserialize stored fields
  ResolutionSurrogate->>Resolution: Restore ratio fields or legacy whole-hertz value
Loading

Possibly related issues

  • Issue 1432: The PR adds exact numerator and denominator fields while retaining the whole-hertz field described in the issue.
  • Issue 1430: The PR updates ResolutionConverter to use shared refresh-rate rounding. The available change summary does not confirm whether it addresses the issue’s reported legacy whole-hertz JSON restoration behavior.
Merge Risk: Minimal · up to b4090

This change preserves exact display refresh rates in protobuf saves and keeps older saves readable. No merge-blocking issue was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: protobuf saves now keep display refresh rates. The changeset adds an exact refresh-rate ratio (numerator and denominator) to the protobuf ResolutionSurrogate, keeps th…
Description check Passed The description follows the template. It has a one-sentence Why, a What section with three one-line bullets, and a Refs line linking #1432. The description adds a disclosure line at the top, which the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: protobuf saves now keep display refresh rates. The changeset adds an exact refresh-rate ratio (numerator and denominator) to the protobuf ResolutionSurrogate, keeps the whole-hertz field for Unity 2021.3, and adds tests and docs. The title is specific and matches the primary objective in the PR objectives.

Full details: Description check

Explanation

The description follows the template. It has a one-sentence Why, a What section with three one-line bullets, and a Refs line linking #1432. The description adds a disclosure line at the top, which the template does not require. The Why says protobuf saves lose the refresh rate on modern Unity, which states the problem. The What bullets cover the exact ratio, the whole-hertz field for Unity 2021.3, and the backends and contracts covered. The description does not say whether the linked issue is complete, so it does not use Fixes, which is correct. The description is brief, which the template asks for.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review details

Context from checks skipped due to timeout: 14

  • GitHub Check: Unity 6000.6.0f1 (selected modes)
  • GitHub Check: Unity package export smoke
  • GitHub Check: CodeRabbit
  • GitHub Check: generator
  • GitHub Check: Windows tools (orchestration)
  • GitHub Check: Type-check (controls)
  • GitHub Check: Contract Suites (shard 0)
  • GitHub Check: Type-check (sources)
  • GitHub Check: Contract Suites (shard 2)
  • GitHub Check: Contract Suites (shard 1)
  • GitHub Check: Contract Suites (shard 3)
  • GitHub Check: Repo Lint (shard 1)
  • GitHub Check: Repo Lint (shard 2)
  • GitHub Check: Windows tools (metadata)
Additional context used

Code guidelines: 4

.llm/context.md — auto-discovered
.agents/skills/add-inspector-attribute/SKILL.md — Agent Skill
.agents/skills/honest-gates/SKILL.md — Agent Skill
.claude/skills/test-odin-drawers/SKILL.md — Agent Skill
Path-based instructions: 3

Applicability reference: AGENTS.md: # Repository Guidelines See the [AI Agent Guidelines](./.llm/context.md) for all AI agent guidelines.

CodeRabbit inference engine (.llm/context.md)

Files:

  • Runtime/Core/Serialization/ProtobufUnitySurrogates.cs
  • Tests/Runtime/Serialization/ResolutionProtobufDisplaySettings.cs
  • Tests/Runtime/Serialization/ResolutionProtobufTests.cs
Source excerpt:

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DISCLOSURE: LLM-GENERATED TEXT

OpenAI review: 1 finding.

The added test contract violates the repository’s nested-type rule and will fail the one-type-per-file lint.

11440 in, 3074 out tokens. Comments only; this review never blocks a merge.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Dec 4, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DISCLOSURE: LLM-GENERATED TEXT

OpenAI review: 0 findings.

No defects found in the diff.

11633 in, 1387 out tokens. Comments only; this review never blocks a merge.

@wallstop
Eli Pinkerton (wallstop) merged commit 36d30e1 into main Dec 5, 2026
34 checks passed
@wallstop
Eli Pinkerton (wallstop) deleted the fix/proto-resolution-refresh-rate branch December 5, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant