Skip to content

Thread Performance Checker warning during signing #30

Description

@nebooz

Environment

  • C2PA iOS SDK Version: 0.0.7
  • iOS Version: 18.2
  • Device: iPhone (physical device)
  • Xcode: Latest

What's happening

We're using the SDK to sign photos in our app and it's working well, but we're seeing this warning from Xcode's Thread Performance Checker every time we call builder.sign():

Thread Performance Checker: Thread running at User-initiated quality-of-service class
waiting on a lower QoS thread running at Default quality-of-service class.
Investigate ways to avoid priority inversions

Code

We run the signing on a background thread with .userInitiated priority to keep the UI responsive:

Task.detached(priority: .userInitiated) {
    let signer = try Signer(
        certsPEM: certificatePEM,
        privateKeyPEM: privateKeyPEM,
        algorithm: .ps256,
        tsaURL: "http://timestamp.digicert.com"
    )

    let builder = try Builder(manifestJSON: manifestJSON)
    let sourceStream = try Stream(fileURL: inputURL, truncate: false)
    let destStream = try Stream(fileURL: outputURL, truncate: true)

    try builder.sign(
        format: "image/jpeg",
        source: sourceStream,
        destination: destStream,
        signer: signer
    )
}

The warning appears even though we're explicitly running this on a background thread - it's coming from inside the SDK's internal operations.

Backtrace

0   std::thread::Thread::park
1   std::sync::mpmc::list::Channel::recv
2   std::sync::mpmc::list::Channel::recv::{{closure}}
3   c2pa::utils::hash_utils::hash_by_alg
4   c2pa::claim::Claim::calc_assertion_box_hash
5   c2pa::claim::Claim::add_assertion_with_salt
6   c2pa::builder::Builder::to_claim
7   c2pa::builder::Builder::to_store
8   c2pa::builder::Builder::sign
9   c2pa_builder_sign (FFI bridge)
10  C2PA.Builder.sign (Swift wrapper)

Looks like it's happening in the internal hashing code (frames 3-4). The signing works fine and completes in about 1.5 seconds, but thought you'd want to know about this warning.

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions