SDL init error on Javascript port

Hi,

I have compiled javascript port with emscripten sdk-fastcomp-1.38.31-64bit.
When I try to run it by node(come with emsdk) and calls SDL.init(), an error occurs:

node build/micropython.js

MicroPython v1.9.4-2095-g32e3cc4d5-dirty on 2019-12-24; JS with Emscripten
Type "help()" for more information.
>>> import SDL
>>> SDL.init()
Calling stub instead of sigaction()
Calling stub instead of sigaction()
/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:215
      throw ex;
      ^

ReferenceError: screen is not defined
    at Array.ASM_CONSTS (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:1639:15)
    at _emscripten_asm_const_i (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:1658:26)
    at Array._Emscripten_VideoInit (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:329148:7)
    at _SDL_VideoInit (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:338543:38)
    at _SDL_InitSubSystem (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:338090:12)
    at _SDL_Init (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:348898:8)
    at _monitor_init (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:195302:3)
    at Array._mp_init_SDL (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:195531:2)
    at Array._fun_builtin_0_call (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:35793:38)
    at _mp_call_function_n_kw (/home/yuming/work/lv_micropython_official_javascript/ports/javascript/build/micropython.js:28403:44)

Does anyone have ideas?
Thanks.

@embeddedt - any idea?

What I noticed is that your MicroPython version (v1.9.4) is quite old. Recent JS port is working with v1.11.

If you just want to experience the JS port, you can try: https://sim.littlevgl.com/micropython/ports/javascript/lvgl_editor.html

My build used branch ‘lvgl_javascript’, which branch should I use to build with Micropython v1.11?
Thanks.

I am trying to integrate javascript port into my electron app.

Looking at the MICROPY_VERSION macros on mpconfig.h of lvgl_javascript branch - it’s 1.11:

Are you up to date?

Interesting. Could you tell us more about what you are trying to do?

My version in ‘mpconfig.h’ is 1.11. But the build version is got from ‘py/makeversionhdr.py’, and the generated version is 1.9.4, seems cause of latest v1.9.4 git tag.

We are developing a GUI editor with electron and it will export Micropython script for Lvgl.
We hope we can use the javascript port as the cross-platform simulator.

The version of the JavaScript port in the lvgl_javascript branch is meant for use in the browser and won’t work within Node.js. If you are trying to use Node.js, you will either need to modify the existing port or start from scratch with the original JavaScript port.

@embeddedt Thanks, I will try to use JavaScript port in a new window.