c2pa-js icon indicating copy to clipboard operation
c2pa-js copied to clipboard

Find better solution for web worker thread pooling

Open dkozma opened this issue 3 years ago • 2 comments

We initially made the release using threads.js, however we wound up in a scenario where the workers could initially lock and cause the first processImage call to never complete, possibly due to https://github.com/andywer/threads.js/issues/254. Due to this, we switched over to workerpool, which seems to be simpler in its pooling implementation, however doesn't include support for Transferable objects, which can speed up data transfer of large files pretty significantly over structured cloning.

We have three options that initially come to mind:

  • See if we can update the SDK to use wasm-bindgen-rayon on the Rust side instead
    • This has the advantage of allowing us to more granularly parallelizing the Rust functions since we would be doing it in the Rust SDK integration layer
    • We need to make sure we make this available to browsers without WebAssembly thread support.
  • Build in our own lightweight thread pooling logic (especially since we don't need Node.js support...I think)
    • This has the advantage of not using any crazy Webpack eval hacks or Node.js requires that we don't need
    • This will also allow us to bring our library size down due to removing non-browser code
  • See if we can help add Transferable objects to workerpool: https://github.com/josdejong/workerpool/issues/3
    • This has the advantage of being tested by the community, as well as helping out another implementation

dkozma avatar Jun 06 '22 16:06 dkozma

@adobe export issue to Jira project CAI

crandmck avatar Jan 23 '23 19:01 crandmck

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/CAI-3380 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Jan 23 '23 19:01 github-jira-sync-bot