So I'm working on this app which currently are written natively for the web, android and ios. This app does some heavy lifting in the background which we are looking for ways to improve, but keeping three sources of basically the same code sucks.
One way is to make a library in C++ which is then used in the apps and through WebAssembly on the web. This however requires us to generate new versions of the android/apps and publish them to their respective stores.
But then I thought that WebAssembly might be usable on all platforms. But since we still want to offer a native experience on the mobile platforms I'm thinking that a WebView could be used to with a javascript interface to communicate with the library in WebAssembly and present the data natively. Updates to the library would only have to be done once and all apps always has the latest version of the library.
Would this be possible and would it still offer high performance? Would the webview and javascript interface be bottlenecks?
From what I understand you have a native Web App (HTML + JavaScript) and native Android (Java or Kotlin) and iOS (Swift or Objective-C) apps. The app does some heavy lifting that has performance issues - I am guessing that these issues only arise in the web (i.e. JavaScript) version of the app? You want to improve the performance of this code, and also share it across all three platforms?
If that is the case, I think WebAssembly is worth considering. You can create a library in C++ which is run natively in iOS and Android, and compiled to WebAssembly via EmScripten to run on the web.
One things to bear in mind is that WebAssembly has no built-in IO. Therefore all interactions with your code would have to cross the JavaScript / WebAssembly boundary, which does incur a penalty. Therefore, this approach works best for algorithms that have a simple interface, e.g. they might perform a lot of calculations on a small amount of data, then return the result.
I am not sure why you are considering running this in a WebView? For iOS and Android you will not need to use WebAssembly - you can run the C++ code natively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With