Title: CRC of objects with references is not comparable across separate databases · Issue #74 · Unity-Technologies/UnityDataTools · GitHub
Open Graph Title: CRC of objects with references is not comparable across separate databases · Issue #74 · Unity-Technologies/UnityDataTools
X Title: CRC of objects with references is not comparable across separate databases · Issue #74 · Unity-Technologies/UnityDataTools
Description: Summary objects.crc32 is meant to be a content fingerprint, and the comparing-builds workflow expects you can analyze two builds into two separate databases and diff CRCs to find which objects changed. That works for leaf assets (Texture...
Open Graph Description: Summary objects.crc32 is meant to be a content fingerprint, and the comparing-builds workflow expects you can analyze two builds into two separate databases and diff CRCs to find which objects chan...
X Description: Summary objects.crc32 is meant to be a content fingerprint, and the comparing-builds workflow expects you can analyze two builds into two separate databases and diff CRCs to find which objects chan...
Opengraph URL: https://github.com/Unity-Technologies/UnityDataTools/issues/74
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CRC of objects with references is not comparable across separate databases","articleBody":"## Summary\n\n`objects.crc32` is meant to be a content fingerprint, and the [comparing-builds](Documentation/comparing-builds.md) workflow expects you can analyze two builds into two separate databases and diff CRCs to find which objects changed. That works for leaf assets (Texture2D/Mesh/AudioClip — no references), but it is **broken for any object that contains references** (Materials, prefabs/GameObjects, MonoBehaviours, etc.): identical content produces different CRCs in two separate `analyze` runs.\n\n## Cause\n\nWhen `PPtrAndCrcProcessor.ExtractPPtr` folds a reference into the CRC, it uses the **resolved analyzer/database object id** returned by the callback, not the PPtr's own identity:\n\n```csharp\nvar refId = m_Callback(m_ObjectId, fileId, pathId, ...); // analyzer db id\nm_Crc32 = Crc32Algorithm.Append(m_Crc32, \u003crefId bytes\u003e);\n```\n\nThat id comes from `ObjectIdProvider.GetId((m_LocalToDbFileId[fileId], pathId))`, and both the serialized-file id and the object id are assigned **sequentially per analyze run**. So the same logical object gets different ids in db1 vs db2 → different CRC for identical content → cross-database comparison reports spurious differences for every object that has references.\n\n## Why we can't just hash the raw PPtr (the tradeoff)\n\nThe obvious fix is to hash the raw on-disk PPtr (`fileId` + `pathId`) instead of the resolved id. But the resolved id is currently what makes **within-database** duplicate detection (`view_potential_duplicates`) work across bundles: two copies of the same object in different bundles reference the same target, and resolving through `m_LocalToDbFileId` (keyed by filename) + `pathId` normalizes them to the same id → same CRC → detected as duplicates.\n\n`fileId` is a **local index** into a serialized file's external-reference list, so two copies of an object in different bundles can have different `fileId` values for the same target. Hashing the raw PPtr would therefore weaken duplicate detection. Deduplication is an important feature and is probably not well covered by tests yet, so we don't want to risk regressing it.\n\n## Options to evaluate\n\n1. **Raw PPtr (`fileId` + `pathId`)** — simplest; fixes cross-db comparison in the common case; risks weakening `view_potential_duplicates` (local `fileId` differs between bundles).\n2. **Stable target identity + `pathId`** — resolve `fileId` to a stable identifier for the target file and hash that + `pathId`, so it is independent of the local index. This fixes cross-db comparison AND preserves cross-bundle duplicate detection, but the \"stable identifier\" differs by source:\n * **Build output** external references carry a **path** (e.g. `archive:/CAB-...`), not a GUID.\n * **Editor / Library** references carry a **GUID** (the source asset's GUID).\n So the CRC needs to mix in whichever of `ExternalReference.Path` / `ExternalReference.Guid` is populated (and a fixed marker for local refs, `fileId == 0`). Relies on those fields being present and stable.\n More code: thread the external-reference info from `sf.ExternalReferences` into the CRC.\n3. Status quo — cross-db comparison stays broken for referenced objects.\n\n## Prerequisite\n\nAdd test coverage for `view_potential_duplicates` / cross-bundle deduplication before changing the CRC, so a fix can be validated to not regress it.\n\n## Context\n\nDiscovered while reviewing #73 / #70. Note that this is independent of the CRC changes made there (the ManagedReferenceData size fix, the ComputeCRC chunking fix, and the cah:/ stream hashing) — those also change CRC values vs. older tool versions, so CRCs are not comparable across tool versions regardless.\n\nRelated: #44 (refs table).","author":{"url":"https://github.com/SkowronskiAndrew","@type":"Person","name":"SkowronskiAndrew"},"datePublished":"2026-06-12T00:53:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/74/UnityDataTools/issues/74"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d22c968c-b2f3-09b1-3c27-ad092a7a4b1b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB62:3FD786:6DDA103:974A6DB:6A5EB300 |
| html-safe-nonce | 77dbe83534519fa1c1ef0984cdb8aab3cce5ef35d7001de6cd80dd63e408f588 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjYyOjNGRDc4Njo2RERBMTAzOjk3NEE2REI6NkE1RUIzMDAiLCJ2aXNpdG9yX2lkIjoiNjM1MDg3MzMxMzc5Njg2MjcyMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 20874d467de029bf7ba6de5d78d2fee3c9fa95413969492770dd2bef2d74bd3d |
| hovercard-subject-tag | issue:4645310733 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Unity-Technologies/UnityDataTools/74/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c8e7bf5ab9782769b532ed3db0726b76e865440c8005472e2299b966c1f11504/Unity-Technologies/UnityDataTools/issues/74 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c8e7bf5ab9782769b532ed3db0726b76e865440c8005472e2299b966c1f11504/Unity-Technologies/UnityDataTools/issues/74 |
| og:image:alt | Summary objects.crc32 is meant to be a content fingerprint, and the comparing-builds workflow expects you can analyze two builds into two separate databases and diff CRCs to find which objects chan... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SkowronskiAndrew |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7129250e6854dcc7bfa46fc877bb154b96762b31e3fa82fdf0697c71f08bb32c |
| turbo-cache-control | no-preview |
| go-import | github.com/Unity-Technologies/UnityDataTools git https://github.com/Unity-Technologies/UnityDataTools.git |
| octolytics-dimension-user_id | 426196 |
| octolytics-dimension-user_login | Unity-Technologies |
| octolytics-dimension-repository_id | 472365703 |
| octolytics-dimension-repository_nwo | Unity-Technologies/UnityDataTools |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 472365703 |
| octolytics-dimension-repository_network_root_nwo | Unity-Technologies/UnityDataTools |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3084c198d559e243975a7a7f61d0b80bcea2a724 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width