CNA-GAP-005: DrawableGameComponent loads content once in Initialize and never follows the graphics device service

CNA snapshot 009d40f5  ·  Known Issues › Functional gaps  ·  source links pinned to 009d40f5

✓

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

It never subscribes to IGraphicsDeviceService.DeviceCreated/DeviceDisposing (OnDeviceCreated is dead code), whereas XNA 4.0 requires the service, reloads on DeviceCreated and unloads on DeviceDisposing.

Identifier
CNA-GAP-005
Category
Functional gap
Subsystem
Core & runtime
Status
Open
Verified against
CNA 009d40f5 (009d40f5dd085c4e674d3479675fac84b12b3e0a)
Evidence basis
Source-verified: read at TARGET, not executed
Tests touching this area
None
Affected contract
Microsoft::Xna::Framework::DrawableGameComponent::Initialize(), LoadContent(), UnloadContent()

Expected behaviour

XNA 4.0's DrawableGameComponent.Initialize looks up IGraphicsDeviceService (throwing if absent), hooks DeviceCreated and DeviceDisposing, and loads content if a device already exists, so a component reloads after a device re-creation and unloads before disposal.

Actual behaviour at TARGET

DrawableGameComponent.cpp's Initialize calls LoadContent() once, with the comment "Full device-service event hookup belongs to IGraphicsDeviceService. Until that service exists..." - although GraphicsDeviceManager now registers that service and raises DeviceCreated/DeviceDisposing. OnDeviceCreated exists but nothing subscribes it; UnloadContent runs only from Dispose.

Source locations

Evidence

Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry. In CNA's Game the device is rarely re-created, which limits the practical effect to unload timing and to games that re-create devices.

Focused reproduction

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

Current tests

DrawableGameComponentTests.cpp does not cover device events.

Regression test

A test that raises DeviceDisposing and DeviceCreated on the service and asserts UnloadContent/LoadContent calls on a registered DrawableGameComponent.

Blast radius

DrawableGameComponent subclasses that load GPU resources in LoadContent and expect XNA's reload/unload around device changes.

Workaround

Subscribe to the manager's DeviceCreated/DeviceDisposing in the component yourself.

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