Skip to content

Restore the accurate libobs effect-caching comment - #250

Merged
iamfatness merged 1 commit into
mainfrom
fix/effect-caching-comment
Sep 6, 2026
Merged

Restore the accurate libobs effect-caching comment#250
iamfatness merged 1 commit into
mainfrom
fix/effect-caching-comment

Conversation

@iamfatness

Copy link
Copy Markdown
Owner

A review finding during #249 claimed gs_effect_create_from_file() allocates a fresh effect on every call. I acted on it before it had been verified against libobs, and the resulting comments asserted the opposite of the truth — one of them explicitly telling the next reader that the earlier, correct version had been mistaken. That is worse than the original, since it actively steers someone away from correct behaviour.

The reviewer subsequently checked the actual source and retracted the finding. Verified:

  • libobs/graphics/graphics.c, gs_effect_create_from_file() — consults find_cached_effect(file) first and returns the existing effect; gs_effect_create() sets cached = true for any file-created effect.
  • libobs/graphics/effect.c, gs_effect_destroy() — guards the real free with if (!effect->cached), so destroying a cached effect is a no-op until obs_free_graphics().

So the Tiles wall and the Loudness Meter share one gs_effect_t*, each tiles_effect_destroy() is a no-op, and there is neither a double compile nor a double-free nor a leak.

Both comments now carry the source references inline so this stops flip-flopping.

Comments only — no behaviour change. Plugin builds clean, 60/60 tests green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WqDL6gcoVvEMXv7Qwcni9n

…omment

A review finding claimed gs_effect_create_from_file() allocates a fresh
effect per call, and I acted on it before it had been checked against
libobs. It was wrong, and the resulting comments asserted the opposite of
the truth — one of them explicitly telling the next reader that the
earlier, correct version had been mistaken.

Verified in libobs source this time:
  graphics.c  gs_effect_create_from_file() consults find_cached_effect()
              first and returns the existing effect; gs_effect_create()
              sets cached = true for any file-created effect.
  effect.c    gs_effect_destroy() guards the real free with
              if (!effect->cached), so destroying a cached effect is a
              no-op until obs_free_graphics().

So the Tiles wall and the Loudness Meter share one gs_effect_t*, each
destroy is a no-op, and there is neither a double compile nor a
double-free. Both comments now carry the source references so this stops
flip-flopping.

Comments only; no behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WqDL6gcoVvEMXv7Qwcni9n
@iamfatness
iamfatness merged commit 67ae173 into main Sep 6, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant