Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for python adapters when compiling with emscripten #95

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

JeanChristopheMorinPerso
Copy link
Member

@JeanChristopheMorinPerso JeanChristopheMorinPerso commented Dec 6, 2024

Fixes #60

This is still WIP. It works but we still need to tweak some things and make the experience smoother.

As a proof, see the video below that shows an AAF being loaded in the browser:

Screenshare.-.2024-12-05.9_49_12.PM.mp4

I'm basically creating this PR (and marking as a draft) for visibility and so that my work doesn't get lost in my fork.

@@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
<title>Raven</title>
<script src="https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js"></script>
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm getting pyodide from a CDN, but we should probably look at other options.

const micropip = pyodide.pyimport("micropip");
await micropip.install(
[
'https://jcmorin.dev/otio-wasm/opentimelineio-0.18.0.dev1-cp312-cp312-pyodide_2024_0_wasm32.whl',
Copy link
Member Author

Choose a reason for hiding this comment

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

We should move this out of there I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

The tricky thing is that we can't upload wasm32 wheels to PyPI. So we'll have to find a place to host it.

// ... And free it when we're done.
_free(stringOnWasmHeap);
}
if (element_event.target.files[0].name.endsWith('.aaf')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe otioz too? What other formats are in binary?

Copy link
Member

Choose a reason for hiding this comment

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

AAF and OTIOZ are binary, the rest are all text.

var stringOnWasmHeap = _malloc(lengthBytes);
stringToUTF8(timeline_json, stringOnWasmHeap, lengthBytes);

Module.ccall("js_LoadString", "number", ["number"], [stringOnWasmHeap]);
Copy link
Member Author

Choose a reason for hiding this comment

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

We should not call this for otioz (which raven supports natively)

Choose a reason for hiding this comment

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

Does it support OTIOZ when running in WASM? If so, how well does it handle the memory mapping situation? We may end up wanting to go down the route of the new File System API (Chromium support ✅, but no Safari/Firefox I'm pretty sure), so that it doesn't have to read the whole thing into memory directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have not tried, but I don't see why it wouldn't work.

I took a quick look at the new shiny file system API stuff but didn't go deep enough to understand the pros and cons memory wise. Do you have a link that would talk more exactly that?

Choose a reason for hiding this comment

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

https://developer.chrome.com/docs/capabilities/web-apis/file-system-access

Give this a quick glance. I don't really know this translates into WASM but my thinking was really just that we could just access the file in-situ without passing it all the way into the WASM-mapped 2GB/4GB memory this way. I just figure that with an OTIOZ when there's actually media, you'll hit the limit pretty much immediately.

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.

Add support for adapters
3 participants