(Possibly) LVGL in WebAssembly with Zig Compiler

Zig Compiler works great for compiling C Libraries into WebAssembly. Can we preview an LVGL App in the Web Browser… With WebAssembly and Zig Compiler?

Let’s find out! In this article we’ll…

  1. Run a Zig LVGL App on PinePhone (with Apache NuttX RTOS)

  2. Explain how Zig works with WebAssembly (and C Libraries)

  3. Compile LVGL Library from C to WebAssembly (with Zig Compiler)

  4. Test it with our LVGL App (in Zig)

  5. Render Simple LVGL UIs (in Web Browser)

  6. Later we might render LVGL UI Controls (with Touch Input)

Check out the article…

(Possibly) LVGL in WebAssembly with Zig Compiler

2 Likes

Very nice! :clap: :clap: :clap:

Do you know how the performance of Zig compares to C?

1 Like

Thanks Gabor! :slight_smile: If we’re talking about Zig Compiler compiling LVGL Library from C to WebAssembly: The performance is probably the same as Clang Compiler, since Zig Compiler calls Clang.

If we’re comparing Zig Code with C Code: Zig has slightly extra overheads because of Runtime Safety Checks. But the checks can be turned off:

https://ziglang.org/documentation/master/#Undefined-Behavior

I meant the “normal” Zig and C to binary case. Thank you for te link.

Anyway, if we keep the rendering in C, a Zig binding shouldn’t be too slow.

1 Like