Strange Rendering Issues - Slider Rendered Twice

With a sample Kotlin Native program the UI is rendered using the Linux Frame Buffer backend on a Raspberry Pi 4 via a Touchscreen, however the Slider appears twice which is weird. Only one Slider (shown in the middle of the display) is defined in the program. The actual Slider is truncated but is rendered properly when it is touched, yet the second Slider still appears (truncated) at the bottom of the display.


Please take a photo about the issue.

Initial Touchscreen State

Touchscreen After Touching Slider

Looks like the issues have been resolved. The wrong data type (CPointer<ByteVar>?) was used for the private buffers (primaryBufPtr and secondaryBufPtr) in the DisplayDrawBuffer class. The data type has been changed to the correct one (CPointer<lv_color_t>?):

// ...
public actual class DisplayDrawBuffer private constructor(
    ptr: CPointer<lv_disp_draw_buf_t>?,
    bufSize: UInt,
    dblBuffer: Boolean
): Closable {
    private val arena = Arena()
    private val primaryBufPtr: CPointer<lv_color_t>? =
        if (ptr == null) arena.allocArray(bufSize.toInt()) else null
    private val secondaryBufPtr: CPointer<lv_color_t>? =
        if (ptr == null && dblBuffer) arena.allocArray(bufSize.toInt()) else null
    public val lvDispDrawBufPtr: CPointer<lv_disp_draw_buf_t> = ptr ?: createDrawBuffer(bufSize).ptr

    private fun createDrawBuffer(bufSize: UInt): lv_disp_draw_buf_t {
        val result = arena.alloc<lv_disp_draw_buf_t>()
        lv_disp_draw_buf_init(draw_buf = result.ptr, buf1 = primaryBufPtr, buf2 = secondaryBufPtr,
            size_in_px_cnt = bufSize)
        return result

    public actual companion object {
        public actual fun create(bufSize: UInt, dblBuffer: Boolean): DisplayDrawBuffer =
            DisplayDrawBuffer(bufSize = bufSize, dblBuffer = dblBuffer, ptr = null)

        public fun fromPointer(ptr: CPointer<lv_disp_draw_buf_t>?): DisplayDrawBuffer =
            DisplayDrawBuffer(ptr = ptr, bufSize = 0u, dblBuffer = false)

    override fun close() {
        if (primaryBufPtr != null) arena.clear()
// ...

Huh, it’s great that you have found the issue. I had no idea :slightly_smiling_face: