fix(football): adaptive cards keep fitted logos, not full-size sources (3.18.6) - #619
Merged
Merged
Conversation
GameRenderer._load_raw_logo cached every logo unresized, up to 128 per renderer, in each of the renderers the plugin builds. NFL logos are 768x768 RGBA (2.3 MB decoded), so the display's memory grew by hundreds of MB over a day of live games. Cache the fitted logo instead (_fit_logo); the source is read, fitted and released on a miss. Pixel-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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 | 32 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Football's adaptive card layout (
layout_mode: "adaptive") cached every team logo it loaded at full size, up to 128 per renderer, in each of the several renderers the plugin builds (a scorebug per manager, scroll cards, Vegas cards). The source files are 768x768 RGBA for the NFL (2.3 MB decoded) and 500x500 for most of NCAA, so these caches grew by hundreds of MB as a day of live games brought new teams on screen.The card only ever draws the logo fitted into its slot, so that is what is cached now:
_fit_logo(abbr, path, slot)caches the fitted result, keyed by logo directory, abbreviation and slot size (same league scoping as before, see_logo_scope)._load_raw_logono longer caches: on a miss it reads the file, converts it, and the source is released after the fit.test_adaptive_layout_mode.pygoldens pass).How it was found
Reported: the display process on ledpi (Pi 4, 1.8 GB) grew 30-40 MB/h during live sports (325 MB at 3 min, 431 MB at 90 min, 549 MB at 6 h), flat with no games. Football runs in adaptive layout there.
mallinfo2(),/procand a PIL-image census sampled every minute. Over 15 h of Saturday games (3 arms: default arenas,MALLOC_ARENA_MAX=2, and the real service), the total footprint went 370 -> ~700 MB; the live malloc heap grew 164 -> 280 MB in the first 4 h and then stayed flat.MALLOC_ARENA_MAX=2made no difference (677 vs 705 MB at 15 h).GameRenderer.__dict__['_raw_logo_cache']['nfl_logos:GB']etc. -- 768x768 RGBA logos, unresized.Test
test_adaptive_logos_not_kept_full_size.pydraws 40 teams with 768x768 logos through one renderer and walks everything it holds:test_adaptive_logo_league_scope.py's last check now looks at the fitted cache (the raw one is gone).Plugin suite: 65 passed, 1 failed --
test_football_plugin.py, which prompts for input ("Would you like to run a 30-second emulator test?") and fails the same way without this change. Guards:check_version_bump(3.18.5 -> 3.18.6),check_manifest_version_fields,check_manifests_ascii,check_min_core_version,check_module_collisions,check_sports_drift,check_sports_helpers_parity,test_espn_dates_copiesall pass. No core change; min core stays 3.8.0.Only football has this cache: no other plugin calls
fit_imageor keeps unresized logos.🤖 Generated with Claude Code