Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random crash in DocTab #3909

Closed
2 tasks done
matwachich opened this issue May 23, 2023 · 11 comments
Closed
2 tasks done

Random crash in DocTab #3909

matwachich opened this issue May 23, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@matwachich
Copy link
Contributor

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

DocTab randomly crashing when selecting an Item

How to reproduce

I have no idea why sometimes it happens, and sometimes no...

Screenshots

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

goroutine 38 [running]:
fyne.io/fyne/v2/container.(*docTabsRenderer).scrollToSelected(0xc0004e01b0?)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/container/doctabs.go:362 +0x189
fyne.io/fyne/v2/container.(*docTabsRenderer).Refresh(0xc0004e01b0)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/container/doctabs.go:267 +0x65 
fyne.io/fyne/v2/widget.(*BaseWidget).Refresh(0x7ff7f51bbf40?)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/widget/widget.go:139 +0x2e     
fyne.io/fyne/v2/container.(*DocTabs).Select(0xc0001160a0, 0xc001ee48e0?)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/container/doctabs.go:144 +0x37
main.(*MainWindow).TabAdd(0x7ff7f5743520, {0x7ff7f51bae60, 0xc0020cf880})
        C:/Users/Matwachich/Documents/Programmation/KissEMR/KissEMR/main_window.go:154 +0x147
main.(*tabHomeSearch).openOrCreatePatient(0xc0005044e0?, {0x93, 0xac, 0xb1, 0x43, 0x6b, 0x59, 0x45, 0xed, 0xb1, ...})
        C:/Users/Matwachich/Documents/Programmation/KissEMR/KissEMR/tab_home.go:237 +0x88
main.newTabHomeSearchListItem.func1()
        C:/Users/Matwachich/Documents/Programmation/KissEMR/KissEMR/tab_home.go:289 +0x5a
main.(*tabHomeSearchListItem).Tapped(0xc003348780, 0xc000448901?)
        C:/Users/Matwachich/Documents/Programmation/KissEMR/KissEMR/tab_home.go:334 +0x42
fyne.io/fyne/v2/internal/driver/glfw.(*window).mouseClickedHandleTapDoubleTap.func1()
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/window.go:634 +0x26
fyne.io/fyne/v2/internal/driver/common.(*Window).RunEventQueue(0x0?)
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/common/window.go:35 +0x3e
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
        C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/window.go:946 +0x136
exit status 2

Example code

I have a complexe code base, I could not reproduce the bug with simple code.

Fyne version

develop v2.3.4-rc1.0.20230516195251-56dd0f3e0f32

Go compiler version

1.20

Operating system and version

Windows 10

Additional Information

No response

@matwachich matwachich added the unverified A bug that has been reported but not verified label May 23, 2023
@matwachich matwachich reopened this Jun 25, 2023
@matwachich
Copy link
Contributor Author

Re-opening this because I encountered it again in develop (v2.3.6-0.20230618081107-a984816deecd)

"runtime error: index out of range [0] with length 0"
Stack:
	 3  0x00007ff7a1bdc734 in fyne.io/fyne/v2/container.(*docTabsRenderer).scrollToSelected
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/container/doctabs.go:362
	 4  0x00007ff7a1bdb5d1 in fyne.io/fyne/v2/container.(*docTabsRenderer).Refresh
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/container/doctabs.go:267
	 5  0x00007ff7a1bb79c9 in fyne.io/fyne/v2/widget.(*BaseWidget).Refresh
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/widget/widget.go:139
	 6  0x00007ff7a1bdab85 in fyne.io/fyne/v2/container.(*DocTabs).Remove
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/container/doctabs.go:132
	 7  0x00007ff7a1f01308 in main.(*MainWindow).Setup.func16.1
	     at c:/Users/Matwachich/Documents/Programmation/EMR Made Simple/emr-made-simple/src/main_window.go:78
	 8  0x00007ff7a1f11d51 in main.(*TabContentModels).onClose
	     at c:/Users/Matwachich/Documents/Programmation/EMR Made Simple/emr-made-simple/src/tab_content_models.go:148
	 9  0x00007ff7a1f01276 in main.(*MainWindow).Setup.func16
	     at c:/Users/Matwachich/Documents/Programmation/EMR Made Simple/emr-made-simple/src/main_window.go:75
	10  0x00007ff7a1f031a9 in main.(*MainWindow).TabCloseAll
	     at c:/Users/Matwachich/Documents/Programmation/EMR Made Simple/emr-made-simple/src/main_window.go:223
	11  0x00007ff7a1f01c57 in main.(*MainWindow).Logout
	     at c:/Users/Matwachich/Documents/Programmation/EMR Made Simple/emr-made-simple/src/main_window.go:131
	12  0x00007ff7a1fa5beb in main.(*MainWindow).Logout-fm
	     at <autogenerated>:1
	13  0x00007ff7a1b971f5 in fyne.io/fyne/v2/widget.(*menuItem).trigger
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/widget/menu_item.go:205
	14  0x00007ff7a1b96d2d in fyne.io/fyne/v2/widget.(*menuItem).Tapped
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/widget/menu_item.go:151
	15  0x00007ff7a1db2262 in fyne.io/fyne/v2/internal/driver/glfw.(*window).mouseClickedHandleTapDoubleTap.func1
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/window.go:631
	16  0x00007ff7a1d78ed3 in fyne.io/fyne/v2/internal/driver/common.(*Window).RunEventQueue
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/common/window.go:35
	17  0x00007ff7a1db5dcb in fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1.1
	     at C:/Users/Matwachich/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/window.go:943

@matwachich
Copy link
Contributor Author

#4009
Same issue here.
Good that he could reproduce with a simple code.

@andydotxyz
Copy link
Member

I think we are still missing code to reproduce this error?

@andydotxyz
Copy link
Member

I tried removing all and adding new tab but could not cause the crash.
Looking for help understanding how to make this happen.

@matwachich
Copy link
Contributor Author

matwachich commented Sep 3, 2023

I still unable to reproduce with simple code.
I just encountered the crash in 2.4.0, while closing a Tab.

The DocTab was containing 3 tabs, I close one (idx 2), so there remains only 2 tabItems (idx 0 and 1)

The crash happened inside docTab.CloseIntercept, while .Refresh()ing inside docTab.Remove(*container.TabItem).
image

Inside Refresh, first .Layout is called. As I understand, this function is charged (among other tasks) to update the DocTab buttons according to docTab.Items.
image

But something happens in it that prevents it to update buttons.
image

Just after Refresh, the function scrollToSelected is called (because the closed tab was selected).
So here happens the crash because the buttons container contains only 1 button (it should contain 2, because the docTabs has 2 items).
image
image
image


I really hope this will help understand this silly intermittent crash!

@andydotxyz
Copy link
Member

There is an additional interaction (and thread) through your use of OnClosing.
Does it happen if you move the Remove call into the CloseIntercept?

@matwachich
Copy link
Contributor Author

The OnClosing function most of the time does nothing, it is built like this because certain ITab must do cleanup when closed.

The OnClosed method does nearly nothing involving fyne, only database access, sometimes dialog display.
It will call the function passed to it when everything is OK for closing the tab.

In the particular case of the last crash encountered, the OnClosed does strictly nothing other than directly calling the function passed to it.

But I will investigate more in this direction...

@matwachich
Copy link
Contributor Author

Always happening...
Even after code simplification.

Here is the code responsible for managing docTabs in my application: https://pastebin.com/56DWJG2R

By the way, the crash not only happens on tab closing, but also when adding the very first tab at application launch.

@matwachich
Copy link
Contributor Author

Would it be possible to just add a simple check in the begining of docTabsRenderer.scrollToSelected to see if r.docTabs.current is not out of bound of buttons.Objects?
This would temporarly correct this (very rare) crash, at the cost of not scrolling to selected tab

matwachich added a commit to matwachich/fyne that referenced this issue Sep 21, 2023
@matwachich
Copy link
Contributor Author

Something like this?
#4269

andydotxyz pushed a commit that referenced this issue Sep 29, 2023
@andydotxyz andydotxyz added this to the D fixes (v2.4.x) milestone Sep 29, 2023
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Sep 29, 2023
@andydotxyz
Copy link
Member

Landing for release branch

andydotxyz pushed a commit that referenced this issue Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants