-
Notifications
You must be signed in to change notification settings - Fork 23
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
base: main
Are you sure you want to change the base?
Add support for python adapters when compiling with emscripten #95
Conversation
Signed-off-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
@@ -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> |
There was a problem hiding this comment.
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.
shell_minimal.html
Outdated
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', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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')) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…lecting a different file Signed-off-by: Jean-Christophe Morin <[email protected]>
…a loop Signed-off-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
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.