Skip to content

fix: gate AVIF/WebP C dependencies behind feature flags to fix WASM env import error#138

Merged
nao1215 merged 1 commit intomainfrom
fix/wasm-env-import-and-tests
Mar 13, 2026
Merged

fix: gate AVIF/WebP C dependencies behind feature flags to fix WASM env import error#138
nao1215 merged 1 commit intomainfrom
fix/wasm-env-import-and-tests

Conversation

@nao1215
Copy link
Owner

@nao1215 nao1215 commented Mar 13, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added AVIF image format encoding and decoding support
    • AVIF format option dynamically enables or disables based on build capabilities
  • Style

    • Added favicon to web interface

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be44a3cf-9484-47be-8e03-3762eb63ecd0

📥 Commits

Reviewing files that changed from the base of the PR and between 3a1ff71 and b4cb6d0.

📒 Files selected for processing (9)
  • .github/workflows/pages.yml
  • Cargo.toml
  • scripts/build-wasm-demo.sh
  • src/adapters/wasm.rs
  • src/codecs/raster.rs
  • src/codecs/svg.rs
  • src/core.rs
  • web/app.js
  • web/index.html
💤 Files with no reviewable changes (1)
  • .github/workflows/pages.yml

📝 Walkthrough

Walkthrough

The PR removes WASI SDK setup from the GitHub Actions CI/CD pipeline while adding AVIF image format as an optional, feature-gated capability. Changes span dependency configuration, codec implementations for AVIF encode/decode, and web UI integration for capability detection and user interaction.

Changes

Cohort / File(s) Summary
CI/CD WASI SDK Removal
.github/workflows/pages.yml, scripts/build-wasm-demo.sh
Removed wasi-sdk installation step and associated environment variable configuration; removed webp-lossy from wasm build features.
AVIF Feature Configuration
Cargo.toml
Added avif as a default feature; made rav1d-safe, mp4parse, and yuvutils-rs optional dependencies linked to the avif feature; removed avif from image crate features.
AVIF Codec Implementation
src/codecs/raster.rs, src/codecs/svg.rs
Introduced AVIF decode/encode paths with YUV-to-RGBA conversion and metadata handling, all gated by the avif feature flag; updated error handling for capability-missing scenarios.
AVIF Capability Detection
src/adapters/wasm.rs, src/core.rs
Added avif field to WasmCapabilities struct populated via cfg!(feature = "avif"); expanded tests for AVIF dimension/alpha detection and cross-format transformations; added helper for AVIF-encoded bytes.
Web UI AVIF Support
web/app.js, web/index.html
Integrated AVIF capability detection in format selector and validation logic; disabled AVIF option when unsupported; updated capability display and status messaging; added favicon data URL SVG.

Sequence Diagram

sequenceDiagram
    participant Web as Web UI
    participant Adapter as WASM Adapter
    participant Codec as Codec Layer
    participant AVIF as AVIF Encoder/Decoder

    Web->>Adapter: Load image (check capabilities)
    Adapter->>Adapter: Detect AVIF feature flag
    Adapter->>Web: Return capabilities (avif: true/false)
    
    alt AVIF supported
        Web->>Codec: Request AVIF decode/encode
        Codec->>AVIF: Process AVIF (YUV→RGBA, quality)
        AVIF->>Codec: Return transformed image
        Codec->>Web: Image data
    else AVIF not supported
        Web->>Codec: Request AVIF operation
        Codec->>Web: CapabilityMissing error
        Web->>Web: Fallback to default format
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A rabbit's hop through formats new,
AVIF arrives, so sleek and true,
While WASI fades like morning dew,
Feature gates keep builds lean—
Best support you've ever seen!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the main change: gating AVIF/WebP C dependencies behind feature flags to resolve a WASM environment import error. It accurately summarizes the core objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/wasm-env-import-and-tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@nao1215 nao1215 merged commit 43606ef into main Mar 13, 2026
17 checks passed
@nao1215 nao1215 deleted the fix/wasm-env-import-and-tests branch March 13, 2026 12:50
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