fix(flights): compose the map at the width the ticker asked for - #304
fix(flights): compose the map at the width the ticker asked for#304ChuckBuilds wants to merge 1 commit into
Conversation
Noticed on a live rig: the flight map came back at two different sizes.
Vegas asks a plugin for a narrower render so a layout built for the full panel
does not read as sparse in the ticker. It normally delivers that by narrowing
the shared canvas for the duration of the call, which a plugin sizing itself
from matrix.width picks up with no changes of its own. But it cannot narrow
the canvas in offscreen mode -- _render_at swaps the shared canvas, which is
unsafe there -- so it only sets the hint, and notes that a plugin reading
get_vegas_render_width() still gets the narrow size while one that reads only
matrix.width "renders full width and is trimmed instead".
This plugin relied on the canvas being narrowed; its own docstring said the
projection scales "without any extra plumbing". Measured over two hours on the
rig, that assumption held 3 times out of 12:
Native: requesting 256px instead of 512px
Native: SUCCESS - 1 images, 512px total width <- cropped afterwards
Native: SUCCESS - 1 images, 256px total width
so which width came back depended on a path the plugin cannot see, and the
full-width renders composed a map twice the needed width to have most of it
thrown away.
The width property now reads the hint. That covers both paths and falls back
to the panel width outside a Vegas request, so the rotation is unaffected. The
composite cache is already keyed by (width, height) and its comment already
says "Rotation and Vegas render the same map at different widths", so this
adds a cache entry rather than invalidating one.
No plugin in the repo read get_vegas_render_width() before this, despite core
providing and documenting it. Nine other plugins currently render full-width
frames that the adapter then trims by 56-83%; they are candidates for the same
treatment but each needs its own layout thought, so this fixes the one with a
measured problem.
test_vegas_render_width.py asserts the width follows the request, returns to
the panel width afterwards, and falls back on a nonsense hint, plus that the
cache still keys on size. Mutation-checked: reverting to matrix.width fails it.
The harness sets both display_manager and _display_manager_ref deliberately:
this plugin keeps the private name while BasePlugin stores the same object
under the public one, and get_vegas_render_width()'s fallback reads the public
one. A stub with only the private name makes the fallback miss the matrix and
return its hard-coded 128, which looks exactly like the property being broken.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 9 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Superseded by #314, which combines the four ledmatrix-flights PRs into one version bump. Every change from this PR is verified present on that branch; the branch here is untouched if you want to compare. |
Follow-up to the observation that the flight map "is always a different size". It is — and which size you get depends on a code path the plugin cannot see.
What happens
Vegas asks a plugin for a narrower render so a full-panel layout doesn't read as sparse in the ticker. It normally delivers that by narrowing the shared canvas for the call, which a plugin sizing itself from
matrix.widthpicks up for free.But it cannot narrow the canvas in offscreen mode —
_render_atswaps the shared canvas, which is unsafe there — so it only sets the hint. Core's own comment says as much:This plugin relied on the canvas being narrowed; its docstring said the projection scales "without any extra plumbing". Measured over two hours on the rig, that held 3 times out of 12:
So the map was composed at twice the needed width and most of it thrown away, on 9 of 12 requests.
The fix
The width property reads the hint. It covers both paths and falls back to the panel width outside a Vegas request, so the rotation is untouched.
The composite cache is already keyed by size, and its comment already says "Rotation and Vegas render the same map at different widths" — so this adds a cache entry rather than invalidating one. That was worth checking before changing anything, given a size-keyed cache is exactly where I found a thrash in the radar last time.
Wider finding
No plugin in the repo read
get_vegas_render_width()before this, despite core providing and documenting it. Nine others currently render full-width frames the adapter then trims:They're candidates for the same treatment, but each needs its own layout thought — a tighter arrangement, not just a smaller canvas. This fixes the one with a measured problem.
Verification
test_vegas_render_width.py: the width follows the request, returns to the panel width afterwards, falls back on a nonsense hint (0,-1,"wide",None), and the cache still keys on size. Mutation-checked — reverting tomatrix.widthfails it. All 9 flights suites pass.One trap the test caught, worth recording: the harness must set both
display_managerand_display_manager_ref. This plugin keeps the private name;BasePluginstores the same object under the public one, andget_vegas_render_width()'s fallback reads the public one. A stub with only the private name makes the fallback miss the matrix and return its hard-coded128— which looks exactly like the property being broken, and briefly convinced me the fix was wrong.🤖 Generated with Claude Code
https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW