Skip to content

Conversation

@matt-edmondson
Copy link
Contributor

@matt-edmondson matt-edmondson commented Aug 5, 2025

Note

Adds a GPU-aware FontMemoryGuard with fallbacks and integrates it into font initialization, plus tests, config hooks, and build/dependency updates.

  • Core (ImGuiApp):
    • Integrates FontMemoryGuard into InitFonts() with GPU detection, memory estimation, and fallback strategies (reduced sizes, disable emojis, reduced Unicode).
    • Adds helpers: ApplyFallbackConstraints, ShouldLoadEmojis, ShouldUseReducedUnicode, GetConstrainedGlyphRanges, LogFontAtlasInfo.
    • Logs atlas size/memory; uses constrained glyph ranges; minor logging adjustments.
  • New Component:
    • ImGuiApp/FontMemoryGuard.cs: GPU memory detection (NVIDIA/AMD extensions, Intel/AMD APU heuristics), config (FontMemoryConfig), estimation (FontMemoryEstimate), strategies (FallbackStrategy), range reducers and utilities.
  • Config:
    • ImGuiAppConfig: adds FontMemoryConfig to control font memory limits/behavior.
  • Tests:
    • ImGuiApp.Test/FontMemoryGuardTests.cs: unit tests for estimation, fallbacks, heuristics, config, and logging.
    • ImGuiApp.Test/ImGuiAppTests.cs: updates to support new APIs/usings.
  • Build/Deps:
    • Target frameworks updated to net9.0 (libs, tests, demo).
    • Bumps deps: Hexa.NET.ImGui, SixLabors.ImageSharp, System.Text.Json, MSTest packages; updates global.json SDKs.

Written by Cursor Bugbot for commit dad3369. This will update automatically on new commits. Configure here.

…o limit texture memory allocation for fonts, enhancing performance on low-end GPUs. Updated font initialization to incorporate memory constraints and fallback strategies, ensuring efficient resource usage. Updated package versions for dependencies.
…methods to public, enhancing accessibility. Updated integrated GPU detection patterns for AMD and Intel, and improved memory limit calculations for both GPU types. Added comprehensive unit tests for FontMemoryGuard functionality, ensuring robust memory estimation and GPU detection.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
43.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@ktsu-dev ktsu-dev deleted a comment from cursor bot Aug 6, 2025
…mGuiApp.Test, and ImGuiAppDemo projects to support .NET 8.0 and 9.0. Reintroduced coverlet.collector dependency in test dependencies section of Directory.Packages.props. Updated ktsu SDK versions to 1.56.0 across all projects for improved functionality.
@matt-edmondson matt-edmondson moved this to Todo in ktsu.dev Nov 14, 2025
@matt-edmondson matt-edmondson moved this from Todo to In Progress in ktsu.dev Nov 14, 2025
@matt-edmondson
Copy link
Contributor Author

@copilot please make this branch ready to merge into main

Copy link
Contributor

Copilot AI commented Nov 14, 2025

@matt-edmondson I've opened a new pull request, #144, to work on those changes. Once the pull request is ready, I'll request review from you.

Implement font memory guards to prevent texture memory exhaustion on integrated GPUs
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

builder.BuildRanges(ref reducedRanges);

return reducedRanges.Data;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Dangling Pointer From Out-of-Scope Data

The GetReducedUnicodeRanges method returns a dangling pointer. It creates a local ImVector<uint> reducedRanges, builds glyph ranges into it, and returns reducedRanges.Data. However, the local ImVector goes out of scope immediately after the method returns, making the returned pointer invalid. This causes undefined behavior when the pointer is later used in LoadFontFromMemory. The method should follow the pattern used in FontHelper.GetExtendedUnicodeRanges by storing the ImVector in a static field to keep it alive, similar to how extendedUnicodeRanges and emojiRanges are managed.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants