CNA-BUG-278: An XNB BoundingSphere or Model mesh sphere with a negative radius fails to load, although XNA and CNA's own XNB writer accept it

CNA snapshot c6dec91f  ·  Known Issues › Current bugs  ·  source links pinned to c6dec91f

✓

Evidence basis: source-verified at the pinned commit; tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit c6dec91f; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.

ContentReader::ReadBoundingSphere builds the sphere through the validating BoundingSphere(Vector3, float) constructor, so a negative radius in a .xnb throws System::ArgumentException, where XNA's reader assigns Center and Radius as stored.

Identifier
CNA-BUG-278
Category
Bug
Subsystem
Content & XNB/CNB/CNJ
Status
Open
Verified against
CNA c6dec91f (c6dec91fbf3ef5440f60e5329e4a4758b2d80c22)
Severity
Low (a triage suggestion, not a project priority)
Evidence basis
Source-verified: read at TARGET, not executed
Tests touching this area
Yes: see Current tests
Affected contract
ContentManager::Load of an .xnb holding a BoundingSphere (BoundingSphereReader) or a Model (the per-mesh bounding sphere)

Expected behaviour

XNA 4.0's ContentReader.ReadBoundingSphere reads the centre and the radius into the sphere's fields without a check, so content that stores a negative radius (a degenerate or hand-made asset) loads, and a Model's mesh bounds stay advisory. CNA's own XNB writer follows XNA here: it writes such a sphere rather than refusing it.

Actual behaviour at TARGET

At this snapshot ContentReader::ReadBoundingSphere returns BoundingSphere(center, radius), and since e1377c437 that constructor (BoundingSphere.cpp) throws System::ArgumentException for a negative radius. The Model reader takes each mesh's sphere through the same call (XnbModelGraphReader.hpp), so one negative mesh radius fails the whole model load. The writer side accepts the same value on purpose: the fuzz seed “a bounding sphere with a negative radius and a NaN centre” in XnbWriterInputFuzzTests.cpp expects Outcome::Written (“XNA writes the sphere the content gave it, and a Model's own bounds are advisory”), so a file CNA writes can be one CNA cannot read back.

Source locations

Evidence

Read at c6dec91f: the reader and constructor code above, and the writer fuzz seed that documents the XNA writer behaviour. XNA 4.0's reader behaviour was read in the XNA 4.0 Framework assembly (it assigns the two fields). Nothing was built or run for this entry; no test loads an .xnb with a negative radius.

Focused reproduction

No focused reproduction is known. Nothing has been invented here; the evidence above is what exists.

Current tests

PrimitiveAndMathReaderTest.BoundingSphereReaderRoundTrips covers an ordinary sphere only; the writer fuzz test writes a negative radius but never reads it back.

Regression test

Read a BoundingSphereReader payload and a Model whose mesh sphere has radius -1 and assert that both load with the stored values, as in XNA.

Blast radius

Only content that stores a negative radius: degenerate or hand-made spheres and models exported with broken bounds. Normal pipeline output has non-negative radii.

Workaround

Fix the radius in the source asset, or rebuild the content so the pipeline recomputes the bounds.

The same subject is explained at several altitudes. These are the neighbouring pages at each one.

User guide
XNB Loading
Known issues
Bug index