Skip to content

feat(fbuild): first-class data/ asset pipeline (#2284) - #2335

Merged
zackees merged 1 commit into
masterfrom
feat/asset-pipeline-v1-2284
Apr 19, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/asset-pipeline-v1-2284

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

v1 of the data/ asset pipeline from issue #2284. Sketches can now write
fl::UIAudio audio("Audio", FL_ASSET("data/track.mp3")); and the path
resolves to a URL on WASM (via a build-time manifest) or to a local
file / sibling .lnk URL on host/stub.

v1 scope (per issue #2284):

  • Platforms: WASM + host/stub only. ESP32 LittleFS is future work.
  • .lnk format: *.mp3.lnk — first non-blank line is the URL; subsequent
    key=value lines are metadata.
  • sha256= / fallback= metadata is parsed but not enforced (reserved
    for future integrity/retry features).
  • .. path segments are rejected at compile time via static_assert
    on FL_ASSET("..."). The constexpr fl::asset(const char*) overload
    returns an empty handle for such inputs as defense-in-depth.
  • One manifest per sketch, injected once per HTML output.

What's in the box

  • src/fl/asset.h — fl::asset_ref (trivially-copyable handle:
    const char* + fl::size), FL_ASSET() macro with compile-time
    .. rejection, fl::resolve_asset() declaration, fl::register_asset().
  • src/fl/asset.cpp.hpp — runtime resolver: process-local registry first,
    then (on host/stub only) local file probe + sibling *.lnk fallback.
  • src/fl/stl/url.h — new parse_lnk_with_metadata() returning
    LnkMetadata { primary, sha256, fallback }. Existing parse_lnk()
    unchanged — just reused.
  • src/fl/ui.h + src/fl/ui.cpp.hpp — new UIAudio(name, asset_ref)
    constructor that resolves to a fl::url then forwards to the existing
    url-based ctor. The existing url-based constructor is untouched.
  • ci/compiler/asset_scanner.py — walks <sketch>/data/ for *.lnk
    files, emits a {relative_path: {url, sha256, fallback}} manifest
    (JSON), a window.fastledAssetManifest = {...} JS snippet, and a C++
    header of fl::register_asset() calls for the generated C++ build.
  • ci/wasm_build.py — generate_asset_manifest() writes
    asset_manifest.json alongside fastled.js at build time.
  • src/platforms/wasm/compiler/index.ts — fetch and inject
    window.fastledAssetManifest at startup (idempotent, non-fatal on 404).
  • Tests:
    • tests/fl/asset.cpp — compile-time .. rejection (static_assert
      matrix), runtime resolution, host filesystem probe, sibling-.lnk
      fallback.
    • tests/fl/stl/url.cpp — parse_lnk_with_metadata metadata cases.
    • ci/tests/test_asset_scanner.py — 12 Python unit tests covering
      parsing, scanning, JSON serialization, JS snippet, and C++ header
      emission.
  • examples/AudioUrl/AudioUrl.ino — the existing inline-fl::url
    variant is KEPT (regression coverage). The FL_ASSET(...) variant is
    documented in an adjacent commented-out line. The pre-existing
    examples/AudioUrl/data/track.mp3.lnk stays in place.

Decisions made during implementation

  • asset_ref copy semantics: trivially copyable — just a const char*
    • fl::size. No ownership. The scoping report didn't nail this down;
      this matches how fl::string_view is treated and lets FL_ASSET()
      produce a constexpr-like handle.
  • Runtime registry vs JS round-trip: on WASM, the asset scanner emits
    a generated C++ header full of fl::register_asset(path, url) calls
    that the link step compiles into the sketch. That keeps
    fl::resolve_asset() fully C++-side — no EM_ASM to cross into JS.
    window.fastledAssetManifest is still injected for pure-JS consumers
    so both sides see the same source of truth.
  • Host/stub fallback: if the raw file exists on disk we return a
    fl::url wrapping the filesystem path (fl::url accepts arbitrary
    strings). If it doesn't, we read the sibling <path>.lnk.
  • Existing parse_lnk() signature is preserved; the new
    metadata-returning version is additive.

Test plan

  • bash test fl_asset — passes (8 cases incl. static_asserts).
  • bash test fl_asset --debug — passes with ASAN/UBSAN.
  • bash test url — passes (existing + new metadata cases).
  • bash test audio_url — passes (existing url-based path).
  • bash test audio / bash test ui — pass.
  • uv run python -m pytest ci/tests/test_asset_scanner.py — 12/12 pass.
  • bash lint — clean.
  • bash compile wasm --examples AudioUrl — C++ side builds fine; the
    esbuild template step fails on a pre-existing
    vendor/three/three.module.js missing-file bug, which is orthogonal
    to this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added sketch-local asset support: data/ assets can be referenced by lightweight asset handles, resolved at runtime (including a generated asset manifest for WASM).
    • UI audio components can be constructed from asset references.
    • Asset entries may include optional checksum and fallback URL metadata.
  • Documentation

    • Example updated to show asset provisioning patterns.
  • Tests

    • New unit and integration tests covering parsing, manifest generation, resolution, and safety checks.

@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a v1 sketch-local asset pipeline: a Python scanner parses data/*.lnk files and emits JSON/JS/C++ manifests; WASM build integrates manifest generation and client loader; C++ gains fl::asset_ref, registration/resolution logic, UIAudio asset constructor, and corresponding tests.

Changes

Cohort / File(s) Summary
Python asset tooling
ci/compiler/asset_scanner.py, ci/tests/test_asset_scanner.py, ci/wasm_build.py
New asset scanner parses .lnk (URL + optional sha256/fallback), produces JSON/JS/C++ manifests; WASM build step invokes manifest generation; unit tests cover parsing, scanning, and serialization.
C++ asset API & runtime
src/fl/asset.h, src/fl/asset.cpp.hpp, src/fl/_build.cpp.hpp, src/fl/build/fl.cpp
Introduces fl::asset_ref, FL_ASSET macro, register_asset, and resolve_asset with a process-local registry and host/stub disk+.lnk fallback; unity build updated to include implementation.
.lnk parsing & URL types
src/fl/stl/url.h, tests/fl/stl/url.cpp
Adds LnkMetadata and parse_lnk_with_metadata() to extract primary URL, sha256, and fallback; tests validate parsing behavior and edge cases.
UI integration
src/fl/ui.h, src/fl/ui.cpp.hpp, examples/AudioUrl/AudioUrl.ino
Adds UIAudio overload accepting fl::asset_ref and example updated to show FL_ASSET(...) usage (commented).
WASM client loader
src/platforms/wasm/compiler/index.ts
Client-side bootstrap fetches asset_manifest.json (no-cache) and assigns parsed manifest to window.fastledAssetManifest, handling missing/parse failures gracefully.
Tests
tests/fl/asset.cpp
New tests for compile-time path-safety, FL_ASSET/fl::asset() behavior, registry registration, filesystem resolution, and .lnk fallback.

Sequence Diagram(s)

sequenceDiagram
    participant Build as Build System
    participant Scanner as Python Scanner
    participant Data as Sketch data/
    participant Manifest as Generated Manifest
    participant CppReg as C++ Registration

    Build->>Scanner: scan_sketch_assets(sketch_dir)
    Scanner->>Data: list & read *.lnk
    Data-->>Scanner: file contents
    Scanner->>Scanner: parse URL, sha256, fallback
    Scanner-->>Manifest: assemble manifest entries
    Scanner-->>Build: AssetScanResult (manifest + warnings)
    Build->>Manifest: write_manifest_json(), manifest_to_js_bootstrap(), manifest_to_cpp_header()
    Manifest-->>CppReg: generated C++ registration code
Loading
sequenceDiagram
    participant Sketch as Sketch Code
    participant AssetRef as fl::asset_ref
    participant Resolver as fl::resolve_asset
    participant Registry as In-memory Registry
    participant Filesys as Host/Stub Filesystem
    participant Result as fl::url

    Sketch->>AssetRef: FL_ASSET("data/track.mp3")
    Sketch->>Resolver: resolve_asset(assetRef)
    Resolver->>Registry: lookup(path)
    alt Found in Registry
        Registry-->>Result: return registered URL
    else Not found
        Resolver->>Filesys: check <cwd>/path (file)
        alt File exists
            Filesys-->>Result: return file URL
        else Try <cwd>/path.lnk
            Filesys-->>Resolver: .lnk content
            Resolver-->>Result: parsed primary URL
        else
            Resolver-->>Result: invalid URL
        end
    end
    Result-->>Sketch: fl::url
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Hopped the data folder, sniffed each tiny link,

Turned scattered URLs to manifests in a blink.
Compile-time checks keep traversal at bay,
Runtime registry maps paths the rabbit way,
Now audio and assets sing — hip-hop hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(fbuild): first-class data/ asset pipeline' clearly and concisely describes the main change: implementing a new asset pipeline feature for data/ assets. It uses the conventional commit format, is specific to the primary change, and avoids vague or misleading terms.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/asset-pipeline-v1-2284

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (5)
ci/wasm_build.py (1)

1469-1469: Move the new scanner import to the module import block.

This new local import should live with the other top-level local imports unless there is a deliberate lazy-import requirement.

Proposed cleanup
 from ci.wasm_flags import get_link_flags, get_sketch_compile_flags
 from ci.wasm_tools import run_emcc
+from ci.compiler.asset_scanner import scan_sketch_assets, write_manifest_json
-    from ci.compiler.asset_scanner import scan_sketch_assets, write_manifest_json
-
     sketch_dir = PROJECT_ROOT / "examples" / example_name

As per coding guidelines, “All system imports must be at the top of the file in proper order: standard library, third-party, local”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/wasm_build.py` at line 1469, The import "from ci.compiler.asset_scanner
import scan_sketch_assets, write_manifest_json" is a local/module-level import
that was added mid-file; move it into the file's top import block alongside
other local imports (following standard library then third-party ordering) so
it's a top-level import rather than a late/local one; verify there is no
deliberate lazy-import dependency in functions referencing scan_sketch_assets or
write_manifest_json before making the change.
src/platforms/wasm/compiler/index.ts (1)

82-110: Use async/await for the manifest loader.

The new loader uses a .then() chain; please keep this path consistent with the project’s async style.

Proposed rewrite
-(function loadFastledAssetManifest() {
+(async function loadFastledAssetManifest() {
   // Idempotent: don't clobber a manifest that was injected earlier (e.g., by
   // server-side rendering or a test harness).
   if ((window as any).fastledAssetManifest) {
     console.log('🎛️ fastledAssetManifest already present, skipping fetch');
     return;
   }
-  fetch('asset_manifest.json', { cache: 'no-cache' })
-    .then((response) => {
-      if (!response.ok) {
-        // 404 is expected for sketches without a data/ dir; log at info level.
-        console.log(`🎛️ asset_manifest.json not present (${response.status}); continuing without manifest`);
-        (window as any).fastledAssetManifest = {};
-        return null;
-      }
-      return response.json();
-    })
-    .then((manifest) => {
-      if (manifest) {
-        (window as any).fastledAssetManifest = manifest;
-        const count = Object.keys(manifest).length;
-        console.log(`🎛️ Loaded fastledAssetManifest with ${count} entries`);
-      }
-    })
-    .catch((err) => {
-      console.warn('🎛️ asset_manifest.json fetch failed:', err);
-      (window as any).fastledAssetManifest = {};
-    });
+  try {
+    const response = await fetch('asset_manifest.json', { cache: 'no-cache' });
+    if (!response.ok) {
+      // 404 is expected for sketches without a data/ dir; log at info level.
+      console.log(`🎛️ asset_manifest.json not present (${response.status}); continuing without manifest`);
+      (window as any).fastledAssetManifest = {};
+      return;
+    }
+
+    const manifest = await response.json();
+    (window as any).fastledAssetManifest = manifest;
+    const count = Object.keys(manifest).length;
+    console.log(`🎛️ Loaded fastledAssetManifest with ${count} entries`);
+  } catch (err) {
+    console.warn('🎛️ asset_manifest.json fetch failed:', err);
+    (window as any).fastledAssetManifest = {};
+  }
 })();

As per coding guidelines, “Always use async/await for promises instead of .then() chains”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/platforms/wasm/compiler/index.ts` around lines 82 - 110, Rewrite the
immediately-invoked loadFastledAssetManifest function to use async/await: keep
the idempotent check on (window as any).fastledAssetManifest and early return,
then perform an await fetch('asset_manifest.json', { cache: 'no-cache' }) inside
a try/catch, check response.ok and if false log the same info message and assign
(window as any).fastledAssetManifest = {} and return, otherwise await
response.json(), assign it to (window as any).fastledAssetManifest, compute
Object.keys(manifest).length and log the loaded count; in the catch block log
the warning and set fastledAssetManifest = {} — preserving all original messages
and behavior but using async/await.
tests/fl/asset.cpp (2)

71-114: Registry state persists between test cases — consider resetting.

fl::register_asset pushes into a process-global static fl::vector with no cleanup hook. It happens to not collide with the subsequent tests today because the registered key (pipeline/a.mp3) is unique, and lookup_registry returns on first match — but any future test that registers an overlapping key, or re-runs the same case, will accumulate entries and silently mask regressions (especially given the "first writer wins" lookup behavior — see the companion comment on src/fl/asset.cpp.hpp).

If you want to keep the API registry-only, adding a fl::clear_registered_assets() (or per-test RAII helper) and calling it in a fixture SetUp would make these tests hermetic.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/fl/asset.cpp` around lines 71 - 114, The test suite mutates a
process-global registry via fl::register_asset which persists across tests; add
a function fl::clear_registered_assets() (or similar) in the asset registry
implementation and call it from the test fixture SetUp/tearDown (or call it at
top of each test before registering) to reset state; alternatively provide an
RAII helper (e.g., RegisteredAssetsGuard) that calls
fl::clear_registered_assets() in its destructor and use it in tests that call
fl::register_asset to ensure lookup_registry behavior is hermetic between test
cases.

88-108: Host-fallback tests depend on on-disk fixtures and working directory.

Both tests/fl/data/test_audio.ogg and examples/AudioUrl/data/track.mp3.lnk must exist at exactly those repo-relative paths, and the test process CWD must be the project root. Nothing in the test asserts or sets that up, so a future move of either fixture (or running under a different CWD — e.g. a sub-test-binary from a build dir) will convert "unknown asset" into a silent false negative rather than a helpful failure.

Consider either (a) asserting file existence at the top of each test with a clear message, or (b) constructing the fixtures in a TemporaryDirectory and chdir-ing for the duration of the test. The second option also makes the .lnk fallback assertion independent of examples/.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/fl/asset.cpp` around lines 88 - 108, The tests "fl::resolve_asset -
host fallback finds local file" and "fl::resolve_asset - host fallback finds
sibling .lnk" depend on repo-relative fixtures and CWD; make them robust by
either asserting the fixture files exist up-front or creating temporary fixtures
and switching CWD for the test. Update the FL_TEST_CASEs that call
fl::resolve_asset with asset_ref r to first check
std::filesystem::exists("tests/fl/data/test_audio.ogg") and
exists("examples/AudioUrl/data/track.mp3.lnk") (or create equivalent temp files
and a .lnk content) and fail the test with a clear message if missing, or
instead create the files in a TemporaryDirectory, chdir into it for the duration
of the test, then call fl::resolve_asset and restore CWD; reference the test
names and the fl::resolve_asset/asset_ref usage to locate where to add these
setup/assertions.
src/fl/stl/url.h (1)

274-377: DRY: line-splitting/trim logic is duplicated between parse_lnk and parse_lnk_with_metadata.

The CRLF handling and whitespace trim loop (lines 282-299 vs 335-349) are identical. Since parse_lnk_with_metadata is strictly a superset, consider making parse_lnk a one-liner wrapper:

♻️ Proposed refactor
 inline url parse_lnk(fl::string_view content) FL_NOEXCEPT {
-    fl::size pos = 0;
-    while (pos < content.size()) {
-        // … ~35 lines of line splitting / trimming / comment handling …
-        return url(line);
-    }
-    return url();
+    return parse_lnk_with_metadata(content).primary;
 }

Functionally equivalent, and keeps both parsers in lock-step going forward. Defer if you're wary of touching the existing hot path in v1.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/stl/url.h` around lines 274 - 377, The parsing/trimming logic is
duplicated between parse_lnk and parse_lnk_with_metadata; remove the duplication
by making parse_lnk delegate to parse_lnk_with_metadata (call
parse_lnk_with_metadata(content) and return its primary as a url) or by
extracting the common line-splitting/trim routine into a helper used by both;
update parse_lnk to be a simple one-liner that returns the primary URL from
LnkMetadata (use LnkMetadata::primary and parse_lnk_with_metadata) so both stay
in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/compiler/asset_scanner.py`:
- Around line 167-178: The try block around lnk_path.read_text(encoding="utf-8")
must handle KeyboardInterrupt before the other except clauses; add an except
KeyboardInterrupt as exc: that re-raises the exception (or simply "raise")
placed immediately before the UnicodeDecodeError and OSError handlers so
KeyboardInterrupt propagates instead of being caught and converted into a
warning appended to result.warnings.
- Around line 43-78: Add runtime type validation by decorating both dataclasses
AssetEntry and AssetScanResult with `@typechecked` (ensure the typechecked
decorator is imported), and replace the dict comprehension inside
AssetScanResult.to_json_dict with an explicit loop that constructs the result
dict (iterate over self.manifest items, call asdict(entry) for each, assign into
result mapping, then return result) to satisfy the "no comprehension" guideline.

In `@src/fl/asset.cpp.hpp`:
- Around line 50-61: lookup_registry currently returns the first matching entry
which makes registration behave as "first-writer-wins" despite the comment
claiming "last writer wins"; change lookup_registry to iterate the registry in
reverse (from r.size()-1 down to 0) so the most recently registered entry wins,
and audit/update any other similar lookups (the other loop mentioned around the
same area) to the same reverse-iteration pattern; also ensure the comment in
asset.h describing "Last writer wins" matches this behavior.
- Around line 92-110: The read result from fl::ifstream lnk is not validated:
after calling lnk.read(&content[0], sz) you must call lnk.gcount() (or check
lnk.good()/!lnk.fail()) and resize content to the actual bytes read or bail out
on failure; update the code around fl::ifstream lnk, the lnk.read(...) call, and
the subsequent return parse_lnk(...) so that you use the gcount result to set
content.size() (or return fl::url() on read failure) before passing the buffer
to parse_lnk.

In `@src/fl/asset.h`:
- Around line 173-174: The comment on register_asset promises "Last writer wins"
but asset_detail::lookup_registry currently returns the first match; change
lookup_registry to search newest-first (e.g., reverse-iterate the registry or
use rbegin/rend) so it returns the most recently registered asset and therefore
matches the register_asset doc, and ensure any test or call-sites expecting
lookup_registry (symbol: asset_detail::lookup_registry) still behave correctly
after reversing the iteration order.

In `@src/fl/stl/url.h`:
- Around line 361-374: The parser currently assigns key/value from the split
without trimming, causing mismatches versus the Python parser; modify the
parsing block so you trim whitespace from both fl::string_view key and value
(e.g., compute trimmed_key and trimmed_value from the existing key/value), then
use trimmed_key for the comparisons and trimmed_value when setting out.sha256
(constructing fl::string from trimmed_value) and out.fallback (constructing url
from trimmed_value); ensure unknown keys are still ignored.

---

Nitpick comments:
In `@ci/wasm_build.py`:
- Line 1469: The import "from ci.compiler.asset_scanner import
scan_sketch_assets, write_manifest_json" is a local/module-level import that was
added mid-file; move it into the file's top import block alongside other local
imports (following standard library then third-party ordering) so it's a
top-level import rather than a late/local one; verify there is no deliberate
lazy-import dependency in functions referencing scan_sketch_assets or
write_manifest_json before making the change.

In `@src/fl/stl/url.h`:
- Around line 274-377: The parsing/trimming logic is duplicated between
parse_lnk and parse_lnk_with_metadata; remove the duplication by making
parse_lnk delegate to parse_lnk_with_metadata (call
parse_lnk_with_metadata(content) and return its primary as a url) or by
extracting the common line-splitting/trim routine into a helper used by both;
update parse_lnk to be a simple one-liner that returns the primary URL from
LnkMetadata (use LnkMetadata::primary and parse_lnk_with_metadata) so both stay
in sync.

In `@src/platforms/wasm/compiler/index.ts`:
- Around line 82-110: Rewrite the immediately-invoked loadFastledAssetManifest
function to use async/await: keep the idempotent check on (window as
any).fastledAssetManifest and early return, then perform an await
fetch('asset_manifest.json', { cache: 'no-cache' }) inside a try/catch, check
response.ok and if false log the same info message and assign (window as
any).fastledAssetManifest = {} and return, otherwise await response.json(),
assign it to (window as any).fastledAssetManifest, compute
Object.keys(manifest).length and log the loaded count; in the catch block log
the warning and set fastledAssetManifest = {} — preserving all original messages
and behavior but using async/await.

In `@tests/fl/asset.cpp`:
- Around line 71-114: The test suite mutates a process-global registry via
fl::register_asset which persists across tests; add a function
fl::clear_registered_assets() (or similar) in the asset registry implementation
and call it from the test fixture SetUp/tearDown (or call it at top of each test
before registering) to reset state; alternatively provide an RAII helper (e.g.,
RegisteredAssetsGuard) that calls fl::clear_registered_assets() in its
destructor and use it in tests that call fl::register_asset to ensure
lookup_registry behavior is hermetic between test cases.
- Around line 88-108: The tests "fl::resolve_asset - host fallback finds local
file" and "fl::resolve_asset - host fallback finds sibling .lnk" depend on
repo-relative fixtures and CWD; make them robust by either asserting the fixture
files exist up-front or creating temporary fixtures and switching CWD for the
test. Update the FL_TEST_CASEs that call fl::resolve_asset with asset_ref r to
first check std::filesystem::exists("tests/fl/data/test_audio.ogg") and
exists("examples/AudioUrl/data/track.mp3.lnk") (or create equivalent temp files
and a .lnk content) and fail the test with a clear message if missing, or
instead create the files in a TemporaryDirectory, chdir into it for the duration
of the test, then call fl::resolve_asset and restore CWD; reference the test
names and the fl::resolve_asset/asset_ref usage to locate where to add these
setup/assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd2949b9-a965-4987-8968-4e782bf7ba14

📥 Commits

Reviewing files that changed from the base of the PR and between 8bb5d7c and 7191a2c.

📒 Files selected for processing (14)
  • ci/compiler/asset_scanner.py
  • ci/tests/test_asset_scanner.py
  • ci/wasm_build.py
  • examples/AudioUrl/AudioUrl.ino
  • src/fl/_build.cpp.hpp
  • src/fl/asset.cpp.hpp
  • src/fl/asset.h
  • src/fl/build/fl.cpp
  • src/fl/stl/url.h
  • src/fl/ui.cpp.hpp
  • src/fl/ui.h
  • src/platforms/wasm/compiler/index.ts
  • tests/fl/asset.cpp
  • tests/fl/stl/url.cpp

Comment on lines +43 to +78
@dataclass
class AssetEntry:
"""Resolved metadata for a single ``*.lnk`` file.

Attributes:
url: Primary URL from the first non-comment line of the ``.lnk``.
sha256: Optional hex digest declared in the ``.lnk`` (``sha256=...``).
v1 runtime ignores this; parser captures it for forward-compat.
fallback: Optional mirror URL declared in the ``.lnk`` (``fallback=...``).
v1 runtime ignores this; parser captures it for forward-compat.
"""

url: str
sha256: str | None = None
fallback: str | None = None


@dataclass
class AssetScanResult:
"""Result of scanning a sketch's ``data/`` directory.

Attributes:
manifest: Dict mapping relative asset paths (POSIX form, e.g.
``"data/track.mp3"``) to ``AssetEntry``. Missing ``data/`` or an
empty one yields an empty dict — not an error.
warnings: Non-fatal issues encountered during scanning (malformed
``.lnk`` files, unreadable files, etc.). Callers should log them
but the build should NOT fail on these.
"""

manifest: dict[str, AssetEntry] = field(default_factory=dict)
warnings: list[str] = field(default_factory=list)

def to_json_dict(self) -> dict[str, dict[str, str | None]]:
"""Return manifest as a plain nested dict for JSON serialization."""
return {key: asdict(entry) for key, entry in self.manifest.items()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guideline violations: missing @typechecked and dict comprehension.

Two repo coding-guideline items apply here:

  1. Both AssetEntry (line 43) and AssetScanResult (line 60) are @dataclass but lack @typechecked. Guideline: "Use @typechecked decorator with @dataclass for runtime type validation."
  2. to_json_dict (line 78) uses a dict comprehension. Guideline: "Use explicit loops instead of list comprehensions for code clarity and debuggability."
🔧 Proposed fix
 import json
 from dataclasses import asdict, dataclass, field
 from pathlib import Path
+
+from typeguard import typechecked
 
 
-@dataclass
+@typechecked
+@dataclass
 class AssetEntry:
     …
 
 
-@dataclass
+@typechecked
+@dataclass
 class AssetScanResult:
     …

     def to_json_dict(self) -> dict[str, dict[str, str | None]]:
         """Return manifest as a plain nested dict for JSON serialization."""
-        return {key: asdict(entry) for key, entry in self.manifest.items()}
+        out: dict[str, dict[str, str | None]] = {}
+        for key, entry in self.manifest.items():
+            out[key] = asdict(entry)
+        return out

As per coding guidelines: "Use @typechecked decorator with @dataclass for runtime type validation" and "Use explicit loops instead of list comprehensions for code clarity and debuggability."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@dataclass
class AssetEntry:
"""Resolved metadata for a single ``*.lnk`` file.
Attributes:
url: Primary URL from the first non-comment line of the ``.lnk``.
sha256: Optional hex digest declared in the ``.lnk`` (``sha256=...``).
v1 runtime ignores this; parser captures it for forward-compat.
fallback: Optional mirror URL declared in the ``.lnk`` (``fallback=...``).
v1 runtime ignores this; parser captures it for forward-compat.
"""
url: str
sha256: str | None = None
fallback: str | None = None
@dataclass
class AssetScanResult:
"""Result of scanning a sketch's ``data/`` directory.
Attributes:
manifest: Dict mapping relative asset paths (POSIX form, e.g.
``"data/track.mp3"``) to ``AssetEntry``. Missing ``data/`` or an
empty one yields an empty dict — not an error.
warnings: Non-fatal issues encountered during scanning (malformed
``.lnk`` files, unreadable files, etc.). Callers should log them
but the build should NOT fail on these.
"""
manifest: dict[str, AssetEntry] = field(default_factory=dict)
warnings: list[str] = field(default_factory=list)
def to_json_dict(self) -> dict[str, dict[str, str | None]]:
"""Return manifest as a plain nested dict for JSON serialization."""
return {key: asdict(entry) for key, entry in self.manifest.items()}
`@typechecked`
`@dataclass`
class AssetEntry:
"""Resolved metadata for a single ``*.lnk`` file.
Attributes:
url: Primary URL from the first non-comment line of the ``.lnk``.
sha256: Optional hex digest declared in the ``.lnk`` (``sha256=...``).
v1 runtime ignores this; parser captures it for forward-compat.
fallback: Optional mirror URL declared in the ``.lnk`` (``fallback=...``).
v1 runtime ignores this; parser captures it for forward-compat.
"""
url: str
sha256: str | None = None
fallback: str | None = None
`@typechecked`
`@dataclass`
class AssetScanResult:
"""Result of scanning a sketch's ``data/`` directory.
Attributes:
manifest: Dict mapping relative asset paths (POSIX form, e.g.
``"data/track.mp3"``) to ``AssetEntry``. Missing ``data/`` or an
empty one yields an empty dict — not an error.
warnings: Non-fatal issues encountered during scanning (malformed
``.lnk`` files, unreadable files, etc.). Callers should log them
but the build should NOT fail on these.
"""
manifest: dict[str, AssetEntry] = field(default_factory=dict)
warnings: list[str] = field(default_factory=list)
def to_json_dict(self) -> dict[str, dict[str, str | None]]:
"""Return manifest as a plain nested dict for JSON serialization."""
out: dict[str, dict[str, str | None]] = {}
for key, entry in self.manifest.items():
out[key] = asdict(entry)
return out
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/asset_scanner.py` around lines 43 - 78, Add runtime type
validation by decorating both dataclasses AssetEntry and AssetScanResult with
`@typechecked` (ensure the typechecked decorator is imported), and replace the
dict comprehension inside AssetScanResult.to_json_dict with an explicit loop
that constructs the result dict (iterate over self.manifest items, call
asdict(entry) for each, assign into result mapping, then return result) to
satisfy the "no comprehension" guideline.

Comment on lines +167 to +178
try:
content = lnk_path.read_text(encoding="utf-8")
except UnicodeDecodeError as exc:
result.warnings.append(
f"asset-scan: {lnk_path}: not valid UTF-8 ({exc}); skipped"
)
continue
except OSError as exc:
result.warnings.append(
f"asset-scan: {lnk_path}: read failed ({exc}); skipped"
)
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

try block is missing KeyboardInterrupt handling.

Repo guideline: "All Python try-catch blocks must handle KeyboardInterrupt before other exceptions." This block only catches UnicodeDecodeError and OSError. In practice read_text rarely raises KeyboardInterrupt, but the rule is absolute and static checkers/linters may flag this.

🔧 Proposed fix
         try:
             content = lnk_path.read_text(encoding="utf-8")
+        except KeyboardInterrupt:
+            raise
         except UnicodeDecodeError as exc:
             result.warnings.append(
                 f"asset-scan: {lnk_path}: not valid UTF-8 ({exc}); skipped"
             )
             continue
         except OSError as exc:
             result.warnings.append(
                 f"asset-scan: {lnk_path}: read failed ({exc}); skipped"
             )
             continue

As per coding guidelines: "All Python try-catch blocks must handle KeyboardInterrupt before other exceptions."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try:
content = lnk_path.read_text(encoding="utf-8")
except UnicodeDecodeError as exc:
result.warnings.append(
f"asset-scan: {lnk_path}: not valid UTF-8 ({exc}); skipped"
)
continue
except OSError as exc:
result.warnings.append(
f"asset-scan: {lnk_path}: read failed ({exc}); skipped"
)
continue
try:
content = lnk_path.read_text(encoding="utf-8")
except KeyboardInterrupt:
raise
except UnicodeDecodeError as exc:
result.warnings.append(
f"asset-scan: {lnk_path}: not valid UTF-8 ({exc}); skipped"
)
continue
except OSError as exc:
result.warnings.append(
f"asset-scan: {lnk_path}: read failed ({exc}); skipped"
)
continue
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/asset_scanner.py` around lines 167 - 178, The try block around
lnk_path.read_text(encoding="utf-8") must handle KeyboardInterrupt before the
other except clauses; add an except KeyboardInterrupt as exc: that re-raises the
exception (or simply "raise") placed immediately before the UnicodeDecodeError
and OSError handlers so KeyboardInterrupt propagates instead of being caught and
converted into a warning appended to result.warnings.

Comment thread src/fl/asset.cpp.hpp
Comment on lines +50 to +61
inline fl::url lookup_registry(fl::string_view path) FL_NOEXCEPT {
auto& r = registry();
for (fl::size i = 0; i < r.size(); ++i) {
// Compare as string_view on both sides to avoid any ambiguity in the
// fl::string / fl::string_view overload resolution.
fl::string_view candidate(r[i].path.c_str(), r[i].path.size());
if (candidate == path) {
return r[i].url;
}
}
return fl::url();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

"Last writer wins" is documented, but implementation is first-writer-wins.

asset.h line 173 states: "Last writer wins for duplicate paths (scan then manually plug in tests)." — but register_asset only appends, and lookup_registry returns on the first matching entry. So if the generated manifest registers "data/foo.mp3" and a test later registers an override for the same path, the override is silently ignored — the opposite of what the doc promises.

Either fix the loop to walk in reverse (cheap), or dedupe on insert:

🔧 Proposed fix — reverse-iterate on lookup
-    for (fl::size i = 0; i < r.size(); ++i) {
-        // Compare as string_view on both sides to avoid any ambiguity in the
-        // fl::string / fl::string_view overload resolution.
-        fl::string_view candidate(r[i].path.c_str(), r[i].path.size());
+    for (fl::size i = r.size(); i > 0; --i) {
+        // Walk newest-first so a later register_asset() overrides an earlier
+        // one — matches the "last writer wins" contract documented in asset.h.
+        fl::string_view candidate(r[i - 1].path.c_str(), r[i - 1].path.size());
         if (candidate == path) {
-            return r[i].url;
+            return r[i - 1].url;
         }
     }

Either way, the behavior and the comment in asset.h should agree.

Also applies to: 118-121

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/asset.cpp.hpp` around lines 50 - 61, lookup_registry currently returns
the first matching entry which makes registration behave as "first-writer-wins"
despite the comment claiming "last writer wins"; change lookup_registry to
iterate the registry in reverse (from r.size()-1 down to 0) so the most recently
registered entry wins, and audit/update any other similar lookups (the other
loop mentioned around the same area) to the same reverse-iteration pattern; also
ensure the comment in asset.h describing "Last writer wins" matches this
behavior.

Comment thread src/fl/asset.cpp.hpp
Comment on lines +92 to +110
fl::ifstream lnk(lnkPath.c_str(), fl::ios::in | fl::ios::binary);
if (!lnk.is_open()) {
return fl::url();
}
// Read entire file. .lnk files are expected to be tiny (URL + a few
// metadata lines); cap the read at 8 KiB to avoid pathological inputs.
constexpr fl::size kMaxLnkBytes = 8 * 1024;
fl::size sz = lnk.size();
if (sz > kMaxLnkBytes) {
sz = kMaxLnkBytes;
}
fl::string content;
content.resize(sz);
if (sz > 0) {
lnk.read(&content[0], sz);
}
lnk.close();
return parse_lnk(fl::string_view(content.data(), content.size()));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check what fl::ifstream exposes (gcount, size, etc.) in the repo.
fd -e h -e hpp -e cpp 'fstream' src/fl/stl
rg -nP -C2 '\bgcount\b|\bifstream\b' src/fl/stl

Repository: FastLED/FastLED

Length of output: 7365


🏁 Script executed:

# Find and examine the asset.cpp.hpp file around lines 92-110
fd -name "asset.cpp.hpp" src/fl

Repository: FastLED/FastLED

Length of output: 289


🏁 Script executed:

# Get the exact code snippet from asset.cpp.hpp
cat -n src/fl/asset.cpp.hpp | sed -n '85,115p'

Repository: FastLED/FastLED

Length of output: 1142


🏁 Script executed:

# Check if fl::ifstream has a size() method
rg -n '\bsize\(' src/fl/stl/fstream.h

Repository: FastLED/FastLED

Length of output: 267


Use gcount() after read() to verify the actual bytes read.

The code calls lnk.read(&content[0], sz) without verifying that sz bytes were actually read. If the read operation fails or returns fewer bytes (due to truncation, I/O error, or CRLF translation quirks in fl::ifstream::size()), the buffer will still have length sz with indeterminate trailing bytes, which parse_lnk() will then process as valid data.

Since fl::ifstream exposes gcount(), call it after read() to get the actual byte count and resize content accordingly. Alternatively, check lnk.good() or !lnk.fail() after the read and return fl::url() on failure.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/asset.cpp.hpp` around lines 92 - 110, The read result from
fl::ifstream lnk is not validated: after calling lnk.read(&content[0], sz) you
must call lnk.gcount() (or check lnk.good()/!lnk.fail()) and resize content to
the actual bytes read or bail out on failure; update the code around
fl::ifstream lnk, the lnk.read(...) call, and the subsequent return
parse_lnk(...) so that you use the gcount result to set content.size() (or
return fl::url() on read failure) before passing the buffer to parse_lnk.

Comment thread src/fl/asset.h
Comment on lines +173 to +174
/// Last writer wins for duplicate paths (scan then manually plug in tests).
void register_asset(fl::string_view path, const fl::url& u) FL_NOEXCEPT;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Doc contradicts implementation — fix alongside the registry-lookup change.

This comment says "Last writer wins for duplicate paths" but asset_detail::lookup_registry in src/fl/asset.cpp.hpp returns the first match, so it's actually first-writer-wins. Please resolve this together with the lookup-direction fix suggested on src/fl/asset.cpp.hpp lines 50-61 — either adjust the lookup to iterate newest-first (matching this doc) or weaken this comment to match the current behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/asset.h` around lines 173 - 174, The comment on register_asset
promises "Last writer wins" but asset_detail::lookup_registry currently returns
the first match; change lookup_registry to search newest-first (e.g.,
reverse-iterate the registry or use rbegin/rend) so it returns the most recently
registered asset and therefore matches the register_asset doc, and ensure any
test or call-sites expecting lookup_registry (symbol:
asset_detail::lookup_registry) still behave correctly after reversing the
iteration order.

Comment thread src/fl/stl/url.h
Comment on lines +361 to +374
// Subsequent lines: look for "key=value" metadata.
fl::size eq = line.find('=');
if (eq == fl::string_view::npos) {
// Unknown non-kv line, ignore (forward-compat).
continue;
}
fl::string_view key = line.substr(0, eq);
fl::string_view value = line.substr(eq + 1);
if (key == "sha256") {
out.sha256 = fl::string(value.data(), value.size());
} else if (key == "fallback") {
out.fallback = url(value);
}
// else: unknown key, ignore.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Trim mismatch between C++ and Python .lnk parsers.

ci/compiler/asset_scanner.py strips whitespace from both key and value (key = key.strip(); value = value.strip()), but this C++ path does neither. A .lnk containing sha256 = deadbeef will register sha256="deadbeef" on the Python/manifest side and sha256="" on the C++ host-fallback side — unknown key, then never recorded because " sha256 " != "sha256". v1 runtime ignores these fields so this isn't user-visible today, but when integrity/fallback enforcement lands in v2 the two paths will disagree.

🔧 Suggested fix — trim key and value symmetrically
         fl::size eq = line.find('=');
         if (eq == fl::string_view::npos) {
             // Unknown non-kv line, ignore (forward-compat).
             continue;
         }
         fl::string_view key = line.substr(0, eq);
         fl::string_view value = line.substr(eq + 1);
+        // Match the Python scanner which strips key/value whitespace.
+        while (!key.empty() && (key[0] == ' ' || key[0] == '\t')) key = key.substr(1);
+        while (!key.empty() && (key[key.size()-1] == ' ' || key[key.size()-1] == '\t')) key = key.substr(0, key.size()-1);
+        while (!value.empty() && (value[0] == ' ' || value[0] == '\t')) value = value.substr(1);
+        while (!value.empty() && (value[value.size()-1] == ' ' || value[value.size()-1] == '\t')) value = value.substr(0, value.size()-1);
         if (key == "sha256") {
             out.sha256 = fl::string(value.data(), value.size());
         } else if (key == "fallback") {
             out.fallback = url(value);
         }

Adding a test case with sha256 = abc / fallback = https://... around spaces in both tests/fl/stl/url.cpp and ci/tests/test_asset_scanner.py would lock the contract down.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Subsequent lines: look for "key=value" metadata.
fl::size eq = line.find('=');
if (eq == fl::string_view::npos) {
// Unknown non-kv line, ignore (forward-compat).
continue;
}
fl::string_view key = line.substr(0, eq);
fl::string_view value = line.substr(eq + 1);
if (key == "sha256") {
out.sha256 = fl::string(value.data(), value.size());
} else if (key == "fallback") {
out.fallback = url(value);
}
// else: unknown key, ignore.
// Subsequent lines: look for "key=value" metadata.
fl::size eq = line.find('=');
if (eq == fl::string_view::npos) {
// Unknown non-kv line, ignore (forward-compat).
continue;
}
fl::string_view key = line.substr(0, eq);
fl::string_view value = line.substr(eq + 1);
// Match the Python scanner which strips key/value whitespace.
while (!key.empty() && (key[0] == ' ' || key[0] == '\t')) key = key.substr(1);
while (!key.empty() && (key[key.size()-1] == ' ' || key[key.size()-1] == '\t')) key = key.substr(0, key.size()-1);
while (!value.empty() && (value[0] == ' ' || value[0] == '\t')) value = value.substr(1);
while (!value.empty() && (value[value.size()-1] == ' ' || value[value.size()-1] == '\t')) value = value.substr(0, value.size()-1);
if (key == "sha256") {
out.sha256 = fl::string(value.data(), value.size());
} else if (key == "fallback") {
out.fallback = url(value);
}
// else: unknown key, ignore.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/stl/url.h` around lines 361 - 374, The parser currently assigns
key/value from the split without trimming, causing mismatches versus the Python
parser; modify the parsing block so you trim whitespace from both
fl::string_view key and value (e.g., compute trimmed_key and trimmed_value from
the existing key/value), then use trimmed_key for the comparisons and
trimmed_value when setting out.sha256 (constructing fl::string from
trimmed_value) and out.fallback (constructing url from trimmed_value); ensure
unknown keys are still ignored.

zackees added a commit that referenced this pull request Apr 18, 2026
… path

The esbuild alias `three=./vendor/three/three.module.js` and the direct
relative imports in app.ts and fastled_background_worker.ts (both of
which use `./vendor/three/build/three.module.js`) both pointed at
paths that were never populated — the original vendor commit 7d5bb4e
committed only `vendor/three/examples/jsm/` and missed the runtime
module. Every WASM CI build has been failing at the esbuild step with
"Could not resolve ./vendor/three/three.module.js".

Fixes by:
  - Committing three.module.js (three.js v0.170.0, MIT) under
    vendor/three/build/, matching the actual import paths.
  - Adding an unignore rule so vendor/three/build/ isn't swept by the
    project-wide build/ ignore (follows the existing precedent for
    !src/fl/build/).
  - Updating the esbuild alias to the same path so bare `three` imports
    from examples/jsm files resolve to the identical module instance as
    the direct relative imports (no double-bundle).
  - Vendoring LICENSE alongside for attribution.

Verified locally: bash compile wasm --examples AudioUrl now produces
fastled.js + fastled.wasm + index.html (previously the final esbuild
step failed, leaving those artifacts missing and breaking the
"Check for required artifacts" step in build.yml).

Unblocks CI for #2331, #2332, #2335, and every future PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Apr 18, 2026
Every WASM CI build was failing at the esbuild bundling step with
"Could not resolve ./vendor/three/three.module.js (originally three)"
because the path the existing alias in ci/esbuild_frontend.py has
always pointed at was never populated. The original vendor commit
7d5bb4e committed only vendor/three/examples/jsm/ and missed the
runtime module.

The project's security-safe CI workflow copies only src/, examples/,
and a handful of root manifests from PR head into the trusted tree —
it does not copy ci/ or .gitignore, which means a fix that lives
only under ci/ cannot unblock PRs at all.

Fix, entirely under src/:

  - Vendor three.js v0.170.0 (MIT) at
    src/platforms/wasm/compiler/vendor/three/three.module.js —
    exactly the path the existing esbuild alias already points to,
    so bare `from 'three'` imports in examples/jsm/* resolve cleanly.
  - Retarget the three direct-relative imports (app.ts,
    fastled_background_worker.ts, scene.js) from
    ./vendor/three/build/three.module.js → ./vendor/three/three.module.js
    so every consumer resolves to the same on-disk file, which also
    means esbuild bundles three.js exactly once (no double-bundle,
    no instanceof surprises across worker/main bundles).
  - Ship three.js LICENSE alongside for MIT attribution.

No ci/ changes, no .gitignore changes — the fix is self-contained in
src/ and will survive the workflow's safe-file merge.

Verified locally: bash compile wasm --examples AudioUrl now emits
fastled.js, fastled.wasm, and index.html. Previously failed with
esbuild exit 1, leaving those artifacts missing and breaking the
"Check for required artifacts" step in build.yml.

Unblocks #2331, #2335, and master CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Header Compilation Performance

Total Time: 785.47ms

Top 5 Slowest Headers

  1. FastLED.h - 595.82ms
  2. fl/fastled.h - 247.93ms
  3. fl/task/executor.h - 195.17ms
  4. crgb.h - 136.36ms
  5. fl/gfx/crgb.h - 135.37ms

Warnings

⚠️ Header FastLED.h exceeds 150ms (595.8ms)
⚠️ Header fl/fastled.h exceeds 150ms (247.9ms)
⚠️ Header fl/task/executor.h exceeds 150ms (195.2ms)
⚠️ Header crgb.h exceeds 50ms (136.4ms)
⚠️ Header fl/gfx/crgb.h exceeds 50ms (135.4ms)
⚠️ Header fl/math/ease.h exceeds 50ms (132.0ms)
⚠️ Header fl/math/fixed_point.h exceeds 50ms (130.6ms)
⚠️ Header fl/task/scheduler.h exceeds 50ms (101.2ms)
⚠️ Header fl/stl/singleton.h exceeds 50ms (94.0ms)
⚠️ Header fl/stl/thread_local.h exceeds 50ms (93.5ms)
⚠️ Header fl/stl/thread.h exceeds 50ms (92.6ms)
⚠️ Header platforms/thread.h exceeds 50ms (92.6ms)
⚠️ Header platforms/stub/thread_stub.h exceeds 50ms (92.5ms)
⚠️ Header platforms/stub/thread_stub_stl.h exceeds 50ms (92.5ms)
⚠️ Header fl/ui.h exceeds 50ms (85.5ms)
⚠️ Header fl/task/promise.h exceeds 50ms (84.2ms)
⚠️ Header fl/stl/json.h exceeds 50ms (52.6ms)
⚠️ Template instantiation time is high (46.9%)

Full Report
================================================================================
FASTLED COMPILATION PERFORMANCE REPORT
================================================================================
Generated: 2026-04-19 01:01:56
Compiler: clang++-17
File: ci/perf/test_compile.cpp

SUMMARY
--------------------------------------------------------------------------------
Total Compilation Time:    1,296.51 ms
Frontend Time:             11.09 ms (0.9%)
Backend Time:              35.17 ms (2.7%)

COMPILATION PHASES
--------------------------------------------------------------------------------
Source                     9832.70 ms (758.4%)
Templates                   372.92 ms ( 28.8%)

FASTLED HEADERS (Level 1 - Direct Includes)
--------------------------------------------------------------------------------
  1103.7 ms - FastLED.h (SLOW)
   622.1 ms - fl/task/executor.h (SLOW)
   323.7 ms - fl/fastled.h (SLOW)
   319.2 ms - fl/task/scheduler.h (SLOW)
   312.4 ms - fl/stl/singleton.h (SLOW)
   311.9 ms - fl/stl/thread_local.h (SLOW)
   311.0 ms - fl/stl/thread.h (SLOW)
   310.9 ms - platforms/thread.h (SLOW)
   310.9 ms - platforms/stub/thread_stub.h (SLOW)
   310.8 ms - platforms/stub/thread_stub_stl.h (SLOW)
   293.3 ms - fl/task/promise.h (SLOW)
   260.8 ms - fl/stl/function.h (SLOW)
   188.0 ms - crgb.h (SLOW)
   187.1 ms - fl/gfx/crgb.h (SLOW)
   183.7 ms - fl/math/ease.h (SLOW)
   182.2 ms - fl/math/fixed_point.h (SLOW)
   135.3 ms - fl/stl/vector.h (SLOW)
   111.9 ms - fl/math/math.h (SLOW)
   110.2 ms - fl/stl/variant.h (SLOW)
   108.9 ms - fl/stl/new.h (SLOW)

FASTLED HEADERS (Nested Includes - Up to 10 Levels)
--------------------------------------------------------------------------------
FastLED.h (1103.7ms)
  ├─  622.1 ms - fl/task/executor.h
  │ ├─  319.2 ms - fl/task/scheduler.h
  │ │ ├─  312.4 ms - fl/stl/singleton.h
  │ │ │ └─  311.9 ms - fl/stl/thread_local.h
  │ │ │   └─  311.0 ms - fl/stl/thread.h
  │ │ │     └─  310.9 ms - platforms/thread.h
  │ │ │       └─  310.9 ms - platforms/stub/thread_stub.h
  │ │ │         └─  310.8 ms - platforms/stub/thread_stub_stl.h
  │ │ │           └─  306.2 ms - thread
  │ │ │             ├─  186.0 ms - std_thread.h
  │ │ │             └─  105.8 ms - this_thread_sleep.h
  │ │ └─    6.2 ms - fl/task/task.h
  │ │   └─    2.4 ms - fl/trace.h
  │ │     ├─    1.6 ms - fl/stl/chrono.h
  │ │     └─    0.6 ms - fl/stl/tuple.h
  │ ├─  293.3 ms - fl/task/promise.h
  │ │ ├─  260.8 ms - fl/stl/function.h
  │ │ │ ├─  135.3 ms - fl/stl/vector.h
  │ │ │ │ ├─  111.9 ms - fl/math/math.h
  │ │ │ │ │ └─  108.4 ms - fl/stl/undef.h
  │ │ │ │ │   └─  197.0 ms - stdlib.h
  │ │ │ │ │     ├─   98.7 ms - cstdlib
  │ │ │ │ │     │ └─  197.0 ms - stdlib.h
  │ │ │ │ │     │   ├─   98.7 ms - cstdlib
  │ │ │ │ │     │   └─   25.0 ms - types.h
  │ │ │ │ │     └─   25.0 ms - types.h
  │ │ │ │ │       ├─   25.0 ms - types.h
  │ │ │ │ │       │ ├─   25.0 ms - types.h
  │ │ │ │ │       │ ├─    1.8 ms - pthreadtypes.h
  │ │ │ │ │       │ ├─    1.7 ms - endian.h
  │ │ │ │ │       │ └─    1.6 ms - select.h
  │ │ │ │ │       ├─    1.8 ms - pthreadtypes.h
  │ │ │ │ │       │ └─    1.3 ms - thread-shared-types.h
  │ │ │ │ │       ├─    1.7 ms - endian.h
  │ │ │ │ │       └─    1.6 ms - select.h
  │ │ │ │ ├─   11.9 ms - fl/stl/allocator.h
  │ │ │ │ │ └─    8.1 ms - fl/stl/bitset.h
  │ │ │ │ │   └─    5.3 ms - fl/stl/bitset_dynamic.h
  │ │ │ │ │     └─    1.4 ms - fl/stl/unique_ptr.h
  │ │ │ │ ├─    4.6 ms - fl/stl/initializer_list.h
  │ │ │ │ └─    1.8 ms - fl/stl/basic_vector.h
  │ │ │ ├─  110.2 ms - fl/stl/variant.h
  │ │ │ │ └─  108.9 ms - fl/stl/new.h
  │ │ │ │   └─  108.8 ms - platforms/new.h
  │ │ │ │     └─  108.8 ms - platforms/shared/new.h
  │ │ │ │       └─  100.2 ms - new
  │ │ │ │         └─   46.8 ms - c++config.h
  │ │ │ │           └─   37.8 ms - os_defines.h
  │ │ │ ├─    8.3 ms - fl/stl/shared_ptr.h
  │ │ │ │ ├─    4.1 ms - fl/stl/type_traits.h
  │ │ │ │ └─    0.9 ms - fl/stl/atomic.h
  │ │ │ ├─    2.9 ms - fl/stl/algorithm.h
  │ │ │ │ └─    1.3 ms - fl/math/random.h
  │ │ │ │   └─    0.6 ms - fl/math/random8.h
  │ │ │ └─    0.9 ms - fl/stl/pair.h
  │ │ └─   28.7 ms - fl/stl/string.h
  │ │   ├─    8.6 ms - fl/stl/basic_string.h
  │ │   │ ├─    0.7 ms - fl/stl/not_null.h
  │ │   │ └─    0.6 ms - fl/stl/iterator.h
  │ │   ├─    5.5 ms - fl/stl/span.h
  │ │   │ └─    2.3 ms - fl/math/geometry.h
  │ │   ├─    3.4 ms - fl/stl/string_view.h
  │ │   └─    1.0 ms - fl/stl/optional.h
  │ ├─    8.0 ms - platforms/await.h
  │ │ └─    7.7 ms - platforms/coroutine_runtime.h
  │ │   └─    6.5 ms - fl/system/engine_events.h
  │ │     ├─    3.3 ms - fl/math/screenmap.h
  │ │     │ └─    2.4 ms - fl/stl/flat_map.h
  │ │     └─    2.1 ms - fl/math/xymap.h
  │ │       └─    0.5 ms - fl/math/lut.h
  │ └─    0.5 ms - fl/task/promise_result.h
  ├─  323.7 ms - fl/fastled.h
  │ ├─  188.0 ms - crgb.h
  │ │ ├─  187.1 ms - fl/gfx/crgb.h
  │ │ │ └─  183.7 ms - fl/math/ease.h
  │ │ │   └─  182.2 ms - fl/math/fixed_point.h
  │ │ │     ├─   89.7 ms - fl/math/fixed_point/s4x12.h
  │ │ │     │ ├─   76.6 ms - fl/math/sin32.h
  │ │ │     │ │ └─   74.7 ms - fl/math/simd.h
  │ │ │     │ │   └─   74.3 ms - fl/math/simd/types.h
  │ │ │     │ │     └─   74.0 ms - platforms/simd.h
  │ │ │     │ └─    0.7 ms - fl/math/fixed_point/traits.h
  │ │ │     ├─   11.7 ms - fl/math/fixed_point/s8x8.h
  │ │ │     ├─   11.4 ms - fl/math/fixed_point/s8x24.h
  │ │ │     ├─   11.3 ms - fl/math/fixed_point/s16x16.h
  │ │ │     └─   11.1 ms - fl/math/fixed_point/s24x8.h
  │ │ └─    0.6 ms - chsv.h
  │ │   └─    0.5 ms - fl/gfx/hsv.h
  │ ├─   63.5 ms - platforms.h
  │ │ └─   63.4 ms - platforms/stub/fastled_stub.h
  │ │   ├─   38.1 ms - platforms/stub/fastspi_stub.h
  │ │   │ └─   38.1 ms - platforms/stub/fastspi_stub_generic.h
  │ │   │   ├─   33.4 ms - platforms/shared/active_strip_data/active_strip_data.h
  │ │   │   │ └─   31.8 ms - fl/id_tracker.h
  │ │   │   │   └─   31.1 ms - fl/stl/mutex.h
  │ │   │   │     └─   31.0 ms - platforms/mutex.h
  │ │   │   │       └─   30.9 ms - platforms/stub/mutex_stub.h
  │ │   │   └─    4.3 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │ │   └─   25.2 ms - platforms/stub/clockless_stub.h
  │ │     └─   25.2 ms - platforms/stub/clockless_channel_stub.h
  │ │       ├─    9.2 ms - fl/channels/data.h
  │ │       │ └─    6.8 ms - fl/channels/config.h
  │ │       │   ├─    1.4 ms - fl/chipsets/chipset_timing_config.h
  │ │       │   │ └─    0.9 ms - fl/chipsets/led_timing.h
  │ │       │   └─    1.1 ms - fl/chipsets/spi.h
  │ │       ├─    8.6 ms - fl/system/log.h
  │ │       │ └─    8.2 ms - fl/stl/strstream.h
  │ │       ├─    1.7 ms - fl/channels/manager.h
  │ │       ├─    1.1 ms - fl/stl/weak_ptr.h
  │ │       └─    0.8 ms - fl/channels/driver.h
  │ ├─   26.8 ms - colorutils.h
  │ │ └─   26.2 ms - fl/gfx/colorutils.h
  │ │   ├─    5.8 ms - fl/gfx/blur.h
  │ │   │ └─    3.1 ms - fl/gfx/canvas.h
  │ │   │   └─    1.9 ms - fl/math/alpha.h
  │ │   └─    2.1 ms - fl/gfx/fill.h
  │ ├─   15.6 ms - pixel_controller.h
  │ │ ├─   11.1 ms - pixel_iterator.h
  │ │ │ └─   11.0 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │ │   ├─    3.1 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │ │   ├─    3.1 ms - fl/chipsets/encoders/apa102.h
  │ │ │   │ └─    2.4 ms - fl/chipsets/encoders/encoder_utils.h
  │ │ │   │   └─    2.0 ms - fl/gfx/gamma_lut.h
  │ │ │   ├─    0.6 ms - fl/chipsets/encoders/sk9822.h
  │ │ │   └─    0.5 ms - fl/chipsets/encoders/hd108.h
  │ │ └─    1.9 ms - rgbw.h
  │ │   └─    1.7 ms - fl/gfx/rgbw.h
  │ └─   14.6 ms - pixeltypes.h
  │   ├─   12.2 ms - lib8tion.h
  │   │ ├─    6.3 ms - fl/math/math8.h
  │   │ │ ├─    3.1 ms - fl/math/intmap.h
  │   │ │ │ └─    2.4 ms - platforms/intmap.h
  │   │ │ ├─    1.6 ms - platforms/math8.h
  │   │ │ │ └─    1.1 ms - platforms/shared/math8.h
  │   │ │ └─    1.6 ms - fl/math/scale8.h
  │   │ │   └─    1.5 ms - platforms/scale8.h
  │   │ │     └─    0.6 ms - platforms/shared/scale8.h
  │   │ └─    1.3 ms - fl/math/beat.h
  │   │   └─    0.8 ms - fl/math/trig8.h
  │   │     └─    0.7 ms - platforms/trig8.h
  │   │       └─    0.6 ms - platforms/shared/trig8.h
  │   └─    2.1 ms - crgb.hpp
  ├─   83.5 ms - fl/ui.h
  │ ├─   50.7 ms - fl/stl/json.h
  │ │ └─   39.8 ms - fl/stl/json/types.h
  │ │   └─    4.7 ms - fl/stl/limits.h
  │ ├─    7.8 ms - fl/ui_impl.h
  │ │ └─    7.3 ms - platforms/ui_defs.h
  │ │   ├─    1.6 ms - platforms/shared/ui/json/audio.h
  │ │   │ └─    0.8 ms - platforms/shared/ui/json/audio_internal.h
  │ │   ├─    1.2 ms - platforms/shared/ui/json/button.h
  │ │   │ └─    0.5 ms - platforms/shared/ui/json/ui_internal.h
  │ │   ├─    0.7 ms - platforms/shared/ui/json/checkbox.h
  │ │   ├─    0.6 ms - platforms/shared/ui/json/help.h
  │ │   └─    0.6 ms - platforms/shared/ui/json/number_field.h
  │ └─    6.3 ms - fl/asset.h
  │   └─    5.5 ms - fl/stl/url.h
  ├─   19.6 ms - chipsets.h
  │ ├─    8.2 ms - fl/chipsets/ucs7604.h
  │ │ └─    6.1 ms - fl/chipsets/encoders/ucs7604.h
  │ ├─    4.6 ms - fl/chipsets/apa102.h
  │ ├─    1.2 ms - fl/chipsets/lpd880x.h
  │ ├─    0.6 ms - fl/chipsets/encoders/ws2816.h
  │ └─    0.6 ms - fl/chipsets/ws2801.h
  └─   16.4 ms - fl/audio/audio_processor.h
    ├─    4.1 ms - fl/audio/audio_context.h
    │ └─    1.1 ms - fl/audio/fft/fft.h
    ├─    1.6 ms - fl/audio/detector/vibe.h
    └─    0.7 ms - fl/audio/signal_conditioner.h
fl/task/executor.h (622.1ms)
  ├─  319.2 ms - fl/task/scheduler.h
  │ ├─  312.4 ms - fl/stl/singleton.h
  │ │ └─  311.9 ms - fl/stl/thread_local.h
  │ │   └─  311.0 ms - fl/stl/thread.h
  │ │     └─  310.9 ms - platforms/thread.h
  │ │       └─  310.9 ms - platforms/stub/thread_stub.h
  │ │         └─  310.8 ms - platforms/stub/thread_stub_stl.h
  │ │           └─  306.2 ms - thread
  │ │             ├─  186.0 ms - std_thread.h
  │ │             │ ├─   51.8 ms - iosfwd
  │ │             │ ├─   44.2 ms - tuple
  │ │             │ ├─   19.9 ms - refwrap.h
  │ │             │ ├─   12.5 ms - gthr.h
  │ │             │ └─    4.2 ms - unique_ptr.h
  │ │             └─  105.8 ms - this_thread_sleep.h
  │ │               ├─   74.5 ms - chrono.h
  │ │               └─   22.4 ms - cerrno
  │ └─    6.2 ms - fl/task/task.h
  │   └─    2.4 ms - fl/trace.h
  │     ├─    1.6 ms - fl/stl/chrono.h
  │     └─    0.6 ms - fl/stl/tuple.h
  ├─  293.3 ms - fl/task/promise.h
  │ ├─  260.8 ms - fl/stl/function.h
  │ │ ├─  135.3 ms - fl/stl/vector.h
  │ │ │ ├─  111.9 ms - fl/math/math.h
  │ │ │ │ └─  108.4 ms - fl/stl/undef.h
  │ │ │ │   └─  197.0 ms - stdlib.h
  │ │ │ │     ├─   98.7 ms - cstdlib
  │ │ │ │     │ └─  197.0 ms - stdlib.h
  │ │ │ │     │   ├─   98.7 ms - cstdlib
  │ │ │ │     │   │ └─  197.0 ms - stdlib.h
  │ │ │ │     │   └─   25.0 ms - types.h
  │ │ │ │     │     ├─   25.0 ms - types.h
  │ │ │ │     │     ├─    1.8 ms - pthreadtypes.h
  │ │ │ │     │     ├─    1.7 ms - endian.h
  │ │ │ │     │     └─    1.6 ms - select.h
  │ │ │ │     └─   25.0 ms - types.h
  │ │ │ │       ├─   25.0 ms - types.h
  │ │ │ │       │ ├─   25.0 ms - types.h
  │ │ │ │       │ │ ├─   25.0 ms - types.h
  │ │ │ │       │ │ ├─    1.8 ms - pthreadtypes.h
  │ │ │ │       │ │ ├─    1.7 ms - endian.h
  │ │ │ │       │ │ └─    1.6 ms - select.h
  │ │ │ │       │ ├─    1.8 ms - pthreadtypes.h
  │ │ │ │       │ │ └─    1.3 ms - thread-shared-types.h
  │ │ │ │       │ ├─    1.7 ms - endian.h
  │ │ │ │       │ └─    1.6 ms - select.h
  │ │ │ │       ├─    1.8 ms - pthreadtypes.h
  │ │ │ │       │ └─    1.3 ms - thread-shared-types.h
  │ │ │ │       ├─    1.7 ms - endian.h
  │ │ │ │       └─    1.6 ms - select.h
  │ │ │ ├─   11.9 ms - fl/stl/allocator.h
  │ │ │ │ └─    8.1 ms - fl/stl/bitset.h
  │ │ │ │   └─    5.3 ms - fl/stl/bitset_dynamic.h
  │ │ │ │     └─    1.4 ms - fl/stl/unique_ptr.h
  │ │ │ ├─    4.6 ms - fl/stl/initializer_list.h
  │ │ │ └─    1.8 ms - fl/stl/basic_vector.h
  │ │ ├─  110.2 ms - fl/stl/variant.h
  │ │ │ └─  108.9 ms - fl/stl/new.h
  │ │ │   └─  108.8 ms - platforms/new.h
  │ │ │     └─  108.8 ms - platforms/shared/new.h
  │ │ │       └─  100.2 ms - new
  │ │ │         └─   46.8 ms - c++config.h
  │ │ │           └─   37.8 ms - os_defines.h
  │ │ │             └─   33.3 ms - features.h
  │ │ ├─    8.3 ms - fl/stl/shared_ptr.h
  │ │ │ ├─    4.1 ms - fl/stl/type_traits.h
  │ │ │ └─    0.9 ms - fl/stl/atomic.h
  │ │ ├─    2.9 ms - fl/stl/algorithm.h
  │ │ │ └─    1.3 ms - fl/math/random.h
  │ │ │   └─    0.6 ms - fl/math/random8.h
  │ │ └─    0.9 ms - fl/stl/pair.h
  │ └─   28.7 ms - fl/stl/string.h
  │   ├─    8.6 ms - fl/stl/basic_string.h
  │   │ ├─    0.7 ms - fl/stl/not_null.h
  │   │ └─    0.6 ms - fl/stl/iterator.h
  │   ├─    5.5 ms - fl/stl/span.h
  │   │ └─    2.3 ms - fl/math/geometry.h
  │   ├─    3.4 ms - fl/stl/string_view.h
  │   └─    1.0 ms - fl/stl/optional.h
  ├─    8.0 ms - platforms/await.h
  │ └─    7.7 ms - platforms/coroutine_runtime.h
  │   └─    6.5 ms - fl/system/engine_events.h
  │     ├─    3.3 ms - fl/math/screenmap.h
  │     │ └─    2.4 ms - fl/stl/flat_map.h
  │     └─    2.1 ms - fl/math/xymap.h
  │       └─    0.5 ms - fl/math/lut.h
  └─    0.5 ms - fl/task/promise_result.h
fl/fastled.h (323.7ms)
  ├─  188.0 ms - crgb.h
  │ ├─  187.1 ms - fl/gfx/crgb.h
  │ │ └─  183.7 ms - fl/math/ease.h
  │ │   └─  182.2 ms - fl/math/fixed_point.h
  │ │     ├─   89.7 ms - fl/math/fixed_point/s4x12.h
  │ │     │ ├─   76.6 ms - fl/math/sin32.h
  │ │     │ │ └─   74.7 ms - fl/math/simd.h
  │ │     │ │   └─   74.3 ms - fl/math/simd/types.h
  │ │     │ │     └─   74.0 ms - platforms/simd.h
  │ │     │ │       └─   74.0 ms - platforms/shared/simd_x86.hpp
  │ │     │ └─    0.7 ms - fl/math/fixed_point/traits.h
  │ │     ├─   11.7 ms - fl/math/fixed_point/s8x8.h
  │ │     ├─   11.4 ms - fl/math/fixed_point/s8x24.h
  │ │     ├─   11.3 ms - fl/math/fixed_point/s16x16.h
  │ │     └─   11.1 ms - fl/math/fixed_point/s24x8.h
  │ └─    0.6 ms - chsv.h
  │   └─    0.5 ms - fl/gfx/hsv.h
  ├─   63.5 ms - platforms.h
  │ └─   63.4 ms - platforms/stub/fastled_stub.h
  │   ├─   38.1 ms - platforms/stub/fastspi_stub.h
  │   │ └─   38.1 ms - platforms/stub/fastspi_stub_generic.h
  │   │   ├─   33.4 ms - platforms/shared/active_strip_data/active_strip_data.h
  │   │   │ └─   31.8 ms - fl/id_tracker.h
  │   │   │   └─   31.1 ms - fl/stl/mutex.h
  │   │   │     └─   31.0 ms - platforms/mutex.h
  │   │   │       └─   30.9 ms - platforms/stub/mutex_stub.h
  │   │   │         └─   30.9 ms - platforms/stub/mutex_stub_stl.h
  │   │   └─    4.3 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │   └─   25.2 ms - platforms/stub/clockless_stub.h
  │     └─   25.2 ms - platforms/stub/clockless_channel_stub.h
  │       ├─    9.2 ms - fl/channels/data.h
  │       │ └─    6.8 ms - fl/channels/config.h
  │       │   ├─    1.4 ms - fl/chipsets/chipset_timing_config.h
  │       │   │ └─    0.9 ms - fl/chipsets/led_timing.h
  │       │   └─    1.1 ms - fl/chipsets/spi.h
  │       ├─    8.6 ms - fl/system/log.h
  │       │ └─    8.2 ms - fl/stl/strstream.h
  │       ├─    1.7 ms - fl/channels/manager.h
  │       ├─    1.1 ms - fl/stl/weak_ptr.h
  │       └─    0.8 ms - fl/channels/driver.h
  ├─   26.8 ms - colorutils.h
  │ └─   26.2 ms - fl/gfx/colorutils.h
  │   ├─    5.8 ms - fl/gfx/blur.h
  │   │ └─    3.1 ms - fl/gfx/canvas.h
  │   │   └─    1.9 ms - fl/math/alpha.h
  │   └─    2.1 ms - fl/gfx/fill.h
  ├─   15.6 ms - pixel_controller.h
  │ ├─   11.1 ms - pixel_iterator.h
  │ │ └─   11.0 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │   ├─    3.1 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │   ├─    3.1 ms - fl/chipsets/encoders/apa102.h
  │ │   │ └─    2.4 ms - fl/chipsets/encoders/encoder_utils.h
  │ │   │   └─    2.0 ms - fl/gfx/gamma_lut.h
  │ │   ├─    0.6 ms - fl/chipsets/encoders/sk9822.h
  │ │   └─    0.5 ms - fl/chipsets/encoders/hd108.h
  │ └─    1.9 ms - rgbw.h
  │   └─    1.7 ms - fl/gfx/rgbw.h
  └─   14.6 ms - pixeltypes.h
    ├─   12.2 ms - lib8tion.h
    │ ├─    6.3 ms - fl/math/math8.h
    │ │ ├─    3.1 ms - fl/math/intmap.h
    │ │ │ └─    2.4 ms - platforms/intmap.h
    │ │ ├─    1.6 ms - platforms/math8.h
    │ │ │ └─    1.1 ms - platforms/shared/math8.h
    │ │ └─    1.6 ms - fl/math/scale8.h
    │ │   └─    1.5 ms - platforms/scale8.h
    │ │     └─    0.6 ms - platforms/shared/scale8.h
    │ └─    1.3 ms - fl/math/beat.h
    │   └─    0.8 ms - fl/math/trig8.h
    │     └─    0.7 ms - platforms/trig8.h
    │       └─    0.6 ms - platforms/shared/trig8.h
    └─    2.1 ms - crgb.hpp
fl/ui.h (83.5ms)
  ├─   50.7 ms - fl/stl/json.h
  │ └─   39.8 ms - fl/stl/json/types.h
  │   └─    4.7 ms - fl/stl/limits.h
  ├─    7.8 ms - fl/ui_impl.h
  │ └─    7.3 ms - platforms/ui_defs.h
  │   ├─    1.6 ms - platforms/shared/ui/json/audio.h
  │   │ └─    0.8 ms - platforms/shared/ui/json/audio_internal.h
  │   ├─    1.2 ms - platforms/shared/ui/json/button.h
  │   │ └─    0.5 ms - platforms/shared/ui/json/ui_internal.h
  │   ├─    0.7 ms - platforms/shared/ui/json/checkbox.h
  │   ├─    0.6 ms - platforms/shared/ui/json/help.h
  │   └─    0.6 ms - platforms/shared/ui/json/number_field.h
  └─    6.3 ms - fl/asset.h
    └─    5.5 ms - fl/stl/url.h
chipsets.h (19.6ms)
  ├─    8.2 ms - fl/chipsets/ucs7604.h
  │ └─    6.1 ms - fl/chipsets/encoders/ucs7604.h
  ├─    4.6 ms - fl/chipsets/apa102.h
  ├─    1.2 ms - fl/chipsets/lpd880x.h
  ├─    0.6 ms - fl/chipsets/encoders/ws2816.h
  └─    0.6 ms - fl/chipsets/ws2801.h

TOP 20 SLOWEST OPERATIONS
--------------------------------------------------------------------------------
  1.  1103.7 ms - Source: FastLED.h
  2.  1103.7 ms - Total Source: 
  3.   622.1 ms - Source: fl/task/executor.h
  4.   423.1 ms - Total ParseClass: 
  5.   323.7 ms - Source: fl/fastled.h
  6.   319.2 ms - Source: fl/task/scheduler.h
  7.   312.4 ms - Source: fl/stl/singleton.h
  8.   311.9 ms - Source: fl/stl/thread_local.h
  9.   311.0 ms - Source: fl/stl/thread.h
 10.   310.9 ms - Source: platforms/thread.h
 11.   310.9 ms - Source: platforms/stub/thread_stub.h
 12.   310.8 ms - Source: platforms/stub/thread_stub_stl.h
 13.   306.2 ms - Source: thread
 14.   293.3 ms - Source: fl/task/promise.h
 15.   260.8 ms - Source: fl/stl/function.h
 16.   188.0 ms - Source: crgb.h
 17.   187.1 ms - Source: fl/gfx/crgb.h
 18.   186.0 ms - Source: std_thread.h
 19.   183.7 ms - Source: fl/math/ease.h
 20.   182.2 ms - Source: fl/math/fixed_point.h

PERFORMANCE FLAGS
--------------------------------------------------------------------------------
⚠️  SLOW HEADERS (>50.0ms):
    - FastLED.h (1103.7ms)
    - fl/task/executor.h (622.1ms)
    - fl/fastled.h (323.7ms)
    - fl/task/scheduler.h (319.2ms)
    - fl/stl/singleton.h (312.4ms)
    - fl/stl/thread_local.h (311.9ms)
    - fl/stl/thread.h (311.0ms)
    - platforms/thread.h (310.9ms)
    - platforms/stub/thread_stub.h (310.9ms)
    - platforms/stub/thread_stub_stl.h (310.8ms)

⚠️  Template instantiation time is high (28.8% of total)
✓  Lexing time is acceptable (<10% of total)

RECOMMENDATIONS
--------------------------------------------------------------------------------
1. Consider optimizing FastLED.h (1103.7ms)
2. Consider optimizing fl/task/executor.h (622.1ms)
3. Consider optimizing fl/fastled.h (323.7ms)

================================================================================

Adds the v1 asset pipeline so sketches can write
`fl::UIAudio audio("Audio", FL_ASSET("data/track.mp3"))` and have the
path resolved to a URL on WASM (via a build-time manifest) or to a local
file/URL on host/stub.

- `src/fl/asset.h` — `fl::asset_ref` handle, `FL_ASSET()` macro with
  compile-time rejection of `..` paths via `static_assert`.
- `src/fl/asset.cpp.hpp` — runtime resolver: registry-first, then on
  host/stub probe filesystem then sibling `*.lnk` as a fallback.
- `src/fl/stl/url.h` — add `parse_lnk_with_metadata()` returning URL +
  optional `sha256=` / `fallback=` metadata (v1: parsed but not
  enforced; reserved for future integrity/fallback features).
- `src/fl/ui.h` + `src/fl/ui.cpp.hpp` — new
  `UIAudio(name, fl::asset_ref)` overload that resolves then forwards
  to the existing url ctor.
- `ci/compiler/asset_scanner.py` — new fbuild-side scanner that walks
  `<sketch>/data/` for `*.lnk` files and emits a JSON manifest +
  `window.fastledAssetManifest` JS snippet + C++ header of
  `fl::register_asset` calls.
- `ci/wasm_build.py` — emit `asset_manifest.json` alongside fastled.js.
- `src/platforms/wasm/compiler/index.ts` — fetch and inject
  `window.fastledAssetManifest` at startup.
- Tests: `tests/fl/asset.cpp` covers compile-time `..` rejection,
  runtime resolution, host filesystem probe, and sibling-`.lnk`
  fallback. `tests/fl/stl/url.cpp` adds `parse_lnk_with_metadata()`
  cases. `ci/tests/test_asset_scanner.py` covers the Python scanner.
- Example: keep the inline-`fl::url` path in
  `examples/AudioUrl/AudioUrl.ino` (regression coverage) and document
  the new `FL_ASSET()` variant in a commented-out line alongside. The
  sketch's existing `data/track.mp3.lnk` stays in place.

v1 scope per issue #2284: WASM + host/stub only. ESP32 LittleFS is
tracked as future work (TODO comment in asset.cpp.hpp).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the feat/asset-pipeline-v1-2284 branch from 7191a2c to ec35801 Compare April 19, 2026 02:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (4)
src/fl/asset.cpp.hpp (2)

50-57: ⚠️ Potential issue | 🟡 Minor

Make duplicate registration actually last-writer-wins.

register_asset() appends mappings, but lookup_registry() returns the first match. That contradicts the src/fl/asset.h line 173 contract and prevents tests/host code from overriding generated entries.

Proposed lookup-order fix
 inline fl::url lookup_registry(fl::string_view path) FL_NOEXCEPT {
     auto& r = registry();
-    for (fl::size i = 0; i < r.size(); ++i) {
+    for (fl::size i = r.size(); i > 0; --i) {
+        const fl::size idx = i - 1;
         // Compare as string_view on both sides to avoid any ambiguity in the
         // fl::string / fl::string_view overload resolution.
-        fl::string_view candidate(r[i].path.c_str(), r[i].path.size());
+        fl::string_view candidate(r[idx].path.c_str(), r[idx].path.size());
         if (candidate == path) {
-            return r[i].url;
+            return r[idx].url;
         }
     }
     return fl::url();
 }

Also applies to: 118-121

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/asset.cpp.hpp` around lines 50 - 57, lookup_registry currently scans
the registry vector forward and returns the first matching entry, which makes
earlier registrations win; to implement last-writer-wins (matching
register_asset which appends), change lookup_registry to iterate the registry
from back to front (e.g., for i = r.size(); i-- > 0) and return the first match
found when scanning backwards; apply the same change to any other lookup
overloads (the other occurrence around the second lookup block) so that newly
appended mappings override earlier ones while preserving the existing
fl::string_view comparison logic.

103-109: ⚠️ Potential issue | 🟡 Minor

Validate how many bytes were read before parsing .lnk.

lnk.read(&content[0], sz) can read fewer bytes than requested; parsing the pre-sized buffer can then consume stale/trailing bytes. Check gcount() or fail closed before calling parse_lnk().

Proposed read validation
     fl::string content;
     content.resize(sz);
+    fl::size bytes_read = 0;
     if (sz > 0) {
         lnk.read(&content[0], sz);
+        bytes_read = static_cast<fl::size>(lnk.gcount());
     }
     lnk.close();
+    if (bytes_read != sz) {
+        return fl::url();
+    }
+    content.resize(bytes_read);
     return parse_lnk(fl::string_view(content.data(), content.size()));
 }

Verify the local stream API shape before patching:

#!/bin/bash
# Description: Confirm fl::ifstream exposes read-count/error APIs used for safe partial-read handling.
# Expect: fl::ifstream has read(...) plus gcount() or equivalent post-read status APIs.
rg -n -C3 '\bclass\s+ifstream\b|\bgcount\s*\(|\bread\s*\(|\bsize\s*\(' src/fl/stl
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/asset.cpp.hpp` around lines 103 - 109, The code pre-sizes fl::string
content and calls lnk.read(&content[0], sz) then parses the entire buffer with
parse_lnk, but lnk.read may return fewer bytes than requested; update the read
path to check the actual number of bytes read (e.g. via lnk.gcount() or the
stream's equivalent) and resize/truncate content to that count or fail closed
before calling parse_lnk; specifically modify the block that uses fl::string
content, lnk.read(...), and the subsequent lnk.close()/return parse_lnk(...) so
that parse_lnk receives only the bytes actually read (or an error is returned)
rather than any leftover uninitialized/stale bytes.
ci/compiler/asset_scanner.py (2)

33-78: ⚠️ Potential issue | 🟡 Minor

Add @typechecked and avoid the dict comprehension.

Both dataclasses are missing runtime type validation, and to_json_dict() uses a comprehension where the repo asks for explicit loops.

Proposed guideline fix
 import json
 from dataclasses import asdict, dataclass, field
 from pathlib import Path
+
+from typeguard import typechecked
@@
-@dataclass
+@typechecked
+@dataclass
 class AssetEntry:
@@
-@dataclass
+@typechecked
+@dataclass
 class AssetScanResult:
@@
     def to_json_dict(self) -> dict[str, dict[str, str | None]]:
         """Return manifest as a plain nested dict for JSON serialization."""
-        return {key: asdict(entry) for key, entry in self.manifest.items()}
+        result: dict[str, dict[str, str | None]] = {}
+        for key, entry in self.manifest.items():
+            result[key] = asdict(entry)
+        return result

As per coding guidelines: "Use @typechecked decorator with @dataclass for runtime type validation" and "Use explicit loops instead of list comprehensions for code clarity and debuggability."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/asset_scanner.py` around lines 33 - 78, Add runtime type
validation by decorating both dataclasses AssetEntry and AssetScanResult with
`@typechecked` (import the decorator from the appropriate typeguard/typechecking
library) and update AssetScanResult.to_json_dict to avoid a dict comprehension:
create an empty result dict, iterate over self.manifest.items() with an explicit
for loop, convert each AssetEntry to a plain dict using asdict and assign into
the result, then return it; keep the existing return type annotation dict[str,
dict[str, str | None]] and preserve all field names (manifest, warnings).

167-178: ⚠️ Potential issue | 🟡 Minor

Handle KeyboardInterrupt before other exceptions.

The repo guideline requires every Python try-catch block to include KeyboardInterrupt handling first.

Proposed guideline fix
         try:
             content = lnk_path.read_text(encoding="utf-8")
+        except KeyboardInterrupt:
+            raise
         except UnicodeDecodeError as exc:
             result.warnings.append(
                 f"asset-scan: {lnk_path}: not valid UTF-8 ({exc}); skipped"

As per coding guidelines: "All Python try-catch blocks must handle KeyboardInterrupt before other exceptions."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/asset_scanner.py` around lines 167 - 178, The try/except around
lnk_path.read_text must handle KeyboardInterrupt first: add an except
KeyboardInterrupt that re-raises the interrupt before the existing except
UnicodeDecodeError and except OSError handlers so that lnk_path.read_text(...)
doesn’t swallow Ctrl-C; update the block that appends to result.warnings (the
handlers that reference result.warnings.append and the lnk_path variable) to
come after the KeyboardInterrupt case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/compiler/asset_scanner.py`:
- Around line 216-217: The JSON payload produced by
json.dumps(scan.to_json_dict(), sort_keys=True) can contain the string
"</script>" which will terminate a surrounding <script> tag; after creating
payload (the variable named payload) replace occurrences of "</" with "<\/" (or
the equivalent safe escape such as "\u003c/") to neutralize script-closing
sequences, then return the bootstrapping string using that escaped payload
(update the line that builds and returns f"window.fastledAssetManifest =
{payload};\n" to use the escaped payload).
- Around line 116-122: The parser currently strips key and value after
partitioning which accepts entries like "sha256 = ..." that the C++ parser
ignores; to match C++ `src/fl/stl/url.h` behavior, strip the entire line first
(e.g., call line.strip() before partition) and then partition without stripping
key/value so keys must match exactly "sha256" or "fallback"; update the block
around the partition (variables key, value, sha256, fallback) to perform line =
line.strip() then key, _, value = line.partition("=") and remove the subsequent
key/value .strip() calls.

In `@src/fl/asset.h`:
- Around line 83-130: Make the unchecked constructor asset_ref(const char*,
fl::size) non-public (e.g., move it to private) so callers cannot bypass path
validation, and add/keep a single validated factory (the constexpr asset(const
char*) function) as the only public way to create asset_ref; inside that factory
ensure you first reject nullptr (if path == nullptr return empty asset_ref) and
only then call asset_detail::path_has_parent_segment(path) and
asset_detail::clen(path) to construct the private asset_ref; update any other
creation site (the other public overload referenced around lines 136-143) to use
this validated factory so resolve_asset() cannot receive unchecked paths.

---

Duplicate comments:
In `@ci/compiler/asset_scanner.py`:
- Around line 33-78: Add runtime type validation by decorating both dataclasses
AssetEntry and AssetScanResult with `@typechecked` (import the decorator from the
appropriate typeguard/typechecking library) and update
AssetScanResult.to_json_dict to avoid a dict comprehension: create an empty
result dict, iterate over self.manifest.items() with an explicit for loop,
convert each AssetEntry to a plain dict using asdict and assign into the result,
then return it; keep the existing return type annotation dict[str, dict[str, str
| None]] and preserve all field names (manifest, warnings).
- Around line 167-178: The try/except around lnk_path.read_text must handle
KeyboardInterrupt first: add an except KeyboardInterrupt that re-raises the
interrupt before the existing except UnicodeDecodeError and except OSError
handlers so that lnk_path.read_text(...) doesn’t swallow Ctrl-C; update the
block that appends to result.warnings (the handlers that reference
result.warnings.append and the lnk_path variable) to come after the
KeyboardInterrupt case.

In `@src/fl/asset.cpp.hpp`:
- Around line 50-57: lookup_registry currently scans the registry vector forward
and returns the first matching entry, which makes earlier registrations win; to
implement last-writer-wins (matching register_asset which appends), change
lookup_registry to iterate the registry from back to front (e.g., for i =
r.size(); i-- > 0) and return the first match found when scanning backwards;
apply the same change to any other lookup overloads (the other occurrence around
the second lookup block) so that newly appended mappings override earlier ones
while preserving the existing fl::string_view comparison logic.
- Around line 103-109: The code pre-sizes fl::string content and calls
lnk.read(&content[0], sz) then parses the entire buffer with parse_lnk, but
lnk.read may return fewer bytes than requested; update the read path to check
the actual number of bytes read (e.g. via lnk.gcount() or the stream's
equivalent) and resize/truncate content to that count or fail closed before
calling parse_lnk; specifically modify the block that uses fl::string content,
lnk.read(...), and the subsequent lnk.close()/return parse_lnk(...) so that
parse_lnk receives only the bytes actually read (or an error is returned) rather
than any leftover uninitialized/stale bytes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8f12f245-50f4-417d-8e19-39c00106d352

📥 Commits

Reviewing files that changed from the base of the PR and between 7191a2c and ec35801.

📒 Files selected for processing (14)
  • ci/compiler/asset_scanner.py
  • ci/tests/test_asset_scanner.py
  • ci/wasm_build.py
  • examples/AudioUrl/AudioUrl.ino
  • src/fl/_build.cpp.hpp
  • src/fl/asset.cpp.hpp
  • src/fl/asset.h
  • src/fl/build/fl.cpp
  • src/fl/stl/url.h
  • src/fl/ui.cpp.hpp
  • src/fl/ui.h
  • src/platforms/wasm/compiler/index.ts
  • tests/fl/asset.cpp
  • tests/fl/stl/url.cpp
✅ Files skipped from review due to trivial changes (4)
  • src/fl/build/fl.cpp
  • src/fl/_build.cpp.hpp
  • examples/AudioUrl/AudioUrl.ino
  • tests/fl/asset.cpp
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/fl/ui.cpp.hpp
  • tests/fl/stl/url.cpp
  • src/fl/stl/url.h
  • src/fl/ui.h
  • ci/tests/test_asset_scanner.py
  • src/platforms/wasm/compiler/index.ts
  • ci/wasm_build.py

Comment on lines +116 to +122
key, _, value = line.partition("=")
key = key.strip()
value = value.strip()
if key == "sha256":
sha256 = value
elif key == "fallback":
fallback = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Keep Python .lnk metadata parsing aligned with C++.

src/fl/stl/url.h lines 325-377 trims the full line but does not trim key/value after partition("="). This scanner accepts sha256 = ... and fallback = ... entries that C++ ignores, despite the docstring saying it mirrors the C++ parser.

Proposed parity fix
         key, _, value = line.partition("=")
-        key = key.strip()
-        value = value.strip()
         if key == "sha256":
             sha256 = value
         elif key == "fallback":
             fallback = value
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/asset_scanner.py` around lines 116 - 122, The parser currently
strips key and value after partitioning which accepts entries like "sha256 =
..." that the C++ parser ignores; to match C++ `src/fl/stl/url.h` behavior,
strip the entire line first (e.g., call line.strip() before partition) and then
partition without stripping key/value so keys must match exactly "sha256" or
"fallback"; update the block around the partition (variables key, value, sha256,
fallback) to perform line = line.strip() then key, _, value =
line.partition("=") and remove the subsequent key/value .strip() calls.

Comment on lines +216 to +217
payload = json.dumps(scan.to_json_dict(), sort_keys=True)
return f"window.fastledAssetManifest = {payload};\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Escape script-closing sequences in the JS bootstrap payload.

The doc says callers splice this into a <script> tag. A .lnk URL containing </script> can terminate that tag even inside a JSON string, so escape </ after json.dumps().

Proposed script-safe escaping
 def manifest_to_js_bootstrap(scan: AssetScanResult) -> str:
@@
-    payload = json.dumps(scan.to_json_dict(), sort_keys=True)
+    payload = json.dumps(scan.to_json_dict(), sort_keys=True)
+    payload = payload.replace("</", "<\\/")
     return f"window.fastledAssetManifest = {payload};\n"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
payload = json.dumps(scan.to_json_dict(), sort_keys=True)
return f"window.fastledAssetManifest = {payload};\n"
payload = json.dumps(scan.to_json_dict(), sort_keys=True)
payload = payload.replace("</", "<\\/")
return f"window.fastledAssetManifest = {payload};\n"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/compiler/asset_scanner.py` around lines 216 - 217, The JSON payload
produced by json.dumps(scan.to_json_dict(), sort_keys=True) can contain the
string "</script>" which will terminate a surrounding <script> tag; after
creating payload (the variable named payload) replace occurrences of "</" with
"<\/" (or the equivalent safe escape such as "\u003c/") to neutralize
script-closing sequences, then return the bootstrapping string using that
escaped payload (update the line that builds and returns
f"window.fastledAssetManifest = {payload};\n" to use the escaped payload).

Comment thread src/fl/asset.h
Comment on lines +83 to +130
class asset_ref {
public:
/// Construct from a pointer to a null-terminated string with known length.
/// The pointer MUST outlive the `asset_ref` — typically a string literal.
constexpr asset_ref(const char* path, fl::size length) FL_NOEXCEPT
: mPath(path), mLength(length) {}

/// Default-constructed handle refers to no asset.
constexpr asset_ref() FL_NOEXCEPT : mPath(nullptr), mLength(0) {}

/// Copy/move: trivial — pointer + length. Can't combine `constexpr` with
/// `= default` on the assignment operator pre-C++14, so we leave these as
/// the implicitly-declared operations (the class is trivially copyable).
asset_ref(const asset_ref&) FL_NOEXCEPT = default;
asset_ref& operator=(const asset_ref&) FL_NOEXCEPT = default;

/// True if this handle refers to an asset path.
constexpr explicit operator bool() const FL_NOEXCEPT {
return mPath != nullptr && mLength > 0;
}

/// The relative asset path as a string view (e.g. "data/track.mp3").
fl::string_view path() const FL_NOEXCEPT {
return fl::string_view(mPath, mLength);
}

/// Pointer accessor — useful for JSON serialization.
constexpr const char* c_str() const FL_NOEXCEPT { return mPath; }
constexpr fl::size size() const FL_NOEXCEPT { return mLength; }

private:
const char* mPath;
fl::size mLength;
};

/// Construct an asset handle from a relative sketch path at runtime.
///
/// For **compile-time rejection** of `..` paths, use the `FL_ASSET()` macro
/// instead — it wraps this function with a `static_assert`.
///
/// This overload accepts any `const char*` (including runtime-computed
/// pointers) and, for safety, returns an empty handle if the path contains
/// a `..` segment. Runtime resolution also refuses to walk past `data/`, so
/// this is defense-in-depth rather than the primary gate.
constexpr asset_ref asset(const char* path) FL_NOEXCEPT {
return asset_detail::path_has_parent_segment(path)
? asset_ref()
: asset_ref(path, asset_detail::clen(path));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Close the unchecked construction path and reject null input.

asset_ref(const char*, size) is public, so callers can bypass the .. validation with fl::asset_ref("../x", 4) and resolve_asset() will later use that path. Also, fl::asset(nullptr) reaches clen(nullptr) because path_has_parent_segment(nullptr) returns false.

Proposed validation-boundary fix
 class asset_ref {
   public:
-    /// Construct from a pointer to a null-terminated string with known length.
-    /// The pointer MUST outlive the `asset_ref` — typically a string literal.
-    constexpr asset_ref(const char* path, fl::size length) FL_NOEXCEPT
-        : mPath(path), mLength(length) {}
-
     /// Default-constructed handle refers to no asset.
     constexpr asset_ref() FL_NOEXCEPT : mPath(nullptr), mLength(0) {}
@@
   private:
+    friend constexpr asset_ref asset(const char* path) FL_NOEXCEPT;
+
+    /// Construct from a validated pointer to a null-terminated string with known length.
+    constexpr asset_ref(const char* path, fl::size length) FL_NOEXCEPT
+        : mPath(path), mLength(length) {}
+
     const char* mPath;
     fl::size mLength;
 };
@@
 constexpr asset_ref asset(const char* path) FL_NOEXCEPT {
-    return asset_detail::path_has_parent_segment(path)
+    return (path == nullptr || asset_detail::path_has_parent_segment(path))
                ? asset_ref()
                : asset_ref(path, asset_detail::clen(path));
 }
@@
         static_assert(                                                         \
             !::fl::asset_detail::path_has_parent_segment(LITERAL_PATH),        \
             "fl::asset path must not contain '..' segments");                  \
-        return ::fl::asset_ref(                                                \
-            (LITERAL_PATH), ::fl::asset_detail::clen(LITERAL_PATH));           \
+        return ::fl::asset(LITERAL_PATH);                                      \
     }())

Also applies to: 136-143

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/asset.h` around lines 83 - 130, Make the unchecked constructor
asset_ref(const char*, fl::size) non-public (e.g., move it to private) so
callers cannot bypass path validation, and add/keep a single validated factory
(the constexpr asset(const char*) function) as the only public way to create
asset_ref; inside that factory ensure you first reject nullptr (if path ==
nullptr return empty asset_ref) and only then call
asset_detail::path_has_parent_segment(path) and asset_detail::clen(path) to
construct the private asset_ref; update any other creation site (the other
public overload referenced around lines 136-143) to use this validated factory
so resolve_asset() cannot receive unchecked paths.

@zackees
zackees merged commit 8675488 into master Apr 19, 2026
53 of 88 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📊 Header Compilation Performance

Total Time: 1183.38ms

Top 5 Slowest Headers

  1. FastLED.h - 908.33ms
  2. fl/fastled.h - 388.95ms
  3. fl/task/executor.h - 295.91ms
  4. crgb.h - 222.17ms
  5. fl/gfx/crgb.h - 220.84ms

Warnings

⚠️ Header FastLED.h exceeds 150ms (908.3ms)
⚠️ Header fl/fastled.h exceeds 150ms (389.0ms)
⚠️ Header fl/task/executor.h exceeds 150ms (295.9ms)
⚠️ Header crgb.h exceeds 150ms (222.2ms)
⚠️ Header fl/gfx/crgb.h exceeds 150ms (220.8ms)
⚠️ Header fl/math/ease.h exceeds 150ms (215.9ms)
⚠️ Header fl/math/fixed_point.h exceeds 150ms (213.5ms)
⚠️ Header fl/task/scheduler.h exceeds 150ms (160.6ms)
⚠️ Header fl/stl/singleton.h exceeds 150ms (151.1ms)
⚠️ Header fl/stl/thread_local.h exceeds 150ms (150.4ms)
⚠️ Header fl/stl/thread.h exceeds 50ms (149.3ms)
⚠️ Header platforms/thread.h exceeds 50ms (149.2ms)
⚠️ Header platforms/stub/thread_stub.h exceeds 50ms (149.1ms)
⚠️ Header platforms/stub/thread_stub_stl.h exceeds 50ms (149.1ms)
⚠️ Header fl/ui.h exceeds 50ms (122.7ms)
⚠️ Header fl/task/promise.h exceeds 50ms (121.4ms)
⚠️ Header fl/stl/json.h exceeds 50ms (76.6ms)
⚠️ Header fl/stl/function.h exceeds 50ms (72.2ms)
⚠️ Header fl/math/fixed_point/s4x12.h exceeds 50ms (63.8ms)
⚠️ Header fl/stl/json/types.h exceeds 50ms (59.5ms)
⚠️ Header platforms.h exceeds 50ms (56.0ms)
⚠️ Header platforms/stub/fastled_stub.h exceeds 50ms (55.9ms)
⚠️ Template instantiation time is high (52.0%)

Full Report
================================================================================
FASTLED COMPILATION PERFORMANCE REPORT
================================================================================
Generated: 2026-04-19 03:49:02
Compiler: clang++-17
File: ci/perf/test_compile.cpp

SUMMARY
--------------------------------------------------------------------------------
Total Compilation Time:    1,996.15 ms
Frontend Time:             17.21 ms (0.9%)
Backend Time:              176.73 ms (8.9%)

COMPILATION PHASES
--------------------------------------------------------------------------------
Source                    12214.14 ms (611.9%)
Templates                   608.61 ms ( 30.5%)

FASTLED HEADERS (Level 1 - Direct Includes)
--------------------------------------------------------------------------------
  1478.4 ms - FastLED.h (SLOW)
   700.2 ms - fl/task/executor.h (SLOW)
   508.2 ms - fl/fastled.h (SLOW)
   369.3 ms - fl/task/scheduler.h (SLOW)
   359.8 ms - fl/stl/singleton.h (SLOW)
   359.1 ms - fl/stl/thread_local.h (SLOW)
   358.0 ms - fl/stl/thread.h (SLOW)
   357.9 ms - platforms/thread.h (SLOW)
   357.8 ms - platforms/stub/thread_stub.h (SLOW)
   357.8 ms - platforms/stub/thread_stub_stl.h (SLOW)
   317.2 ms - fl/task/promise.h (SLOW)
   315.2 ms - crgb.h (SLOW)
   313.9 ms - fl/gfx/crgb.h (SLOW)
   309.0 ms - fl/math/ease.h (SLOW)
   306.6 ms - fl/math/fixed_point.h (SLOW)
   268.0 ms - fl/stl/function.h (SLOW)
   159.6 ms - fl/math/fixed_point/s4x12.h (SLOW)
   138.7 ms - fl/math/sin32.h (SLOW)
   135.5 ms - fl/math/simd.h (SLOW)
   134.9 ms - fl/math/simd/types.h (SLOW)

FASTLED HEADERS (Nested Includes - Up to 10 Levels)
--------------------------------------------------------------------------------
FastLED.h (1478.4ms)
  ├─  700.2 ms - fl/task/executor.h
  │ ├─  369.3 ms - fl/task/scheduler.h
  │ │ ├─  359.8 ms - fl/stl/singleton.h
  │ │ │ └─  359.1 ms - fl/stl/thread_local.h
  │ │ │   └─  358.0 ms - fl/stl/thread.h
  │ │ │     └─  357.9 ms - platforms/thread.h
  │ │ │       └─  357.8 ms - platforms/stub/thread_stub.h
  │ │ │         └─  357.8 ms - platforms/stub/thread_stub_stl.h
  │ │ │           └─  350.6 ms - thread
  │ │ │             ├─  186.3 ms - std_thread.h
  │ │ │             └─  148.7 ms - this_thread_sleep.h
  │ │ └─    8.7 ms - fl/task/task.h
  │ │   └─    3.5 ms - fl/trace.h
  │ │     ├─    2.3 ms - fl/stl/chrono.h
  │ │     └─    1.0 ms - fl/stl/tuple.h
  │ ├─  317.2 ms - fl/task/promise.h
  │ │ ├─  268.0 ms - fl/stl/function.h
  │ │ │ ├─  107.8 ms - fl/stl/vector.h
  │ │ │ │ ├─   73.8 ms - fl/math/math.h
  │ │ │ │ │ └─   68.1 ms - fl/stl/undef.h
  │ │ │ │ │   └─  118.1 ms - stdlib.h
  │ │ │ │ │     ├─   59.9 ms - cstdlib
  │ │ │ │ │     │ └─  118.1 ms - stdlib.h
  │ │ │ │ │     │   ├─   59.9 ms - cstdlib
  │ │ │ │ │     │   ├─   14.8 ms - types.h
  │ │ │ │ │     │   ├─    0.7 ms - floatn.h
  │ │ │ │ │     │   └─    0.6 ms - locale_t.h
  │ │ │ │ │     ├─   14.8 ms - types.h
  │ │ │ │ │     │ ├─   14.8 ms - types.h
  │ │ │ │ │     │ │ ├─   14.8 ms - types.h
  │ │ │ │ │     │ │ ├─    3.2 ms - pthreadtypes.h
  │ │ │ │ │     │ │ ├─    2.4 ms - select.h
  │ │ │ │ │     │ │ └─    2.0 ms - endian.h
  │ │ │ │ │     │ ├─    3.2 ms - pthreadtypes.h
  │ │ │ │ │     │ │ └─    2.4 ms - thread-shared-types.h
  │ │ │ │ │     │ ├─    2.4 ms - select.h
  │ │ │ │ │     │ │ └─    0.6 ms - sigset_t.h
  │ │ │ │ │     │ └─    2.0 ms - endian.h
  │ │ │ │ │     ├─    0.7 ms - floatn.h
  │ │ │ │ │     └─    0.6 ms - locale_t.h
  │ │ │ │ ├─   18.6 ms - fl/stl/allocator.h
  │ │ │ │ │ └─   12.7 ms - fl/stl/bitset.h
  │ │ │ │ │   └─    8.1 ms - fl/stl/bitset_dynamic.h
  │ │ │ │ │     └─    2.1 ms - fl/stl/unique_ptr.h
  │ │ │ │ ├─    4.4 ms - fl/stl/initializer_list.h
  │ │ │ │ ├─    2.8 ms - fl/stl/basic_vector.h
  │ │ │ │ └─    0.7 ms - fl/stl/functional.h
  │ │ │ ├─  100.6 ms - fl/stl/shared_ptr.h
  │ │ │ │ ├─   79.2 ms - fl/stl/type_traits.h
  │ │ │ │ │ └─   72.5 ms - fl/stl/move.h
  │ │ │ │ ├─   16.4 ms - fl/stl/atomic.h
  │ │ │ │ │ └─   15.4 ms - platforms/atomic.h
  │ │ │ │ │   └─   15.3 ms - platforms/shared/atomic.h
  │ │ │ │ └─    0.8 ms - fl/stl/bit_cast.h
  │ │ │ ├─   44.3 ms - fl/stl/variant.h
  │ │ │ │ └─   42.5 ms - fl/stl/new.h
  │ │ │ │   └─   42.5 ms - platforms/new.h
  │ │ │ │     └─   42.5 ms - platforms/shared/new.h
  │ │ │ │       └─   34.1 ms - new
  │ │ │ │         ├─   17.6 ms - c++config.h
  │ │ │ │         │ └─    7.2 ms - os_defines.h
  │ │ │ │         └─    0.5 ms - version.h
  │ │ │ ├─    5.0 ms - fl/stl/compiler_control.h
  │ │ │ └─    4.7 ms - fl/stl/algorithm.h
  │ │ │   └─    2.0 ms - fl/math/random.h
  │ │ │     └─    0.9 ms - fl/math/random8.h
  │ │ └─   44.0 ms - fl/stl/string.h
  │ │   ├─   12.8 ms - fl/stl/basic_string.h
  │ │   │ ├─    1.1 ms - fl/stl/not_null.h
  │ │   │ ├─    0.9 ms - fl/stl/iterator.h
  │ │   │ └─    0.5 ms - fl/stl/charconv.h
  │ │   ├─    8.8 ms - fl/stl/span.h
  │ │   │ └─    3.5 ms - fl/math/geometry.h
  │ │   ├─    5.6 ms - fl/stl/string_view.h
  │ │   └─    1.5 ms - fl/stl/optional.h
  │ ├─   11.4 ms - platforms/await.h
  │ │ └─   11.0 ms - platforms/coroutine_runtime.h
  │ │   └─    9.4 ms - fl/system/engine_events.h
  │ │     ├─    4.9 ms - fl/math/screenmap.h
  │ │     │ └─    3.6 ms - fl/stl/flat_map.h
  │ │     └─    3.0 ms - fl/math/xymap.h
  │ │       └─    0.8 ms - fl/math/lut.h
  │ └─    0.8 ms - fl/task/promise_result.h
  ├─  508.2 ms - fl/fastled.h
  │ ├─  315.2 ms - crgb.h
  │ │ ├─  313.9 ms - fl/gfx/crgb.h
  │ │ │ └─  309.0 ms - fl/math/ease.h
  │ │ │   └─  306.6 ms - fl/math/fixed_point.h
  │ │ │     ├─  159.6 ms - fl/math/fixed_point/s4x12.h
  │ │ │     │ ├─  138.7 ms - fl/math/sin32.h
  │ │ │     │ │ └─  135.5 ms - fl/math/simd.h
  │ │ │     │ │   └─  134.9 ms - fl/math/simd/types.h
  │ │ │     │ │     └─  134.7 ms - platforms/simd.h
  │ │ │     │ ├─    1.1 ms - fl/math/fixed_point/traits.h
  │ │ │     │ └─    0.8 ms - fl/math/fixed_point/isqrt.h
  │ │ │     ├─   18.6 ms - fl/math/fixed_point/s8x8.h
  │ │ │     ├─   18.5 ms - fl/math/fixed_point/s8x24.h
  │ │ │     ├─   18.5 ms - fl/math/fixed_point/s16x16.h
  │ │ │     └─   18.2 ms - fl/math/fixed_point/s24x8.h
  │ │ └─    0.9 ms - chsv.h
  │ │   └─    0.8 ms - fl/gfx/hsv.h
  │ ├─   83.5 ms - platforms.h
  │ │ └─   83.4 ms - platforms/stub/fastled_stub.h
  │ │   ├─   46.7 ms - platforms/stub/fastspi_stub.h
  │ │   │ └─   46.6 ms - platforms/stub/fastspi_stub_generic.h
  │ │   │   ├─   40.4 ms - platforms/shared/active_strip_data/active_strip_data.h
  │ │   │   │ └─   38.3 ms - fl/id_tracker.h
  │ │   │   │   └─   37.3 ms - fl/stl/mutex.h
  │ │   │   │     └─   37.3 ms - platforms/mutex.h
  │ │   │   │       └─   37.1 ms - platforms/stub/mutex_stub.h
  │ │   │   └─    5.9 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │ │   └─   36.6 ms - platforms/stub/clockless_stub.h
  │ │     └─   36.6 ms - platforms/stub/clockless_channel_stub.h
  │ │       ├─   13.1 ms - fl/system/log.h
  │ │       │ └─   12.6 ms - fl/stl/strstream.h
  │ │       ├─   12.9 ms - fl/channels/data.h
  │ │       │ └─    9.7 ms - fl/channels/config.h
  │ │       │   ├─    2.2 ms - fl/chipsets/chipset_timing_config.h
  │ │       │   │ └─    1.5 ms - fl/chipsets/led_timing.h
  │ │       │   └─    1.7 ms - fl/chipsets/spi.h
  │ │       ├─    2.3 ms - fl/channels/manager.h
  │ │       ├─    1.6 ms - fl/stl/weak_ptr.h
  │ │       └─    1.1 ms - fl/channels/driver.h
  │ ├─   41.7 ms - colorutils.h
  │ │ └─   40.9 ms - fl/gfx/colorutils.h
  │ │   ├─    8.7 ms - fl/gfx/blur.h
  │ │   │ └─    4.6 ms - fl/gfx/canvas.h
  │ │   │   └─    2.8 ms - fl/math/alpha.h
  │ │   └─    3.1 ms - fl/gfx/fill.h
  │ ├─   23.5 ms - pixel_controller.h
  │ │ ├─   17.0 ms - pixel_iterator.h
  │ │ │ └─   16.9 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │ │   ├─    5.0 ms - fl/chipsets/encoders/apa102.h
  │ │ │   │ └─    3.9 ms - fl/chipsets/encoders/encoder_utils.h
  │ │ │   │   └─    3.2 ms - fl/gfx/gamma_lut.h
  │ │ │   ├─    4.4 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │ │   ├─    1.1 ms - fl/chipsets/encoders/sk9822.h
  │ │ │   └─    0.9 ms - fl/chipsets/encoders/hd108.h
  │ │ └─    2.6 ms - rgbw.h
  │ │   └─    2.4 ms - fl/gfx/rgbw.h
  │ └─   22.7 ms - pixeltypes.h
  │   ├─   19.1 ms - lib8tion.h
  │   │ ├─    9.9 ms - fl/math/math8.h
  │   │ │ ├─    5.2 ms - fl/math/intmap.h
  │   │ │ │ └─    4.1 ms - platforms/intmap.h
  │   │ │ ├─    2.5 ms - fl/math/scale8.h
  │   │ │ │ └─    2.4 ms - platforms/scale8.h
  │   │ │ │   └─    1.0 ms - platforms/shared/scale8.h
  │   │ │ └─    2.1 ms - platforms/math8.h
  │   │ │   └─    1.7 ms - platforms/shared/math8.h
  │   │ └─    2.0 ms - fl/math/beat.h
  │   │   └─    1.0 ms - fl/math/trig8.h
  │   │     └─    1.0 ms - platforms/trig8.h
  │   │       └─    0.9 ms - platforms/shared/trig8.h
  │   └─    3.2 ms - crgb.hpp
  ├─  121.0 ms - fl/ui.h
  │ ├─   75.8 ms - fl/stl/json.h
  │ │ └─   58.7 ms - fl/stl/json/types.h
  │ │   └─    7.4 ms - fl/stl/limits.h
  │ ├─   10.2 ms - fl/ui_impl.h
  │ │ └─    9.6 ms - platforms/ui_defs.h
  │ │   ├─    2.1 ms - platforms/shared/ui/json/audio.h
  │ │   │ └─    1.0 ms - platforms/shared/ui/json/audio_internal.h
  │ │   ├─    1.7 ms - platforms/shared/ui/json/button.h
  │ │   │ └─    0.6 ms - platforms/shared/ui/json/ui_internal.h
  │ │   ├─    0.9 ms - platforms/shared/ui/json/dropdown.h
  │ │   ├─    0.9 ms - platforms/shared/ui/json/help.h
  │ │   └─    0.9 ms - platforms/shared/ui/json/checkbox.h
  │ └─    9.6 ms - fl/asset.h
  │   └─    8.5 ms - fl/stl/url.h
  ├─   28.7 ms - platforms/is_platform.h
  │ └─   28.3 ms - platforms/esp/is_esp.h
  │   └─   28.2 ms - platforms/esp/esp_version.h
  └─   28.3 ms - chipsets.h
    ├─   11.4 ms - fl/chipsets/ucs7604.h
    │ └─    8.5 ms - fl/chipsets/encoders/ucs7604.h
    ├─    6.8 ms - fl/chipsets/apa102.h
    ├─    1.7 ms - fl/chipsets/lpd880x.h
    ├─    0.8 ms - fl/chipsets/p9813.h
    └─    0.8 ms - fl/chipsets/ws2801.h
fl/task/executor.h (700.2ms)
  ├─  369.3 ms - fl/task/scheduler.h
  │ ├─  359.8 ms - fl/stl/singleton.h
  │ │ └─  359.1 ms - fl/stl/thread_local.h
  │ │   └─  358.0 ms - fl/stl/thread.h
  │ │     └─  357.9 ms - platforms/thread.h
  │ │       └─  357.8 ms - platforms/stub/thread_stub.h
  │ │         └─  357.8 ms - platforms/stub/thread_stub_stl.h
  │ │           └─  350.6 ms - thread
  │ │             ├─  186.3 ms - std_thread.h
  │ │             │ ├─   61.6 ms - tuple
  │ │             │ ├─   34.9 ms - iosfwd
  │ │             │ ├─   23.1 ms - refwrap.h
  │ │             │ ├─   13.9 ms - gthr.h
  │ │             │ └─    6.0 ms - unique_ptr.h
  │ │             └─  148.7 ms - this_thread_sleep.h
  │ │               ├─  132.0 ms - chrono.h
  │ │               └─    7.7 ms - cerrno
  │ └─    8.7 ms - fl/task/task.h
  │   └─    3.5 ms - fl/trace.h
  │     ├─    2.3 ms - fl/stl/chrono.h
  │     └─    1.0 ms - fl/stl/tuple.h
  ├─  317.2 ms - fl/task/promise.h
  │ ├─  268.0 ms - fl/stl/function.h
  │ │ ├─  107.8 ms - fl/stl/vector.h
  │ │ │ ├─   73.8 ms - fl/math/math.h
  │ │ │ │ └─   68.1 ms - fl/stl/undef.h
  │ │ │ │   └─  118.1 ms - stdlib.h
  │ │ │ │     ├─   59.9 ms - cstdlib
  │ │ │ │     │ └─  118.1 ms - stdlib.h
  │ │ │ │     │   ├─   59.9 ms - cstdlib
  │ │ │ │     │   │ └─  118.1 ms - stdlib.h
  │ │ │ │     │   ├─   14.8 ms - types.h
  │ │ │ │     │   │ ├─   14.8 ms - types.h
  │ │ │ │     │   │ ├─    3.2 ms - pthreadtypes.h
  │ │ │ │     │   │ ├─    2.4 ms - select.h
  │ │ │ │     │   │ └─    2.0 ms - endian.h
  │ │ │ │     │   ├─    0.7 ms - floatn.h
  │ │ │ │     │   └─    0.6 ms - locale_t.h
  │ │ │ │     ├─   14.8 ms - types.h
  │ │ │ │     │ ├─   14.8 ms - types.h
  │ │ │ │     │ │ ├─   14.8 ms - types.h
  │ │ │ │     │ │ │ ├─   14.8 ms - types.h
  │ │ │ │     │ │ │ ├─    3.2 ms - pthreadtypes.h
  │ │ │ │     │ │ │ ├─    2.4 ms - select.h
  │ │ │ │     │ │ │ └─    2.0 ms - endian.h
  │ │ │ │     │ │ ├─    3.2 ms - pthreadtypes.h
  │ │ │ │     │ │ │ └─    2.4 ms - thread-shared-types.h
  │ │ │ │     │ │ ├─    2.4 ms - select.h
  │ │ │ │     │ │ │ └─    0.6 ms - sigset_t.h
  │ │ │ │     │ │ └─    2.0 ms - endian.h
  │ │ │ │     │ ├─    3.2 ms - pthreadtypes.h
  │ │ │ │     │ │ └─    2.4 ms - thread-shared-types.h
  │ │ │ │     │ ├─    2.4 ms - select.h
  │ │ │ │     │ │ └─    0.6 ms - sigset_t.h
  │ │ │ │     │ └─    2.0 ms - endian.h
  │ │ │ │     ├─    0.7 ms - floatn.h
  │ │ │ │     └─    0.6 ms - locale_t.h
  │ │ │ ├─   18.6 ms - fl/stl/allocator.h
  │ │ │ │ └─   12.7 ms - fl/stl/bitset.h
  │ │ │ │   └─    8.1 ms - fl/stl/bitset_dynamic.h
  │ │ │ │     └─    2.1 ms - fl/stl/unique_ptr.h
  │ │ │ ├─    4.4 ms - fl/stl/initializer_list.h
  │ │ │ ├─    2.8 ms - fl/stl/basic_vector.h
  │ │ │ └─    0.7 ms - fl/stl/functional.h
  │ │ ├─  100.6 ms - fl/stl/shared_ptr.h
  │ │ │ ├─   79.2 ms - fl/stl/type_traits.h
  │ │ │ │ └─   72.5 ms - fl/stl/move.h
  │ │ │ ├─   16.4 ms - fl/stl/atomic.h
  │ │ │ │ └─   15.4 ms - platforms/atomic.h
  │ │ │ │   └─   15.3 ms - platforms/shared/atomic.h
  │ │ │ └─    0.8 ms - fl/stl/bit_cast.h
  │ │ ├─   44.3 ms - fl/stl/variant.h
  │ │ │ └─   42.5 ms - fl/stl/new.h
  │ │ │   └─   42.5 ms - platforms/new.h
  │ │ │     └─   42.5 ms - platforms/shared/new.h
  │ │ │       └─   34.1 ms - new
  │ │ │         ├─   17.6 ms - c++config.h
  │ │ │         │ └─    7.2 ms - os_defines.h
  │ │ │         │   └─    6.6 ms - features.h
  │ │ │         └─    0.5 ms - version.h
  │ │ ├─    5.0 ms - fl/stl/compiler_control.h
  │ │ └─    4.7 ms - fl/stl/algorithm.h
  │ │   └─    2.0 ms - fl/math/random.h
  │ │     └─    0.9 ms - fl/math/random8.h
  │ └─   44.0 ms - fl/stl/string.h
  │   ├─   12.8 ms - fl/stl/basic_string.h
  │   │ ├─    1.1 ms - fl/stl/not_null.h
  │   │ ├─    0.9 ms - fl/stl/iterator.h
  │   │ └─    0.5 ms - fl/stl/charconv.h
  │   ├─    8.8 ms - fl/stl/span.h
  │   │ └─    3.5 ms - fl/math/geometry.h
  │   ├─    5.6 ms - fl/stl/string_view.h
  │   └─    1.5 ms - fl/stl/optional.h
  ├─   11.4 ms - platforms/await.h
  │ └─   11.0 ms - platforms/coroutine_runtime.h
  │   └─    9.4 ms - fl/system/engine_events.h
  │     ├─    4.9 ms - fl/math/screenmap.h
  │     │ └─    3.6 ms - fl/stl/flat_map.h
  │     └─    3.0 ms - fl/math/xymap.h
  │       └─    0.8 ms - fl/math/lut.h
  └─    0.8 ms - fl/task/promise_result.h
fl/fastled.h (508.2ms)
  ├─  315.2 ms - crgb.h
  │ ├─  313.9 ms - fl/gfx/crgb.h
  │ │ └─  309.0 ms - fl/math/ease.h
  │ │   └─  306.6 ms - fl/math/fixed_point.h
  │ │     ├─  159.6 ms - fl/math/fixed_point/s4x12.h
  │ │     │ ├─  138.7 ms - fl/math/sin32.h
  │ │     │ │ └─  135.5 ms - fl/math/simd.h
  │ │     │ │   └─  134.9 ms - fl/math/simd/types.h
  │ │     │ │     └─  134.7 ms - platforms/simd.h
  │ │     │ │       └─  134.6 ms - platforms/shared/simd_x86.hpp
  │ │     │ ├─    1.1 ms - fl/math/fixed_point/traits.h
  │ │     │ └─    0.8 ms - fl/math/fixed_point/isqrt.h
  │ │     ├─   18.6 ms - fl/math/fixed_point/s8x8.h
  │ │     ├─   18.5 ms - fl/math/fixed_point/s8x24.h
  │ │     ├─   18.5 ms - fl/math/fixed_point/s16x16.h
  │ │     └─   18.2 ms - fl/math/fixed_point/s24x8.h
  │ └─    0.9 ms - chsv.h
  │   └─    0.8 ms - fl/gfx/hsv.h
  ├─   83.5 ms - platforms.h
  │ └─   83.4 ms - platforms/stub/fastled_stub.h
  │   ├─   46.7 ms - platforms/stub/fastspi_stub.h
  │   │ └─   46.6 ms - platforms/stub/fastspi_stub_generic.h
  │   │   ├─   40.4 ms - platforms/shared/active_strip_data/active_strip_data.h
  │   │   │ └─   38.3 ms - fl/id_tracker.h
  │   │   │   └─   37.3 ms - fl/stl/mutex.h
  │   │   │     └─   37.3 ms - platforms/mutex.h
  │   │   │       └─   37.1 ms - platforms/stub/mutex_stub.h
  │   │   │         └─   37.1 ms - platforms/stub/mutex_stub_stl.h
  │   │   └─    5.9 ms - platforms/shared/active_strip_tracker/active_strip_tracker.h
  │   └─   36.6 ms - platforms/stub/clockless_stub.h
  │     └─   36.6 ms - platforms/stub/clockless_channel_stub.h
  │       ├─   13.1 ms - fl/system/log.h
  │       │ └─   12.6 ms - fl/stl/strstream.h
  │       ├─   12.9 ms - fl/channels/data.h
  │       │ └─    9.7 ms - fl/channels/config.h
  │       │   ├─    2.2 ms - fl/chipsets/chipset_timing_config.h
  │       │   │ └─    1.5 ms - fl/chipsets/led_timing.h
  │       │   └─    1.7 ms - fl/chipsets/spi.h
  │       ├─    2.3 ms - fl/channels/manager.h
  │       ├─    1.6 ms - fl/stl/weak_ptr.h
  │       └─    1.1 ms - fl/channels/driver.h
  ├─   41.7 ms - colorutils.h
  │ └─   40.9 ms - fl/gfx/colorutils.h
  │   ├─    8.7 ms - fl/gfx/blur.h
  │   │ └─    4.6 ms - fl/gfx/canvas.h
  │   │   └─    2.8 ms - fl/math/alpha.h
  │   └─    3.1 ms - fl/gfx/fill.h
  ├─   23.5 ms - pixel_controller.h
  │ ├─   17.0 ms - pixel_iterator.h
  │ │ └─   16.9 ms - fl/chipsets/encoders/pixel_iterator.h
  │ │   ├─    5.0 ms - fl/chipsets/encoders/apa102.h
  │ │   │ └─    3.9 ms - fl/chipsets/encoders/encoder_utils.h
  │ │   │   └─    3.2 ms - fl/gfx/gamma_lut.h
  │ │   ├─    4.4 ms - fl/chipsets/encoders/pixel_iterator_adapters.h
  │ │   ├─    1.1 ms - fl/chipsets/encoders/sk9822.h
  │ │   └─    0.9 ms - fl/chipsets/encoders/hd108.h
  │ └─    2.6 ms - rgbw.h
  │   └─    2.4 ms - fl/gfx/rgbw.h
  └─   22.7 ms - pixeltypes.h
    ├─   19.1 ms - lib8tion.h
    │ ├─    9.9 ms - fl/math/math8.h
    │ │ ├─    5.2 ms - fl/math/intmap.h
    │ │ │ └─    4.1 ms - platforms/intmap.h
    │ │ ├─    2.5 ms - fl/math/scale8.h
    │ │ │ └─    2.4 ms - platforms/scale8.h
    │ │ │   └─    1.0 ms - platforms/shared/scale8.h
    │ │ └─    2.1 ms - platforms/math8.h
    │ │   └─    1.7 ms - platforms/shared/math8.h
    │ └─    2.0 ms - fl/math/beat.h
    │   └─    1.0 ms - fl/math/trig8.h
    │     └─    1.0 ms - platforms/trig8.h
    │       └─    0.9 ms - platforms/shared/trig8.h
    └─    3.2 ms - crgb.hpp
fl/ui.h (121.0ms)
  ├─   75.8 ms - fl/stl/json.h
  │ └─   58.7 ms - fl/stl/json/types.h
  │   └─    7.4 ms - fl/stl/limits.h
  ├─   10.2 ms - fl/ui_impl.h
  │ └─    9.6 ms - platforms/ui_defs.h
  │   ├─    2.1 ms - platforms/shared/ui/json/audio.h
  │   │ └─    1.0 ms - platforms/shared/ui/json/audio_internal.h
  │   ├─    1.7 ms - platforms/shared/ui/json/button.h
  │   │ └─    0.6 ms - platforms/shared/ui/json/ui_internal.h
  │   ├─    0.9 ms - platforms/shared/ui/json/dropdown.h
  │   ├─    0.9 ms - platforms/shared/ui/json/help.h
  │   └─    0.9 ms - platforms/shared/ui/json/checkbox.h
  └─    9.6 ms - fl/asset.h
    └─    8.5 ms - fl/stl/url.h
platforms/is_platform.h (28.7ms)
  └─   28.3 ms - platforms/esp/is_esp.h
    └─   28.2 ms - platforms/esp/esp_version.h

TOP 20 SLOWEST OPERATIONS
--------------------------------------------------------------------------------
  1.  1478.4 ms - Source: FastLED.h
  2.  1478.4 ms - Total Source: 
  3.   700.2 ms - Source: fl/task/executor.h
  4.   652.6 ms - Total ParseClass: 
  5.   508.2 ms - Source: fl/fastled.h
  6.   369.3 ms - Source: fl/task/scheduler.h
  7.   359.8 ms - Source: fl/stl/singleton.h
  8.   359.1 ms - Source: fl/stl/thread_local.h
  9.   358.0 ms - Source: fl/stl/thread.h
 10.   357.9 ms - Source: platforms/thread.h
 11.   357.8 ms - Source: platforms/stub/thread_stub.h
 12.   357.8 ms - Source: platforms/stub/thread_stub_stl.h
 13.   350.6 ms - Source: thread
 14.   317.2 ms - Source: fl/task/promise.h
 15.   315.2 ms - Source: crgb.h
 16.   313.9 ms - Source: fl/gfx/crgb.h
 17.   309.0 ms - Source: fl/math/ease.h
 18.   306.6 ms - Source: fl/math/fixed_point.h
 19.   268.0 ms - Source: fl/stl/function.h
 20.   219.8 ms - Total InstantiateFunction: 

PERFORMANCE FLAGS
--------------------------------------------------------------------------------
⚠️  SLOW HEADERS (>50.0ms):
    - FastLED.h (1478.4ms)
    - fl/task/executor.h (700.2ms)
    - fl/fastled.h (508.2ms)
    - fl/task/scheduler.h (369.3ms)
    - fl/stl/singleton.h (359.8ms)
    - fl/stl/thread_local.h (359.1ms)
    - fl/stl/thread.h (358.0ms)
    - platforms/thread.h (357.9ms)
    - platforms/stub/thread_stub.h (357.8ms)
    - platforms/stub/thread_stub_stl.h (357.8ms)

⚠️  Template instantiation time is high (30.5% of total)
✓  Lexing time is acceptable (<10% of total)

RECOMMENDATIONS
--------------------------------------------------------------------------------
1. Consider optimizing FastLED.h (1478.4ms)
2. Consider optimizing fl/task/executor.h (700.2ms)
3. Consider optimizing fl/fastled.h (508.2ms)

================================================================================

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