Skip to content

fix(rapier): reject snapshot restore after body membership changes - #299

Open
Ram-Dawson wants to merge 2 commits into
bdero:masterfrom
Ram-Dawson:fix/rapier-snapshot-membership
Open

fix(rapier): reject snapshot restore after body membership changes#299
Ram-Dawson wants to merge 2 commits into
bdero:masterfrom
Ram-Dawson:fix/rapier-snapshot-membership

Conversation

@Ram-Dawson

Copy link
Copy Markdown
Contributor

Fixes #298

Problem

Native Rapier snapshots can restore the native world, but do not recreate Dart pose targets or application-owned body registrations. restore() could accept a snapshot after a body was created or destroyed, leaving the native world and Dart body registry out of sync.

Change

Encode the Dart body-handle set alongside the native snapshot bytes. Decode and compare that set with the current _bodies keys before calling native restore. Return false when membership differs, leaving the current native world untouched.

Validation

  • From packages/flutter_scene_rapier: fvm flutter test test/world_snapshot_test.dart
  • The focused test covers a body created after snapshot and a body destroyed after snapshot; both reject restore and continue simulation safely.
  • The companion reproduction repository provides the failing baseline and fixed tag for the same Android interaction.

Scope and limitation

This PR protects the low-level RapierWorld contract. It does not implement application-level object-graph rollback, automatically destroy Dart-owned objects, reconstruct external pose targets, or change snapshot behavior when body membership is unchanged.

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.

Rapier restore accepts snapshots after body membership changes

1 participant