cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.31k stars 71 forks source link

table select slow #892

Closed ddkwork closed 4 months ago

ddkwork commented 4 months ago

Describe the bug

The line rendering speed of the table can't keep up with the speed of the mouse machine, and there is a delay, which is more serious than this in the real scene, because the demo is delayed for 1 second to simulate user operations, we can change the time size of the delay to test it, and generally the delay feels obvious after adding 10 lines

How to reproduce

screenshots

Example code

// Command async demonstrates async updating in Cogent Core.
package main

import (
    "time"

    "cogentcore.org/core/events"
    "cogentcore.org/core/gi"
    "cogentcore.org/core/giv"
    "cogentcore.org/core/icons"
)

type tableStruct struct {
    Icon       icons.Icon
    IntField   int
    FloatField float32
    StrField   string
    File       gi.Filename
}

const rows = 100000

func main() {
    table := make([]*tableStruct, 0, rows)
    b := gi.NewBody("Async Updating")
    tv := giv.NewTableView(b)
    tv.SetReadOnly(true)
    tv.SetSlice(&table)

    b.OnShow(func(e events.Event) {
        go func() {
            for i := 0; i < rows; i++ {
                updt := b.UpdateStartAsync()
                table = append(table, &tableStruct{IntField: i, FloatField: float32(i) / 10.0})
                tv.UpdateWidgets()
                if len(table) > 0 {
                    tv.ScrollToIdx(len(table) - 1)
                }
                b.UpdateEndAsyncLayout(updt)
                //time.Sleep(1 * time.Millisecond)
                time.Sleep(1 * time.Second)
            }
        }()
    })

    b.RunMainWindow()
}

Relevant output

see title

Platform

Windows

ddkwork commented 4 months ago

I don't feel like it's a mutex repelling it

kkoreilly commented 4 months ago

I can reproduce this issue: the cause of the issue is not that the table selection is "slow", but that there is a bug that causes table selection via widgets to not work for scrolled table views. I will work on fixing this bug today.

ddkwork commented 4 months ago

I can reproduce this issue: the cause of the issue is not that the table selection is "slow", but that there is a bug that causes table selection via widgets to not work for scrolled table views. I will work on fixing this bug today.

It's a perfect fix!