Skip to content

reader.fromBlob is very slow on some PNG files (3+ seconds) #93

@cesrahimi

Description

@cesrahimi

Update: Added Nano Banana 2 image and updated the timings

Description

Reading C2PA manifests from some PNG files using reader.fromBlob is significantly slower than other formats (e.g., JPEG). Processing a single AI-generated PNG (from Nano Banana 2 and Microsoft Designer) takes 8+ seconds in the browser, which is not acceptable for interactive use cases.

Steps to Reproduce

  1. Use createC2pa() to initialize the SDK
  2. Obtain a C2PA-signed PNG file (e.g., generated by Microsoft Designer with AI content credentials)
  3. Call reader.fromBlob("image/png", file) followed by reader.manifestStore()
  4. Observe that the total read time exceeds 3 seconds

Minimal Code

import { createC2pa } from "@contentauth/c2pa-web";

const sdk = await createC2pa({
  wasmSrc: new URL("@contentauth/c2pa-web/resources/c2pa.wasm", import.meta.url).href,
});

const reader = await sdk.reader.fromBlob(file.type, file); // slow for AI-Generated PNG files
const manifestStore = await reader.manifestStore();
await reader.free();

Expected Behavior

Manifest reading for a PNG file should complete in a comparable timeframe to JPEG files (under 1 second for typical file sizes).

Actual Behavior

PNG files take 3+ seconds to process. JPEG files of similar size are noticeably faster.

Environment

  • @contentauth/c2pa-web: 0.6.1
  • Browser: Microsoft Edge Version 145.0.3800.97 (Official build) (64-bit)
  • OS: Windows 11
  • PNG sources:
    • Nano Banana 2 (AI-generated image)
    • Microsoft Designer (AI-generated image)

Additional Context

The same PNG files are parsed by c2patool CLI v0.26.36 in under 300ms, making the web SDK roughly 25x slower for this case. This suggests the bottleneck is specific to the WASM/web implementation rather than inherent to PNG manifest parsing.

The slowness is not limited to reading. Using this PNG as an ingredient for manifest writing/signing is also dramatically slower compared to other image types.

Sample files:

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions