test
Build
mkdir build && cd build
cmake .. \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DWASI_SYSROOT=/usr/bin/wasi-sdk-14.0/share/wasi-sysroot \
-GNinja \
-DRN_SUPPORT
ninja jwst && ninja jwst-rt-wasm-command
Compile wasm file
./jwst -f <bundle.js> --emit-bitcode -o bundle.bc
llc -filetype obj -o bundle.raw.wasm --relocation-model=pic
wasm-ld bundle.wasm build/jwst-rt.ext.wasm ${WASI_SYSROOT}/lib/wasm32-wasi/crt1-command.o ${WASI_SYSROOT}/lib/wasm32-wasi/libc.a -L${WASI_SYSROOT}/lib/wasm32-wasi -lc -m wasm32 -o bundle.link.wasm
Testing Android applications
To test the Android applications, you should prepare an ARM64 mobile phone with Android operating system, with at least API level 24 (Android 7.0), developer mode enabled, and USB debugging enabled (to use ADB). You should also have a React Native development environment set up: Android Studio, Node.JS and Yarn should be installed.
All 3 applications provided already have their JWST support set up. To test the applications, please follow the following procedure:
Install the dependencies of the applications:
yarn
ornpm i
Generate the JS bundle by running in the root folder of the corresponding Android application’s source code:
npx react-native bundle --platform android --dev true --entry-file index.js --bundle-output bundle.js --assets-dest test-assets/`
The entry file might be called index.ts
or index-android.js
instead of index.js
. The generated file is named bundle.js
.
- Compile
bundle.js
usingjwst
. Rename the linked wasm file tojwst-rn.wasm
and it should be placed in/sdcard/Download
.
docker run -v .:/run -w /run --rm -it jwst-wasm-rn bundle.js -O 0
adb shell rm /storage/emulated/0/Download/jwst-rn.module # Remove stale precompiled module
adb push bundle.js.link.wasm /storage/emulated/0/Download/jwst-rn.wasm
The compilation process may take several minutes.
- In android/app/src/main/java/<application-name>/MainApplication.java, there is a field to choose between different executors:
final UsedJavaScriptExecutor usedJavaScriptExecutor = UsedJavaScriptExecutor.JwstWasm;
and grant the application with the permission to access the phone storage.
To measure the startup time, please open the android folder in the application root in Android Studio and follow this procedure:
In Top Menubar > Run > Edit Configurations > Profiling, check Start this recording at startup, CPU Activity and Callstack Sample.
In Top Menubar > Build > Select Build Variant, Select Release for every application.
Initiate Profile with low overhead in the top bar, next to the Run button.
After the application starts, click Stop in the profiling panel. You should see a call graph by now. We recommend that you wait at least 20 seconds after application start to avoid instability in the profiling program.
The startup time is the time between the start of the graph to the first draw before the Rendering thread uses
getFrame
.
Joplin’s application layout is different from the other two. The android app folder lies in packages/app-mobile. Also, because of a bug in JWST, please add the following commandline args while compiling the script, at the end of the arguments: --skip-functions root.94.1.14
.