#9632: Shutdown/restart sometimes slow/never completes on latest builds ----------------------+---------------------------- Reporter: Kev | Owner: nobody Type: bug | Status: new Priority: normal | Milestone: R1 Component: System | Version: R1/Development Resolution: | Keywords: Blocked By: | Blocking: 9667 Has a Patch: 0 | Platform: x86 ----------------------+---------------------------- Comment (by mmlr): I've debugged this yesterday and the cause for the slow shutdown and Deskbar not quitting (and therefore not saving its settings) is an endless loop in _FindNextValidApp() (as pointed to by the attached screenshot). What happens is that fCurrentIndex and with it [[http://cgit.haiku- os.org/haiku/tree/src/apps/deskbar/Switcher.cpp#n880|startIndex]] becomes -1 when the last application from the list is quit (see [[http://cgit .haiku- os.org/haiku/tree/src/apps/deskbar/Switcher.cpp#n480|B_SOME_APP_QUIT]], which also causes CycleApp() and indirectly _FindNextValidApp() to be called). The value of fCurrentIndex is clamped to 0..max, where max is 0 as well, not finding any further valid apps (as there are none in the list anymore) and never triggering the startIndex (-1) == fCurrentIndex (0) abort condition either => endless loop. Why this happens only now is due to a change in the content of the list. In hrev45422 TBarApp::AddTeam() was modified to not add background apps and the Deskbar itself to the list of BarTeamInfos anymore. This is significant because the subscribers (ExpandoMenuBar and Switcher) now don't get messages for these anymore either. The list of apps in the Switcher is therefore now shorter than before (missing the background apps that would usually be there), making the above situation possible. I haven't found an obvious reason why AddTeam() shouldn't filter out background apps and the Deskbar, as all subscribers seem to filter them out as well (this redundant individual filtering should now be removed though). This is just an explanation for why the situation did not arise previously. The easiest solution would probably be to change _FindNextValidApp() to check for an empty list and return false directly in that case. Note that OKToUse() could now be removed and replaced by simple NULL checks, as the list now only includes non-background and non-Deskbar apps. -- Ticket URL: <http://dev.haiku-os.org/ticket/9632#comment:18> Haiku <http://dev.haiku-os.org> Haiku - the operating system.