.llms/rules/ACR_zero_dimension_guard.md
Severity: CRITICAL — D92552358 fixed crash MID 7da93ace143f44f0a0c328eaca7d3029
width or height variables for frame/bitmap operationsgetFrame(), loadFrame(), loadNextFrames() or similar animation methodswidth or height used without preceding > 0 or != 0 checkgetFrame(frameNumber, width, height) without guardsif (width > 0 && height > 0) blocks// BAD — no dimension guard, crashes before view layout complete
fun getFrame(frameNumber: Int, width: Int, height: Int): FrameResult {
if (cachedFrameIndex == null) {
return loadFrame(frameNumber, width, height) // ❌ Crashes if width=0
}
}
// GOOD — guard against zero dimensions
fun getFrame(frameNumber: Int, width: Int, height: Int): FrameResult {
if (cachedFrameIndex == null || width == 0 || height == 0) {
return findNearestToRender() // ✅ Graceful fallback
}
return loadFrame(frameNumber, width, height)
}
Always validate width > 0 && height > 0 before:
BufferFrameLoader.getFrame() crashed when called with zero dimensions before view layoutloadNextFrames() wasted resources loading frames that couldn't be displayedAuto-generated by 10x-auto-code-reviewer plugin from analysis of fresco diffs (2025-12-16 to 2026-03-16). Source patterns: D92552358, D92552368