[#77] Detect missing TypeTrees up front in analyze and dump#78
Open
SkowronskiAndrew wants to merge 3 commits into
Open
[#77] Detect missing TypeTrees up front in analyze and dump#78SkowronskiAndrew wants to merge 3 commits into
SkowronskiAndrew wants to merge 3 commits into
Conversation
…eading errors Analyzing AssetBundles whose SerializedFiles have no TypeTrees handed the files to the native loader, which emitted misleading "Invalid serialized file version" errors and could crash the process with an access violation (0xC0000005) that cannot be caught in .NET. Detect missing TypeTrees before the native open and skip such files cleanly, printing the existing "does not have TypeTrees" hint. This unifies the previously inconsistent outcomes (misleading errors, hard crash, or "Invalid object id") into the same clear message the loose-file path already produces, for both loose files and files inside archives. - SerializedFileDetector: add stream-based overloads of TryDetectSerializedFile and TryParseMetadata (path-based ones delegate to them), a parseExtended flag to read only the EnableTypeTree flag cheaply, and IsMissingTypeTrees. - UnityFileStream: a read/seek Stream over UnityFile so detection works on real paths and archive:/ entries inside a mounted bundle. - SerializedFileSQLiteWriter: reject no-TypeTree files before OpenSerializedFile. - SerializedFileOpenException: add a MissingTypeTrees flag. - AnalyzerTool: report no-TypeTree files in a new "Files without TypeTrees" summary category, distinct from genuine failures.
Now that analyze detects missing TypeTrees and skips the file before any open attempt, the "...can only be opened if all the types exactly match..." note is misleading: the file is never handed to the loader regardless of the API build. Drop the note from the analyze "Skipped (no TypeTrees)" output. The now-dead GetOpenFailureHint call in the generic open-failure path is also removed, since missing-TypeTree files are caught earlier. The hint is retained for the dump command, which still attempts the open and where the explanation is accurate.
dump can never interpret a SerializedFile without TypeTrees, yet it handed such files to the native loader, producing misleading version mismatch errors and a raw SerializedFileOpenException with a stack trace (and, for archives, no clean handling at all). Detect missing TypeTrees before opening for both the direct-SerializedFile and the Unity Archive paths, and print a clear message explaining dump cannot process the file. This reuses the same SerializedFileDetector.IsMissingTypeTrees check the analyzer uses. With the dump path no longer relying on it, the now-unused GetOpenFailureHint and MissingTypeTreesHint are removed from SerializedFileDetector.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #77.
Problem
Running
analyzeordumpon SerializedFiles without TypeTrees (e.g. player builds / AssetBundles built without type information) produced poor output:Invalid serialized file version. Expected: ... Actual: ...to stderr. The version mismatch is a symptom; the real cause is the missing TypeTrees.Fatal error. 0xC0000005plus a long managed stack trace. This is a native access violation that cannot be caught in .NET.Loose
dumpfailures additionally surfaced a rawSerializedFileOpenExceptionwith a stack trace, and the archivedumppath had no clean handling at all.Fix
Detect missing TypeTrees before handing the file to the native loader (works for both loose files and entries inside a mounted archive), and handle the case cleanly. This pre-empts both the misleading stderr output and the crash, since the file is never opened natively.
SerializedFileDetector— added stream-based overloads ofTryDetectSerializedFile/TryParseMetadata(the path-based ones now delegate to them), aparseExtendedflag so only the few bytes needed for theEnableTypeTreeflag are read, and anIsMissingTypeTrees(Stream)helper.UnityFileStream(new) — a read/seekStreamoverUnityFile, so detection works on real paths andarchive:/…entries.analyze— rejects no-TypeTree files before opening and reports them in a newFiles without TypeTreessummary category, distinct from genuine failures.dump— prints a clear message that it cannot dump a file without TypeTrees, for both the direct-file and archive paths.SerializedFileOpenException— gained aMissingTypeTreesflag.GetOpenFailureHint/MissingTypeTreesHintit relied on.Before / after (
analyze)Before / after (
dumpon a no-TypeTree AssetBundle)Testing