# Dispatch Assignment: Explorer M2-2 (OffscreenCanvas LRU Caching & Memory)

**Assigned Agent:** `explorer_m2_2`  
**Role:** OffscreenCanvas LRU Caching & Memory Explorer  
**Working Directory:** `c:\Projects\FreeExile\.agents\teamwork\explorer_m2_2`  
**Project Scope:** `c:\Projects\FreeExile\.agents\teamwork\orchestrator_11\PROJECT.md`  
**Authoritative Request:** `c:\Projects\FreeExile\.agents\teamwork\ORIGINAL_REQUEST.md` (specifically section `## 2026-10-01T19:19:13Z` - R2)  

## Mission
Investigate the $16 \times 16$ tile chunk pre-rendering architecture, LRU cache eviction, and mobile memory budget:
1. Analyze the coordinate space and dimensions for $16 \times 16$ tile chunks:
   - In isometric projection with `TILE_W=64, TILE_H=32`, what are the pixel bounding box dimensions of an offscreen canvas for a $16 \times 16$ chunk?
   - How should chunk local coordinates be offset when blitting to the main viewport canvas?
2. Design the LRU chunk cache pool:
   - Manage active `OffscreenCanvas` (or HTML5 `canvas` fallback where `OffscreenCanvas` is unavailable in older mobile browsers).
   - Strict mobile memory budget: $\le 8\text{ MB}$ total canvas RAM (each chunk canvas memory in bytes $= \text{width} \times \text{height} \times 4$). How many active chunk canvases can fit in $8\text{ MB}$, and why is a pool of 3–4 chunks sufficient for a typical mobile screen ($414 \times 896$ or $390 \times 844$)?
   - Eviction policy: when camera pans, how to evict chunks outside the immediate 1-chunk visible border.
3. Reactive invalidation:
   - Detail the integration with `TileMapRenderer.markChunkDirty(tx, ty)` (which `tile_grid_loader.js:setTileAt` already calls).
   - Ensure dirty chunks are re-rendered on next frame without dropping frames.
4. Verify zero-allocation hot path: ensure `render(ctx, camera, viewport)` does not allocate temporary objects (`new`) during chunk blitting.

Write your findings to: `c:\Projects\FreeExile\.agents\teamwork\explorer_m2_2\report.md`  
Write your standard `handoff.md` and send a message back to parent when complete.

## 2026-10-01T20:04:00Z
You are OffscreenCanvas LRU Caching & Memory Explorer.
Your working directory is: c:\Projects\FreeExile\.agents\teamwork\explorer_m2_2
Your dispatch assignment is: c:\Projects\FreeExile\.agents\teamwork\explorer_m2_2\DISPATCH.md
MANDATORY: Read the authoritative user request at:
c:\Projects\FreeExile\.agents\teamwork\ORIGINAL_REQUEST.md (specifically section ## 2026-10-01T19:19:13Z - R2).
Also consult c:\Projects\FreeExile\GEMINI.md, c:\Projects\FreeExile\AGENTS.md, and c:\Projects\FreeExile\.agents\teamwork\orchestrator_11\PROJECT.md.

Investigate 16x16 chunk OffscreenCanvas caching architecture:
1. Compute coordinate space and pixel dimensions of 16x16 isometric chunks (TILE_W=64, TILE_H=32).
2. Design LRU chunk cache pool (3-4 active OffscreenCanvas instances, RAM <= 8 MB, zero-allocation render loop).
3. Design reactive dirty-chunk invalidation mechanism matching markChunkDirty(tx, ty) called by tile_grid_loader.js:setTileAt.
4. Define eviction policy when camera pans beyond 1-chunk visible border.

Write report.md and handoff.md in your working directory and notify parent when complete.
