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

Improve WASM experience for loading an OTIO file #44

Open
austinwitherspoon opened this issue Apr 13, 2024 · 3 comments
Open

Improve WASM experience for loading an OTIO file #44

austinwitherspoon opened this issue Apr 13, 2024 · 3 comments

Comments

@austinwitherspoon
Copy link

Note: I'm not a C++ developer, nor do I have a lot of experience with WASM! Maybe I'm misunderstanding parts of this.

Today I was able to successfully deploy a built WASM version of raven onto one of our web servers. Exciting!

Following the instructions in the README got me a running version of raven, but I spent quite a bit of time trying to figure out how to actually read a file, since the "Open" menu item doesn't do anything in the browser, and I couldn't figure out any way to use javascript to interact with the main window!

I followed a few guides on how to create "files" (in-memory) in emscripten, and these all caused raven to crash completely.

BUT!

What I finally ended up doing was replacing from_json_file(...) with from_json_string(...) in app.cpp. This allowed me to pass in raw json as an argument to the emscripten app, and get the timeline loaded in the browser!


Anyway, after all of that I had two thoughts:

  1. I don't know how emscripten works, but can we expose a function like from_json_string() to javascript? This way people can write their own javascript code to handle finding and reading OTIO files.
  2. Could we add an argument into the main CLI app to do handle passing in raw json, instead of a file path?
  3. Documenting the WASM stuff better would be lovely, especially for people like me who have no idea what they're doing!
@meshula
Copy link
Member

meshula commented Apr 14, 2024

I wonder if the right thing to do is to write a browser specific main? Passing json from the command line in general sounds like trouble. I'm wondering if what you actually need is to be able to pass a URL to main, rather than raw json data? You would then use a FETCH command to get the data as a string and pass it to from_json_string. So basically, add a new command line switch like --url https://some/path/to.otio.

@jminor
Copy link
Member

jminor commented Apr 15, 2024

Yes, you're right that the WASM build of raven needs some work. There's an easy-to-miss note about "Needs file open/save dialog" in the README and some links to possible paths forward. If I recall correctly I attempted one of those but ran into some roadblocks, but I bet a fresh attempt could make one of those work.

The suggestions you both made about ways to feed OTIO JSON into the WASM are all great. Depending on the use case any/all of these could be useful.

@jminor
Copy link
Member

jminor commented Apr 15, 2024

Here's my attempt from back in Feb 2023: main...web-file-open

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

No branches or pull requests

3 participants