-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New SITL "TARGET": Webassembly (Experimental) #11282
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
base: maintenance-10.x
Are you sure you want to change the base?
Conversation
Merge 9.x to master
…into Webassembly
|
For my wasm build that runs in a browser / PWA, I used two different options to avoid a proxy. Option 1: Option 2: |
Good idea, but it's not that simple, because the INAV main loop runs in a separate thread (web worker) and has to be synchronised, hence the queue and encapsulation in ‘serial_ex’ and only the configurator would have access to it.
The problem: You need a Websocket server and a client. Both the configurator and the SITL run in the browser, but a Websocket server in the browser is not possible. |
|
I might be misreading your comment. |
|
Just show me :). |
|
The simulators are native code, they can't run in the browser. No matter what anyone does with SITL, native code is absolutely required to run the sim. I don't see any big benefit of running SITL slowly in the browser while running a sim. So IMHO they aren't really relevant here. Configurator can run in the browser, so for me, that's the use case for SITL in the browser. To run with Configurator. Which has been working for well for about six weeks. Running SITL in the browser with a native code proxy for web sockets, with a native code sim, gets you 50X slower communication and what else? On other words: Option 2 What's the benefit to adding a browser on top of the native code? If you're going to run SITL_proxy.exe, why not run SITL.exe instead and skip the whole browser and web sockets and all of that entirely? |
|
Yes, you're right, the simulator interface is a nice gimmick, but more of an academic one. |
|
Fyi I'm working on organizing my work into something I can actually show to someone else. |
Yes, INAV in the Browser!
Intended to use with INAV-Configurator Web (PWA) iNavFlight/inav-configurator#2448
It works, inkl. TCP "UARTS" and Simulators, but due to limitations of the browser envoronment/emscripten some workarounds are mandatory:
Only a WebSocket client can run in the browser (no TCP/UDP), so a ‘serial_ex’ interface has been implemented for UART1. Emulates a serial connection via simple function calls.
Other UARTS and simulator interfaces require a locally running proxy that converts the WebSocket into a ‘real’ TCP/UDP socket.
I will integrate a proxy server into the X-Plane XITL plugin so that at least for X-Plane, the whole thing should be easy to use.
-A few more tricks and pull-ups are necessary (e.g. Config) because the emscripten API does not provide all the functions we need.
I'm marking the whole thing as experimental, as the communication Webassembly -> Proxy -> Application is a bit ‘backwards’ and runs a bit shakily.
The alternative would be to rewrite the entire network code (UART and Sims) and switch completely to Websockets, but it's probably not worth it.