Skip to content

ToDynamicAsset() fails with conflicting Script ID hashes #2

Description

@therealchjones

ToDynamicAsset() method uses a static dictionary via GetDeserializer() that indexes deserializers based on hashes of ScriptIDs, but then loading slightly different types with the same hash can cause an error. (For me, this happens when opening analogous AssetBundleFiles from different versions of the same program.) It appears that assets within the same version of an application don't have any overlaps in hashes, but there are collisions with different types between different versions. (See, for instance, the attached test project.) While exceptions are thrown sometimes when this happens, it may be that others fail silently.

This can be mitigated by calling GenDeserializer directly rather than using GetDeserializer (or, therefore, ToDynamicAsset), but this of course gets rid of the benefit of the cache. Rather than making this a static method (and static dictionary), would it be preferable to make it a property of the AssetBundleFile so that loading different assetbundles would not result in these errors? Another possibility would be the addition of a method to "reset" the static dictionary when necessary to load a different version that may have overlapping hashes.

DynamicAssetTest.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions