fyne-io / fyne

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

Crash in accordion #3966

Open matwachich opened 1 year ago

matwachich commented 1 year ago

Checklist

Describe the bug

Accordion may crash, I thought initially that this is related to having many items, but when trying to reproduce with simple code it seems it is not.

It is related to slow items appending.

How to reproduce

Run the code Click the button, this will start populating the accordion, with a small timer of 10 milliseconds between items

Screenshots

No response

Example code

package main

import (
    "fmt"
    "time"

    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
    "github.com/brianvoe/gofakeit/v6"
)

func main() {
    a := app.New()
    w := a.NewWindow("")

    acc := widget.NewAccordion()

    w.SetContent(container.NewBorder(
        widget.NewButton("Populate", func() {
            for i := 1; i <= 100; i++ {
                acc.Append(widget.NewAccordionItem(
                    fmt.Sprintf("Random item %03d", i),
                    widget.NewLabel(gofakeit.Paragraph(1, 3, 5, "\n\n")),
                ))
                time.Sleep(10 * time.Millisecond)
            }
        }),
        nil, nil, nil,
        acc,
    ))
    w.ShowAndRun()
}

Fyne version

2.3.5

Go compiler version

1.20.4

Operating system and version

Windows 10

Additional Information

Stack trace

panic: runtime error: index out of range [3] with length 3

goroutine 1 [running, locked to thread]:
fyne.io/fyne/v2/widget.(*accordionRenderer).MinSize(0xc0000c00f0)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/widget/accordion.go:154 +0x188
fyne.io/fyne/v2/widget.(*BaseWidget).MinSize(0xc0000c6180?)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/widget/widget.go:91 +0x2e
fyne.io/fyne/v2/widget.(*Accordion).MinSize(0xc0000c6180)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/widget/accordion.go:65 +0x34
fyne.io/fyne/v2/layout.(*borderLayout).MinSize(0xc00034f8c0, {0xc000060540?, 0x2, 0xc000054000?})
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/layout/borderlayout.go:74 +0x182
fyne.io/fyne/v2.(*Container).MinSize(0xc0006a9d48?)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/container.go:90 +0x5e
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).MinSize(0xc00050a120)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/canvas.go:72 +0x9f
fyne.io/fyne/v2/internal/driver/glfw.(*window).minSizeOnScreen(0xc0003acb40)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:47 +0x25
fyne.io/fyne/v2/internal/driver/glfw.(*window).fitContent(0xc0003acb40)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window_desktop.go:220 +0x66
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).runGL(0xc0000a2380)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/loop.go:166 +0x430
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).Run(0xc0000a2380)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/driver.go:169 +0x75
fyne.io/fyne/v2/internal/driver/glfw.(*window).ShowAndRun(0xc0003acb40)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:230 +0x2c
main.main()
        C:/Users/Matwachich/Documents/Programmation/tests/accordion_crash/main.go:32 +0x1c5
exit status **2**
matwachich commented 1 year ago

It is like Items are populated before Headers... image

matwachich commented 1 year ago

Perhaps related crash in develop (2.3.6 20230618081107-)

"sync: RUnlock of unlocked RWMutex"
Stack:
     1  0x00007ff73070b0de in sync.fatal
         at C:/Program Files/Go/src/runtime/panic.go:1031
     2  0x00007ff73072549d in sync.(*RWMutex).rUnlockSlow
         at C:/Program Files/Go/src/sync/rwmutex.go:129
     3  0x00007ff730725407 in sync.(*RWMutex).RUnlock
         at C:/Program Files/Go/src/sync/rwmutex.go:119
     4  0x00007ff7312b63cb in fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize.func2
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:95
     7  0x00007ff7310eded2 in fyne.io/fyne/v2/widget.(*accordionRenderer).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/accordion.go:154
     8  0x00007ff73113bde2 in fyne.io/fyne/v2/widget.(*BaseWidget).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/widget.go:91
     9  0x00007ff7310ed2b6 in fyne.io/fyne/v2/widget.(*Accordion).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/accordion.go:65
    10  0x00007ff73152c7c5 in main.(*wPatientSummary).MinSize
         at <autogenerated>:1
    11  0x00007ff730dc0a4b in fyne.io/fyne/v2/internal/widget.(*Scroll).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/widget/scroller.go:426
    12  0x00007ff7311677a4 in fyne.io/fyne/v2/container.(*baseTabsRenderer).minSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/tabs.go:388
    13  0x00007ff73115d99a in fyne.io/fyne/v2/container.(*appTabsRenderer).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/apptabs.go:304
    14  0x00007ff73113bde2 in fyne.io/fyne/v2/widget.(*BaseWidget).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/widget.go:91
    15  0x00007ff73115ccf6 in fyne.io/fyne/v2/container.(*AppTabs).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/apptabs.go:142
    16  0x00007ff730db76e7 in fyne.io/fyne/v2/layout.(*borderLayout).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/layout/borderlayout.go:79
    17  0x00007ff730cbedf2 in fyne.io/fyne/v2.(*Container).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container.go:90
    18  0x00007ff731163a76 in fyne.io/fyne/v2/container.(*splitContainerRenderer).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/split.go:133
    19  0x00007ff73113bde2 in fyne.io/fyne/v2/widget.(*BaseWidget).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/widget.go:91
    20  0x00007ff73116c5e5 in fyne.io/fyne/v2/container.(*Split).MinSize
         at <autogenerated>:1
    21  0x00007ff7311640c8 in fyne.io/fyne/v2/container.(*splitContainerRenderer).minTrailingWidth
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/split.go:200
    22  0x00007ff7311636a7 in fyne.io/fyne/v2/container.(*splitContainerRenderer).Layout
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/split.go:98
    23  0x00007ff731163ca5 in fyne.io/fyne/v2/container.(*splitContainerRenderer).Refresh
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/split.go:153
    24  0x00007ff73113c1e9 in fyne.io/fyne/v2/widget.(*BaseWidget).Refresh
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/widget.go:139
    25  0x00007ff73116c7ae in fyne.io/fyne/v2/container.(*Split).Refresh
         at <autogenerated>:1
    26  0x00007ff73113c2a6 in fyne.io/fyne/v2/widget.(*BaseWidget).setFieldsAndRefresh
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/widget.go:153
    27  0x00007ff73113c026 in fyne.io/fyne/v2/widget.(*BaseWidget).Show
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/widget/widget.go:109
    28  0x00007ff73116c8ae in fyne.io/fyne/v2/container.(*Split).Show
         at <autogenerated>:1
    29  0x00007ff7311672e7 in fyne.io/fyne/v2/container.(*baseTabsRenderer).layout
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/tabs.go:360
    30  0x00007ff731160425 in fyne.io/fyne/v2/container.(*docTabsRenderer).Layout
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/container/doctabs.go:247
    31  0x00007ff7312b99aa in fyne.io/fyne/v2/internal/driver/common.(*Canvas).updateLayout
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:602
    32  0x00007ff7312b6328 in fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:132
    33  0x00007ff7312b8bb7 in fyne.io/fyne/v2/internal/driver/common.(*Canvas).walkTree.func2
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:514
    34  0x00007ff73115434d in fyne.io/fyne/v2/internal/driver.walkObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/util.go:197
    35  0x00007ff731153bc5 in fyne.io/fyne/v2/internal/driver.WalkVisibleObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/util.go:134
    36  0x00007ff7312b8a0b in fyne.io/fyne/v2/internal/driver/common.(*Canvas).walkTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:520
    37  0x00007ff7312b81fb in fyne.io/fyne/v2/internal/driver/common.(*Canvas).WalkTrees
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:432
    38  0x00007ff7312b5db6 in fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/common/canvas.go:137
    39  0x00007ff7312e9525 in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/glfw/loop.go:199
    40  0x00007ff7312f63b9 in fyne.io/fyne/v2/internal/driver/glfw.(*window).RunWithContext
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/glfw/window.go:904
    41  0x00007ff7312e94b2 in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/glfw/loop.go:198
    42  0x00007ff7312e8b3b in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).drawSingleFrame
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/glfw/loop.go:106
    43  0x00007ff7312e994f in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.3.6-0.20230618081107-a984816deecd/internal/driver/glfw/loop.go:254

The same line is involved in the crash (see screenshot), but the actual crash happens elsewhere (in RWMutex) image

matwachich commented 1 year ago

This bug stills the same in develop 05/08/2023. When looking at the code of Accordion, I noticed something: image

MinSize calls CreateRenderer and not updateObjects. It is updateObjects that kind of "syncs" Headers slice with Items slice. Could this be the cause of the crash?

pseidemann commented 1 year ago

hi, could https://github.com/fyne-io/fyne/issues/4009 be a similar bug?

matwachich commented 1 year ago

Perhaps yes, there definitly something not working well in accordion and tabs. The crash stills in v2.3.6-0.20230812072749-e63d4e8030ef

glenvan commented 1 year ago

I don't know the cause of this crash, but I stumbled onto the reason for the sync: RUnlock of unlocked RWMutex. I was messing around with TextGrid (misusing it, really) and caused a panic due to an out-of-bounds index in widget.textGridRenderer.Layout().

This is probably my fault, not a bug. I'm not complaining about it.

However what happens if you panic there is as the stack starts to unwind, you pass through the call to renderer.Layout() in common.Contour.updateLayout(), leaving the common.Canvas object's mutex unlocked. After that you unwind through common.Contour.EnsureMinSize() which has a deferred call to common.Canvas.RUnlock(), causing a second panic, and masking the original panic in the stack trace.

There's a lot of that going on in common.Canvas: the mutex unlocking just long enough to do something that acquires a new lock, then re-lock it. If there's a panic in the middle of that procedure you run into issues with double-unlocking.

It might be better to wrap these unlock/relock code sections in a closure

... which guarantees a good unwind.

andydotxyz commented 1 year ago

Adopting that style would be a lot more code, and harder to read IMHO. If you try to figure out all the places that it could panic and adjust accordingly you're going to be fighting a losing battle. Considering our aim is that Fyne should never panic during app runtime it seems like wasted effort...

matwachich commented 1 year ago

The crash stills in v2.4.1-0.20231002192343-df6e0297c26d It's been a loong time I did not encounter it, totally forgot it! I think I will change the Accordion for a list widget... util the crash is resolved

"sync: RUnlock of unlocked RWMutex"
Stack:
     1  0x00007ff6b4b5b25e in sync.fatal
         at C:/Users/Matwachich/sdk/go1.20.7/src/runtime/panic.go:1031
     2  0x00007ff6b4b7543d in sync.(*RWMutex).rUnlockSlow
         at C:/Users/Matwachich/sdk/go1.20.7/src/sync/rwmutex.go:129
     3  0x00007ff6b4b753a7 in sync.(*RWMutex).RUnlock
         at C:/Users/Matwachich/sdk/go1.20.7/src/sync/rwmutex.go:119
     4  0x00007ff6b58163eb in fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize.func2
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/common/canvas.go:95
     7  0x00007ff6b554ec4f in fyne.io/fyne/v2/widget.(*accordionRenderer).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/widget/accordion.go:175
     8  0x00007ff6b55a1182 in fyne.io/fyne/v2/widget.(*BaseWidget).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/widget/widget.go:92
     9  0x00007ff6b554deb6 in fyne.io/fyne/v2/widget.(*Accordion).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/widget/accordion.go:65
    10  0x00007ff6b520ee2b in fyne.io/fyne/v2/internal/widget.(*Scroll).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/widget/scroller.go:426
    11  0x00007ff6b5211b2c in fyne.io/fyne/v2/internal/widget.(*SimpleRenderer).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/widget/simple_renderer.go:46
    12  0x00007ff6b55a1182 in fyne.io/fyne/v2/widget.(*BaseWidget).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/widget/widget.go:92
    13  0x00007ff6b5a03ac5 in main.(*wPatientSummary).MinSize
         at <autogenerated>:1
    14  0x00007ff6b55cc7e4 in fyne.io/fyne/v2/container.(*baseTabsRenderer).minSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/container/tabs.go:390
    15  0x00007ff6b55c2a9a in fyne.io/fyne/v2/container.(*appTabsRenderer).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/container/apptabs.go:307
    16  0x00007ff6b55a1182 in fyne.io/fyne/v2/widget.(*BaseWidget).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/widget/widget.go:92
    17  0x00007ff6b55c1df6 in fyne.io/fyne/v2/container.(*AppTabs).MinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/container/apptabs.go:142
    18  0x00007ff6b5816002 in fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/common/canvas.go:119
    19  0x00007ff6b5818bd7 in fyne.io/fyne/v2/internal/driver/common.(*Canvas).walkTree.func2
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/common/canvas.go:520
    20  0x00007ff6b55b8e4d in fyne.io/fyne/v2/internal/driver.walkObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:199
    21  0x00007ff6b55b90cb in fyne.io/fyne/v2/internal/driver.walkObjectTree.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:178
    22  0x00007ff6b55b8ddd in fyne.io/fyne/v2/internal/driver.walkObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:192
    23  0x00007ff6b55b90cb in fyne.io/fyne/v2/internal/driver.walkObjectTree.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:178
    24  0x00007ff6b55b8ddd in fyne.io/fyne/v2/internal/driver.walkObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:192
    25  0x00007ff6b55b90cb in fyne.io/fyne/v2/internal/driver.walkObjectTree.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:178
    26  0x00007ff6b55b8ddd in fyne.io/fyne/v2/internal/driver.walkObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:192
    27  0x00007ff6b55b90cb in fyne.io/fyne/v2/internal/driver.walkObjectTree.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:178
    28  0x00007ff6b55b8ddd in fyne.io/fyne/v2/internal/driver.walkObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:192
    29  0x00007ff6b55b8685 in fyne.io/fyne/v2/internal/driver.WalkVisibleObjectTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/util.go:134
    30  0x00007ff6b5818a2b in fyne.io/fyne/v2/internal/driver/common.(*Canvas).walkTree
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/common/canvas.go:526
    31  0x00007ff6b581821b in fyne.io/fyne/v2/internal/driver/common.(*Canvas).WalkTrees
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/common/canvas.go:438
    32  0x00007ff6b5815c76 in fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/common/canvas.go:143
    33  0x00007ff6b584935b in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/glfw/loop.go:192
    34  0x00007ff6b5856539 in fyne.io/fyne/v2/internal/driver/glfw.(*window).RunWithContext
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/glfw/window.go:924
    35  0x00007ff6b58492f2 in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/glfw/loop.go:191
    36  0x00007ff6b584881b in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).drawSingleFrame
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/glfw/loop.go:88
    37  0x00007ff6b584974f in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread.func1
         at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/v2@v2.4.1-0.20231002192343-df6e0297c26d/internal/driver/glfw/loop.go:245
pseidemann commented 1 year ago

Adopting that style would be a lot more code, and harder to read IMHO. If you try to figure out all the places that it could panic and adjust accordingly you're going to be fighting a losing battle. Considering our aim is that Fyne should never panic during app runtime it seems like wasted effort...

I'm not sure this is a good approach for an important project like a gui library.

one of go's proverbs is "don't panic": https://go-proverbs.github.io which I think is a good thing.

1vanKa commented 9 months ago

Hello, I'm not using Accordion, but I have the same error. It takes some hours to occur, but fyne always crashes.

fatal error: sync: RUnlock of unlocked RWMutex
fatal error: sync: RUnlock of unlocked RWMutex

goroutine 6 [running, locked to thread]:
sync.fatal({0x7ff607b7ef1b?, 0xc0005d7700?})
    C:/Program Files/Go/src/runtime/panic.go:1031 +0x1e
sync.(*RWMutex).rUnlockSlow(0xc0000c2cdc, 0x0?)
    C:/Program Files/Go/src/sync/rwmutex.go:129 +0x39
sync.(*RWMutex).RUnlock(0x7ff6073eee06?)
    C:/Program Files/Go/src/sync/rwmutex.go:119 +0x29
fyne.io/fyne/v2/canvas.(*baseObject).MinSize(0x3f8000003f800000?)
    D:/Projects/Golang/weather-board-server/external/fyne/canvas/base.go:40 +0xca
fyne.io/fyne/v2/layout.(*maxLayout).MinSize(0x7ff60743ce01?, {0xc000d86160?, 0x2, 0x7ff607442d06?})
    D:/Projects/Golang/weather-board-server/external/fyne/layout/maxlayout.go:36 +0xa4
fyne.io/fyne/v2.(*Container).MinSize(0xc00036ccf0?)
    D:/Projects/Golang/weather-board-server/external/fyne/container.go:89 +0x5e
fyne.io/fyne/v2/layout.(*boxLayout).MinSize(0xc00036ccf0, {0xc000da6200?, 0x7, 0x7ff607442cd4?})
    D:/Projects/Golang/weather-board-server/external/fyne/layout/boxlayout.go:141 +0x176
fyne.io/fyne/v2.(*Container).MinSize(0xc00036ccf1?)
    D:/Projects/Golang/weather-board-server/external/fyne/container.go:89 +0x5e
fyne.io/fyne/v2/layout.(*boxLayout).MinSize(0xc00036ccf1, {0xc00037e4d0?, 0x7, 0x7ff6074449f1?})
    D:/Projects/Golang/weather-board-server/external/fyne/layout/boxlayout.go:134 +0xea
fyne.io/fyne/v2.(*Container).MinSize(0x7ff607c7db80?)
    D:/Projects/Golang/weather-board-server/external/fyne/container.go:89 +0x5e
fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize.func1(0xc0000b4100)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/common/canvas.go:79 +0xb8
fyne.io/fyne/v2/internal/driver/common.(*Canvas).walkTree.func2({0x7ff607c7db80?, 0xc00006aaa0?}, {0xc00006aa00?, 0x7ff607c7db80?})
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/common/canvas.go:453 +0xa8
fyne.io/fyne/v2/internal/driver.walkObjectTree({0x7ff607c7db80, 0xc00006aaf0}, 0x0, {0x7ff607c7db80, 0xc00006a960}, {0x743cea2?, 0x7ff6?}, {0xda6200?, 0xc0?}, {0x7?, ...}, ...)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/util.go:197 +0x42d
fyne.io/fyne/v2/internal/driver.walkObjectTree.func1(...)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/util.go:176
fyne.io/fyne/v2/internal/driver.walkObjectTree({0x7ff607c7db80, 0xc00006a960}, 0x0, {0x0, 0x0}, {0x7?, 0x0?}, {0x5d7c08?, 0xc0?}, {0x76add46?, ...}, ...)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/util.go:190 +0x3ec
fyne.io/fyne/v2/internal/driver.WalkVisibleObjectTree({0x7ff607c7db80?, 0xc00006a960?}, 0x7ff607c7b058?, 0xc0000c2000?)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/util.go:134 +0x4c
fyne.io/fyne/v2/internal/driver/common.(*Canvas).walkTree(0x7ff607699f44?, 0xc000d860e0, 0x0, 0xc0005d7d78)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/common/canvas.go:459 +0x165
fyne.io/fyne/v2/internal/driver/common.(*Canvas).WalkTrees(0xc00012b200, 0xc0005d7dc8?, 0x7ff6076880e5?)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/common/canvas.go:371 +0x3c
fyne.io/fyne/v2/internal/driver/common.(*Canvas).EnsureMinSize(0xc00012b200)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/common/canvas.go:102 +0xe5
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow.func1()
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/glfw/loop.go:199 +0x35
fyne.io/fyne/v2/internal/driver/glfw.(*window).RunWithContext(0xc0000ae000?, 0xc0005d7e30)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/glfw/window.go:907 +0x4f
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow(0xc0005d7e98?, 0xc0005ce820?)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/glfw/loop.go:198 +0x4a
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).drawSingleFrame(0xc0005d7f90?)
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/glfw/loop.go:106 +0x1ac
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread.func1()
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/glfw/loop.go:254 +0x1a6
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread
    D:/Projects/Golang/weather-board-server/external/fyne/internal/driver/glfw/loop.go:230 +0xea

...

goroutine 11372 [running]:
sync.fatal({0x7ff607b7ef1b?, 0xffffffffffffffff?})
    C:/Program Files/Go/src/runtime/panic.go:1031 +0x1e
sync.(*RWMutex).rUnlockSlow(0xc0000c2cdc, 0x7140a36?)
    C:/Program Files/Go/src/sync/rwmutex.go:129 +0x39
sync.(*RWMutex).RUnlock(0xc000d2bd00?)
    C:/Program Files/Go/src/sync/rwmutex.go:119 +0x29
fyne.io/fyne/v2/canvas.(*baseObject).Size(0x0?)
    D:/Projects/Golang/weather-board-server/external/fyne/canvas/base.go:91 +0xb0
fyne.io/fyne/v2/canvas.(*Rectangle).Resize(0xc0000c2cc0, {0xd2bd20?, 0xc0?})
    D:/Projects/Golang/weather-board-server/external/fyne/canvas/rectangle.go:29 +0x30
fyne.io/fyne/v2/layout.(*maxLayout).Layout(0x31313a3931203630?, {0xc000d86160?, 0x2, 0x0?}, {0x0?, 0x10000?})
    D:/Projects/Golang/weather-board-server/external/fyne/layout/maxlayout.go:22 +0x53
fyne.io/fyne/v2.(*Container).layout(...)
    D:/Projects/Golang/weather-board-server/external/fyne/container.go:193
fyne.io/fyne/v2.(*Container).Refresh(0xc000b625a0)
    D:/Projects/Golang/weather-board-server/external/fyne/container.go:112 +0x48
weather-board-server/internal/ui.(*ColoredMaxLabel).SetBackgroundColor(0xc000b5d740, {0x7ff607c77f00, 0xc0006fe978})
    D:/Projects/Golang/weather-board-server/internal/ui/custom-label.go:69 +0x125
weather-board-server/internal/ui.(*WeatherBoardControlWindow).Write(0xc000414000, {0xc000660000, 0x2b, 0x2000})
    D:/Projects/Golang/weather-board-server/internal/ui/mainwindow.go:95 +0x2e7
weather-board-server/pkg/connection.WriteDecorator.func1({0xc000660000?, 0xc0000a4180?, 0x0?})
    D:/Projects/Golang/weather-board-server/pkg/connection/connection-manager.go:107 +0x26
created by weather-board-server/pkg/connection.(*ConnectionManager).ReadToWrites
    D:/Projects/Golang/weather-board-server/pkg/connection/connection-manager.go:83 +0x265
Eusebius commented 9 months ago

I'm observing similar double-unlock crashes when (I think) a Table is being resized/refreshed while its cells are being updated.

andydotxyz commented 9 months ago

I'm observing similar double-unlock crashes when (I think) a Table is being resized/refreshed while its cells are being updated.

It seems unlikely that this is the same issue, probably a good idea to open a new issue