Weston config file getting corrupted

Hello,

We are using weston through a Yocto Dunfell version and have been for a while.
Problem we have on all of our devices is that the following flow is happening:
1 - weston loads correctly from the host system
2 - config file at /etc/xdg/weston/weston.ini is properly read
3 - we start our docker stack (which has weston and kiosk) with the config file mounted
4 - weston restarts and loads correctly along with the kiosk
5 - we notice that the config file has been appended with additional lines of the last part of the config file (dealing with screen share section)
6 - continuing to kill/start up containers or restarting the docker container process will continue to append entries and run successfully until it occasionally appends an improper format, therefor corrupting the config file. After that point, weston will ofc no longer run.

Details below…

Conf file before starting Weston Docker instance:

[core]
idle-time=0
xwayland=true
modules=screen-share.so

[output]
name=DSI-1
transform=rotate-90

[screen-share]
command=/usr/bin/weston --backend=vnc-backend.so --shell=fullscreen-shell.so

Conf file after running Docker Weston instance once:

[core]
idle-time=0
xwayland=true
modules=screen-share.so

[output]
name=DSI-1
transform=rotate-90

[screen-share]
command=/usr/bin/weston --backend=vnc-backend.so --shell=fullscreen-shell.so
[screen-share]
command=/usr/bin/weston --backend=vnc-backend.so --shell=fullscreen-shell.so
[screen-share]
command=/usr/bin/weston --backend=vnc-backend.so --shell=fullscreen-shell.so

Log file entry containing the weston version and loaded modules:

    Date: 2023-02-08 CET
    [14:14:00.102] weston 9.0.0
                   https://wayland.freedesktop.org
                   Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
                   Build: 9.0.0-34-ga1823f20+
    [14:14:00.102] Command line: /usr/bin/weston --modules=xwayland.so --log=/var/log/weston.log
    [14:14:00.103] OS: Linux, 5.4.91-5.2.0-devel-hannah+git.6afb048a71e3, #1 SMP PREEMPT Wed Apr 7 08:36:44 UTC 2021, aarch64
    [14:14:00.107] Using config file '/etc/xdg/weston/weston.ini'
    [14:14:00.108] Output repaint window is 7 ms maximum.
    [14:14:00.110] Loading module '/usr/lib/libweston-9/drm-backend.so'
    [14:14:00.129] initializing drm backend
    [14:14:00.130] logind: failed to get session seat
    [14:14:00.130] logind: cannot setup systemd-logind helper (-61), using legacy fallback
    [14:14:00.138] using /dev/dri/card0
    [14:14:00.138] DRM: supports atomic modesetting
    [14:14:00.138] DRM: does not support GBM modifiers
    [14:14:00.138] DRM: supports picture aspect ratio
    [14:14:00.139] Loading module '/usr/lib/libweston-9/gl-renderer.so'
    [14:14:00.169] EGL client extensions: EGL_EXT_client_extensions
                   EGL_EXT_platform_base EGL_KHR_platform_wayland
                   EGL_EXT_platform_wayland EGL_KHR_platform_gbm
    [14:14:00.177] EGL version: 1.5
    [14:14:00.177] EGL vendor: Vivante Corporation
    [14:14:00.177] EGL client APIs: OpenGL_ES
    [14:14:00.177] EGL extensions: EGL_KHR_fence_sync EGL_KHR_reusable_sync
                   EGL_KHR_wait_sync EGL_KHR_image EGL_KHR_image_base
                   EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image
                   EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image
                   EGL_EXT_image_dma_buf_import
                   EGL_EXT_image_dma_buf_import_modifiers EGL_KHR_lock_surface
                   EGL_KHR_create_context EGL_KHR_no_config_context
                   EGL_KHR_surfaceless_context EGL_KHR_get_all_proc_addresses
                   EGL_EXT_buffer_age EGL_ANDROID_native_fence_sync
                   EGL_WL_bind_wayland_display
                   EGL_WL_create_wayland_buffer_from_image EGL_KHR_partial_update
                   EGL_EXT_swap_buffers_with_damage
                   EGL_KHR_swap_buffers_with_damage EGL_EXT_pixel_format_float
    [14:14:00.177] EGL_KHR_surfaceless_context available
    [14:14:00.216] GL version: OpenGL ES 2.0 V6.4.3.p1.305572
    [14:14:00.216] GLSL version: OpenGL ES GLSL ES 1.0.0
    [14:14:00.216] GL vendor: Vivante Corporation
    [14:14:00.216] GL renderer: Vivante GC7000NanoUltra
    [14:14:00.216] GL extensions: GL_OES_vertex_half_float
                   GL_OES_element_index_uint GL_OES_mapbuffer
                   GL_OES_vertex_array_object GL_OES_compressed_ETC1_RGB8_texture
                   GL_OES_compressed_paletted_texture GL_OES_texture_npot
                   GL_OES_rgb8_rgba8 GL_OES_depth_texture
                   GL_OES_depth_texture_cube_map GL_OES_depth24 GL_OES_depth32
                   GL_OES_packed_depth_stencil GL_OES_fbo_render_mipmap
                   GL_OES_get_program_binary GL_OES_fragment_precision_high
                   GL_OES_standard_derivatives GL_OES_EGL_image
                   GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3
                   GL_OES_EGL_sync GL_OES_required_internalformat
                   GL_OES_surfaceless_context GL_OES_texture_border_clamp
                   GL_EXT_texture_type_2_10_10_10_REV
                   GL_EXT_texture_compression_dxt1 GL_EXT_texture_format_BGRA8888
                   GL_EXT_texture_compression_s3tc GL_EXT_read_format_bgra
                   GL_EXT_multi_draw_arrays GL_EXT_frag_depth
                   GL_EXT_discard_framebuffer GL_EXT_blend_minmax
                   GL_EXT_multisampled_render_to_texture GL_EXT_robustness
                   GL_EXT_texture_sRGB_decode GL_EXT_texture_border_clamp
                   GL_EXT_texture_rg GL_VIV_direct_texture
    [14:14:00.216] GL ES 2 renderer features:
                   read-back format: BGRA
                   wl_shm sub-image to texture: no
                   EGL Wayland extension: yes
    [14:14:00.326] event2  - gpio-keys: is tagged by udev as: Keyboard
    [14:14:00.326] event2  - gpio-keys: device is a keyboard
    [14:14:00.333] event0  - 30370000.snvs:snvs-powerkey: is tagged by udev as: Keyboard
    [14:14:00.333] event0  - 30370000.snvs:snvs-powerkey: device is a keyboard
    [14:14:00.388] libinput: configuring device "gpio-keys".
    [14:14:00.388] libinput: configuring device "30370000.snvs:snvs-powerkey".
    [14:14:00.389] DRM: head 'DSI-1' found, connector 35 is connected, EDID make 'unknown', model 'unknown', serial 'unknown'
    [14:14:00.390] Registered plugin API 'weston_drm_output_api_v1' of size 24
    [14:14:00.399] Chosen EGL config details: id:  41 rgba: 8 8 8 0 buf: 24 dep:  0 stcl: 0 int: 1-60 type: win|pix|pbf|swap_preserved vis_id: XRGB8888 (0x34325258)
    [14:14:00.399] Output DSI-1 (crtc 33) video modes:
                   800x1280@60.0, preferred, current, 67.3 MHz
    [14:14:00.399] associating input device event2 with output DSI-1 (none by udev)
    [14:14:00.399] associating input device event0 with output DSI-1 (none by udev)
    [14:14:00.399] Output 'DSI-1' enabled with head(s) DSI-1
    [14:14:00.399] Compositor capabilities:
                   arbitrary surface rotation: yes
                   screen capture uses y-flip: yes
                   presentation clock: CLOCK_MONOTONIC, id 1
                   presentation clock resolution: 0.000000001 s
    [14:14:00.400] Loading module '/usr/lib/weston/desktop-shell.so'
    [14:14:00.405] launching '/usr/libexec/weston-keyboard'
    [14:14:00.410] Loading module '/usr/lib/weston/screen-share.so'
    [14:14:00.412] Old Xwayland module loading detected: Please use --xwayland command line option or set xwayland=true in the [core] section in weston.ini
    [14:14:00.412] Loading module '/usr/lib/libweston-9/xwayland.so'
    [14:14:00.474] Registered plugin API 'weston_xwayland_v1' of size 32
    [14:14:00.475] Registered plugin API 'weston_xwayland_surface_v1' of size 16
    [14:14:00.475] xserver listening on display :0
    [14:14:00.475] launching '/usr/libexec/weston-desktop-shell'
    [14:14:01.381] event1  - Goodix Capacitive TouchScreen: is tagged by udev as: Keyboard Touchscreen
    [14:14:01.382] event1  - Goodix Capacitive TouchScreen: device is a keyboard
    [14:14:01.383] event1  - Goodix Capacitive TouchScreen: device is a touch device
    [14:14:01.383] Touchscreen - Goodix Capacitive TouchScreen - /sys/devices/platform/soc@0/soc@0:bus@30800000/30a30000.i2c/i2c-1/1-005d/input/input1/event1
    [14:14:01.383] libinput: configuring device "Goodix Capacitive TouchScreen".
    [14:14:01.383] input device event1 has no enabled output associated (none named), skipping calibration for now.
    [14:14:01.384] associating input device event1 with output DSI-1 (none by udev)
    [14:14:07.807] event3  - failed to create input device '/dev/input/event3'
    [14:14:08.008] event3  - failed to create input device '/dev/input/event3'
    [14:14:10.083] event3  - failed to create input device '/dev/input/event3'
    [14:14:10.415] event3  - USB Camera: USB Camera: is tagged by udev as: Keyboard
    [14:14:10.415] event3  - USB Camera: USB Camera: device is a keyboard
    [14:14:10.415] libinput: configuring device "USB Camera: USB Camera".
    [14:14:10.415] associating input device event3 with output DSI-1 (none by udev)
    [14:14:17.184] deactivating session
    [14:14:17.184] event2  - gpio-keys: device removed
    [14:14:17.184] event0  - 30370000.snvs:snvs-powerkey: device removed
    [14:14:17.184] event1  - Goodix Capacitive TouchScreen: device removed
    [14:14:17.184] event3  - USB Camera: USB Camera: device removed

Additionally, how we start weston from the compose file:

services:
  weston:
    image: torizon/weston-vivante:2
    environment:
     - ACCEPT_FSL_EULA=1
     - ENABLE_VNC=1
    ports:
      - 5900:5900
    volumes:
      - type: bind
        source: /etc/xdg/weston/weston.ini
        target: /etc/xdg/weston/weston.ini
      - type: bind
        source: /etc/xdg/weston/weston.ini
        target: /etc/xdg/weston-dev/weston.ini
      - type: bind
        source: /tmp
        target: /tmp
      - type: bind
        source: /dev
        target: /dev
      - type: bind
        source: /run/udev
        target: /run/udev
    cap_add:
      - CAP_SYS_TTY_CONFIG
    device_cgroup_rules:
      - 'c 4:0 rmw'
      - 'c 4:7 rmw'
      - 'c 13:* rmw'
      - 'c 199:* rmw'
      - 'c 226:* rmw'
    command: --developer weston-launch --tty=/dev/tty7 --user=torizon
    healthcheck:
      test: ["CMD", "test", "-S", "/tmp/.X11-unix/X0"]
      interval: 5s
      timeout: 4s
      retries: 6
      start_period: 10s
    restart: always

Host weston service runs as following (weston@root systemd service):

weston@root.service - Weston Wayland Compositor
         Loaded: loaded (/lib/systemd/system/weston@.service; static; vendor preset: disabled)
         Active: active (running) since Wed 2023-02-08 14:13:59 CET; 24min ago
       Main PID: 486 (weston-launch)
          Tasks: 0 (limit: 1608)
         Memory: 972.0K
         CGroup: /system.slice/system-weston.slice/weston@root.service
                 > 486 weston-launch -- --modules=xwayland.so --log=/var/log/weston.log

    Feb 08 14:13:59 verdin-imx8mm systemd[1]: Started Weston Wayland Compositor.

Interestingly, logs also complain about loading xwayland wrong, even tho it is present in the config file:

Old Xwayland module loading detected: Please use --xwayland command line option or set xwayland=true in the [core] section in weston.ini

Any ideas would be great!

Hi @ebrodlic ,

Just to confirm, you’re using TorizonCore, right?

5 - we notice that the config file has been appended with additional lines of the last part of the config file (dealing with screen share section)

I was able to reproduce this with TorizonCore 5.7, and I believe this is an oversight on our Weston initialization script: If ENABLE_VNC or ENABLE_RDP is set to 1 the script always appends these two lines at the end of weston.ini. Usually this wouldn’t matter because weston.ini will be reset if it isn’t bind mounted. It doesn’t take into account the case where it is bind mounted.

I’ll pass this bug internally to the team. Thanks for reporting it!

For now, as a workaround, you can remove ENABLE_VNC=1 from your Compose file and keep the first instance of

[screen-share]
command=/usr/bin/weston --backend=vnc-backend.so --shell=fullscreen-shell.so

in your weston.ini file. This way the duplication issue shouldn’t occur anymore.

As for the ini file being corrupted after enough container restarts, I wasn’t able to reproduce it, though the above workaround should solve this problem as well.

Let me know if this helps you.

Best regards,
Lucas Akira

Thank you for the prompt reply!

Yes that is correct, we have followed the build instructions for torizon core that matches the dunfell version of yocto (current LTS).

Currently we need the ENABLE_VNC=1 flag for our setup so we will keep it. We occasionally reset the config file after a while if it gets corrupted and no longer works.
Alternative is that we dont bind mount the config but rather create our own image with a static version of the config we need (for screen rotation etc).

But in case a fix will be coming soon in a newer version of the image, we will simply wait for that while we solve issues with a workaround as they arrive.

Hope to hear back soon!
Cheers! Edin

Hi @ebrodlic ,

Currently we need the ENABLE_VNC=1 flag for our setup so we will keep it.

I forgot to mention this in my previous response, but you don’t really need this flag if the two lines are in weston.ini; the flag only tells the initialization script to append the screen share lines, so if you already have them in the config file you should have VNC enabled. Sorry if I wasn’t clear.

Alternative is that we dont bind mount the config but rather create our own image with a static version of the config we need (for screen rotation etc).

Yes, that is also an alternative, possibly more suitable for a production image.

Let me know if you have additional questions.

Best regards,
Lucas Akira

Awesome, thanks a lot @lucas_a.tx!

1 Like