Troubleshooting
Start with the first error. A missing compiler, unavailable widget constructor and frozen interface need different fixes; later errors often follow from the same cause.
Identify the playground error stage
The playground reports errors at the stage that failed. Browser mode checks supported syntax, evaluates the app, validates the view and renders it. Local compiler mode also provides rustc diagnostics.
Compiler diagnostics and UI validation errors describe different contracts.
- 01Rust compilation
rustcSyntax, types, imports and feature-gated APIs.
- 02Descriptor validation
Ui::mount / updateDuplicate keys, invalid properties and values.
- 03Native creation and drawing
LVGL / snapshotNative allocation or rendering failures.
A valid Rust program can still describe an invalid UI. Fix the reported stage, then render the current source again.
Fix the first reported error and run again. Compiler source spans identify Rust source locations; a view-validation failure describes the invalid tree and may not have a source span. For mouse, keyboard or animation behavior in a running application, use the SDL examples.
Toolchain and bindgen
The build compiles C and generates bindings in one pass. A missing C compiler
fails during compilation. A missing or unloadable libclang fails when bindgen
loads it, before header parsing: the common panic is Unable to find libclang,
followed by a clang-sys message that lists the searched shared libraries and
points to LIBCLANG_PATH. The Unable to generate LVGL 9.6 bindings message is
the build script's wrapper for a bindgen generate() error after libclang has
loaded, such as a header or clang-argument failure. Do not expect that wrapper
text when the library cannot be found.
- Install a C toolchain plus libclang. Debian and Ubuntu use
build-essential,clangandlibclang-dev; macOS uses the Xcode Command Line Tools. - If libclang is installed outside the default loader path, point bindgen at it
with
LIBCLANG_PATH. This variable belongs to bindgen, not tors_lvgl_sys. - The Lottie extension also needs a C++14 compiler and runtime. Install
g++on Linux or use the platform C++ toolchain. - A cross build needs a target C compiler and its sysroot as well as host
libclang. Set
CC_<target>andAR_<target>for cc-rs (replace dashes in the target name with underscores).LVGL_SYSROOTonly appends<value>/includeto the bindgen clang arguments; it is not validated and is not passed to the C compiler, so configure the compiler's sysroot separately.
A successful host build does not verify the target compiler, target sysroot headers or target ABI.
Configuration paths
Only these three inputs are validated as absolute existing paths before compilation. The message names the input:
A stale shell variable wins over [env] unless Cargo uses force = true.
Inspect OUT_DIR/conf/lv_conf.h to see which header the build actually used,
and check the include line written there for the selected path.
LVGL_CFLAGS and LVGL_SYSROOT do not pass through this path validation. A
wrong LVGL_SYSROOT usually appears as missing target standard headers in the
bindgen diagnostics.
Capability conflicts
When an application header is authoritative, requested Cargo features must exist in its effective macros. The build stops with:
Enable the macro in the header, or remove the Cargo feature that requests it.
Do not disable validation or edit generated bindings. The same check covers
fonts (LV_FONT_MONTSERRAT_28), extensions and LV_USE_SDL.
Native dependencies must be valid in the same header. For widget-slider, enable
LV_USE_SLIDER and LV_USE_BAR; for widget-keyboard, enable
LV_USE_KEYBOARD, LV_USE_BUTTONMATRIX and LV_USE_TEXTAREA. The default
feature path closes these dependencies automatically; an application header does
not.
If a typed API disappears, for example Rust reports a missing Slider type in
widgets, the effective configuration disabled the widget or the feature was not
selected. The C library can still compile a dependency that another widget
requested; the typed wrapper exists only with that feature.
For rs_lvgl_ui, keep the core object, label and button classes, Montserrat 14,
and each selected UI capability. A header that removes them is not a valid UI
configuration even if the raw build succeeds.
Wrapper compilation after disabling Flex/Grid
In 0.6.0, the sys build emits DEP_LVGL_LAYOUTS from the effective target configuration. Handwritten Flex/Grid wrappers follow that metadata independently, so disabling a layout removes its corresponding Rust API. A missing layout method is expected when that layout is disabled.
Check the resolved crate version, application lv_conf.h and normal/build dependency features together. Run python3 scripts/check-layout-config.py --locked from the library checkout to validate the four layout combinations. rs_lvgl_ui uses Flex/Grid and requires its supported layout configuration. See native checks.
SDL failures
The sdl feature requires SDL2 discovery at build time. Without it the build
panics with a message that names the missing dependency and suggests the package
names. Install SDL2 and pkg-config, then confirm:
The fallback probe uses sdl2-config. On macOS, the linker may need the library
directory explicitly:
Two configuration mismatches are reported separately:
- A header that enables
LV_USE_SDLwithout the Cargosdlfeature fails withLVGL_CONFIG_PATH enables LV_USE_SDL; also enable the sdl Cargo feature for native linking. - The
sdlfeature with a header that leavesLV_USE_SDLoff fails the capability check.
The simulator uses LVGL's SDL backend, not the Rust sdl2 crate. A working Rust
sdl2 dependency is neither required nor does it show that the native backend
is configured correctly.
Missing symbols
A declaration in LVGL_EXTRA_HEADERS only makes a function visible to Rust. The
implementation must be compiled from LVGL_EXTRA_C_DIR (or the application's
native build). A linker error such as
undefined reference to application_value, or Undefined symbols for architecture arm64 on macOS, means the declaration and the implementation were not linked
together.
- Place
.cimplementations under the extra source directory. The scan is recursive and also watches added or removed files. - Add generated font sources there as well; a declared
application_fontneeds its defining translation unit. - The extra directory compiles
.conly. Application C++ sources need separate build integration; Lottie's bundled ThorVG is compiled by the crate itself. - A raw use of
lv_font_montserrat_28without enablingLV_FONT_MONTSERRAT_28in the effective header produces an undefined symbol. Enable the font in the header or select the matching feature. - Do not add a second LVGL library to satisfy missing symbols. This provider is vendored; an external prebuilt LVGL has no verified ABI and can duplicate symbols or mix configurations.
For C++ link failures, confirm the target C++ runtime and standard library are available to the final link, not only to the C compiler.
Fonts
rs_lvgl_ui::Font::montserrat_14() is unconditional. Every other
Font::montserrat_<size> exists only for a selected font-montserrat-<size>
feature. A missing method is a feature-selection error; adding a raw symbol
reference does not create the Rust method. Without font-montserrat-28, the UI
themes use Montserrat 14 for titles.
rs_lvgl::font::Font is a separate type: it wraps an lv_font_t value through
new_raw, and its built-in helpers require the nightly feature.
CJK text needs font-cjk-14 or font-cjk-16 and the matching
Font::cjk_14() or Font::cjk_16(). Montserrat does not contain those glyphs,
and a missing glyph renders as a fallback or blank.
A custom font links but renders blank or malformed text when its descriptor is
incomplete. Font::from_raw does not validate it:
- Use a complete LVGL 9.6 descriptor generated by the matching font converter.
- Keep the glyph tables and callbacks static and alive for every object that uses the font. LVGL stores the pointer in styles.
- Compile the generated
.cfile underLVGL_EXTRA_C_DIRand declare the symbol inLVGL_EXTRA_HEADERS. - Include the built-in symbol glyphs if the UI uses
rs_lvgl_ui::symbol; custom fonts do not inherit them.
Do not manufacture a descriptor at runtime and cast it to lv_font_t. The host
tests link a font symbol and inspect its line_height; they do not show that
glyphs render.
Rendering does not advance
LVGL advances timers, animations and input processing only when the platform supplies time and dispatch:
- Feed the tick. Call
rs_lvgl::tick_incwith theDurationelapsed since the previous call, read from a monotonic clock. A periodic source passes its known interval; a variable loop passes each measured duration, so a long frame does not lose time.tick_incforwards whole milliseconds. Alternatively enablerust_timerand callrs_lvgl::timer::update_clockwithLvClock::since_initreturning monotonic elapsed time; it installslv_tick_set_cb, andlv_tick_getthen reads that callback instead of the increments. Use one source. - Dispatch timers. Call
rs_lvgl::task_handler()orUi::timer_handler().Ui::timer_handleris a thin wrapper overlv_timer_handler. - Apply queued messages. Native callbacks enqueue only;
Ui::drainrunsApp::updateand reconciles. A loop that callstimer_handlerwithoutdrainleaves the UI unchanged. - Advance custom widgets.
Ui::tick(elapsed_ms)walks lifecycle custom widgets; pass the same measured milliseconds used for the tick.lv_timer_handlerdoes not call theirupdatehook.
Ui::drain returns early when no message was processed and nothing marked the
UI dirty. State read outside messages (a clock or sensor in App::view) needs
Ui::mark_dirty() or Ui::update(&app). The returned DrainStats reports
whether reconciliation happened and how many messages were dropped.
Reentrant calls are rejected. A nested Ui::timer_handler returns 0, and
other reentrant Ui calls return UiError::Reentrant. C callbacks must not call
Ui methods, block, panic or delete native objects. A panic in an extern "C"
callback aborts the process.
Display flush and format
Display::register renders RGB888. Its buffer capacity must cover at least one
aligned display row, and the callback receives only the active area pixels. A
capacity of zero, an invalid dimension or a buffer smaller than the aligned row
returns DisplayError::FailedToRegister; increase N or use a full-frame
buffer.
Display::register_raw follows the configured format. Its callback must:
- honor the actual color format, area and stride, including row padding;
- copy or transfer only the valid region;
- call
lv_display_flush_readyafter the transfer, including on error paths that keep the display alive; - not unwind or block indefinitely.
The safe constructor calls lv_display_flush_ready after its Rust callback
returns. A long-running callback still stalls the UI thread. For asynchronous
transfers, do not reuse the buffer until the flush is reported ready.
If SDL closes its window inside timer_handler, the native display can be
deleted during dispatch. Check lv_display_get_default() before draining queued
updates and stop the loop when it is null. The examples use this guard before
touching UI handles.
Teardown and aliases
Dropping a Display handle does not delete the native display, and it is not a
teardown step. Display does not implement Drop; its buffer, flush callback,
screen and aliases remain alive until the native display is deleted.
Display::delete(self) and rs_lvgl::deinit are unsafe. Their safety
conditions are the prerequisites below, not a recipe that makes the calls safe:
- Stop rendering, asynchronous draws, DMA or GPU work and pending flushes.
- For a mounted typed UI, call
Ui::unmount()to remove its tree and input bindings, then destroy input-device handles so their native devices are deleted. - Ensure no screen, widget, animation, callback or other display alias can be used afterwards.
Deleting a display while an alias or mounted tree remains is a use-after-free,
not a recoverable error. Do not silence it with mem::forget on UI handles:
the native objects are still freed. For the same reason, do not call
rs_lvgl::deinit() while any LVGL handle or callback can still run. Completing
the steps does not prove that the conditions hold; do not call either operation
when aliases, callbacks or pending transfers cannot be ruled out.
lv_init resets the native tick callback. rust_timer::update_clock registers
it again on every update, which covers deinitialization and a new initialization
cycle. A cached external registration flag does not.
Custom memory must use a matching allocator. With lvgl_alloc, Rust allocations
come from LVGL; releasing them through another allocator, or releasing LVGL
objects through Rust's allocator, breaks the heap. With the default CLIB
allocator, LVGL's heap monitor does not observe libc allocations.
Rebuild and environment confusion
The build watches the active configuration, application headers and their
includes, the extra source directory, extra headers and relevant environment
variables. A configuration change should rebuild rs_lvgl_sys and the dependent
wrapper generation.
- Confirm which header is active by reading
OUT_DIR/conf/lv_conf.h. Its first line includes the selected application header when one is configured. - Check that the process environment does not override
.cargo/config.toml. - Compare builds only when they use the same
CARGO_TARGET_DIR; separate target directories hold separate generated configurations. - A header generated under
OUT_DIRis deliberately not watched as a new input; changing its generator still rebuilds it. - If a stale build is suspected, inspect the watched inputs before forcing a
rebuild. A blanket
cargo cleandiscards diagnostics and hides a missing watch rule.
Diagnostic checks
The build-script tests cover configuration patching, capability validation and RISC-V ABI selection. The native runner covers custom configuration, C sources, fonts, path failures, cache reuse, interrupted compilation, output isolation and an unpacked crate. These checks run on the host. Board display, hardware tick, input delivery, DMA teardown and external-provider ABI need separate verification on the target or hardware.
Inspect UI remotely
Debug with EmbedScope explains opt-in diagnostics, object/display inspection, and removing diagnostic endpoints from production builds.