fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.13k stars 1.4k forks source link

container.NewScroll(myCheckGroup) issue when the number of check boxes increases #4099

Open FredPont opened 1 year ago

FredPont commented 1 year ago

Checklist

Describe the bug

container.NewScroll(myCheckGroup) can display a small number of checkboxes, for example 100. When this number increases, for example 200, a random bug appears sometime the scroll is displayed sometime not. (see video)

How to reproduce

Use the example code and increase the number of checkboxes in the loop line 19 from 100 to 200 for example. When the number of checkboxes increases you will see a black window. (see video)

Screenshots

bug_fyne_scroll_toy.webm

Example code

package main

import (
    "fmt"

    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/layout"
    "fyne.io/fyne/v2/widget"
)

func main() {
    myApp := app.New()
    myWindow := myApp.NewWindow("Window with Checkboxes in Scroll")

    var myCheckboxLabels []string

    for i := 1; i <= 200; i++ {
        box := fmt.Sprintf("box%d", i)
        myCheckboxLabels = append(myCheckboxLabels, box)
    }

    // Create a CheckGroup widget with the checkbox labels
    myCheckGroup := widget.NewCheckGroup(myCheckboxLabels, func(selected []string) {
        // Handle the checkbox selection change event
    })

    // Create a scrolling container and add the checkboxes to it
    scroller := container.NewScroll(
        container.NewVBox(
            myCheckGroup,
        ),
    )

    // Add the scrolling container to the window
    myWindow.SetContent(
        fyne.NewContainerWithLayout(
            layout.NewGridLayout(1),
            scroller,
        ),
    )

    myWindow.Resize(fyne.NewSize(300, 400))
    myWindow.ShowAndRun()
}

Fyne version

fyne.io/fyne/v2 v2.3.6-0.20230726025429-1646c13c618e

Go compiler version

1.20.6

Operating system and version

system : Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04
Subsystem: Dell TU104GL [Quadro RTX 4000] [1028:12a0] Kernel driver in use: nvidia Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

Additional Information

No response

matwachich commented 1 year ago

Just FYI, it works on Windows 10 with develop v2.3.6-0.20230722221208-8955ea89b1bd

Jacalz commented 1 year ago

@matwachich I'm confused. What does that comment have to do with the issue in question?

matwachich commented 1 year ago

I just saw all the rubish... I think it's because I answered by mail.

I just wanted to say that the code works fine on windows. So it could be a linux related issue.

Jacalz commented 1 year ago

Ah, I see. I would advise against answering over mail on GitHub. It rarely does what you want it to. Will have a look tomorrow and see if I can replicate.

Jacalz commented 1 year ago

@FredPont Are you only seeing this on develop and not the latest stable release? I have no problem using 200 checkboxes here and looking at your video I think it might be a duplicate of https://github.com/fyne-io/fyne/issues/4086.

FredPont commented 1 year ago

@Jacalz I did a test on another computer : EndeavourOS up to date 01:00.0 VGA compatible controller: NVIDIA Corporation GF108 [GeForce GT 630] (rev a1)

With : fyne.io/fyne/v2 v2.3.6-0.20230802221337-a3d63a1ab0cd and 300 checkboxes, I reproduce the bug after 5 attempts

with : fyne.io/fyne/v2 v2.3.5 I do not manage to reproduce the bug after 10 attempts

andydotxyz commented 1 year ago

Looking at the video this does not relate to scroll I don't think - it looks like the UI isn't managing to process that many items. I would highly recommend using List which is designed for handling lots of off-screen data. Your CheckGroup+Scroll is rendering the entirety of a massive UI and putting it behind a scroll bar so it looks small - much less efficient.

andydotxyz commented 1 year ago

But let's come back and see after #4086 fix lands, just to check.