desktop-shell: Weston crash when user click the parent window while the child window is fading out
Dear Weston experts,
Recently we found a problem when testing an app running on Weston desktop-shell. The basic scenario is, when we click a button on the parent window, it would pop-up a child window. We can click the close button to close this child window, and it would disappear with a fade-out animation by default. However, if we click the parent window at the same time when the child window is fading out, Weston would crash with error 'weston: ../graphics/weston/desktop-shell/shell.c:3755: activate: Assertion 'shsurf' failed.'
After some analysis I think I found the root cause. So, in current code logic, when the 'close' button is clicked by user, the weston_desktop_surface_destroy
would be called instantly, which marked the linked weston_surface not to be a desktop surface anymore by setting surface->surface->committed = NULL
. However, the shell_surface of this child window won't be destroyed until the fade-out animation is done (desktop_shell_destroy_surface
would only be called in fade_out_done_idle_cb
). Thus, when the child window is actually fading out but the user clicked the main window and triggered an activate()
call, it would still detect the child window, but would fail at assert(shsurf)
in the recursive call of activate()
(because the weston_surface is not a desktop surface anymore).
Currently I have two thoughts to solve this issue:
1, If we have something (e.g. a flag as a member in struct shell_surface) which indicates the animation is running, we can add this condition in https://gitlab.freedesktop.org/wayland/weston/-/blob/main/desktop-shell/shell.c#L3367 so that the recursive activate()
won't be triggered in this case. By this way, we could start to activate the parent window as soon as the child window is closed by user, not need to wait until the animation finished.
2, We can just replace the assert(shsurf)
by if(!shsurf) return;
instead. By this way, the code change is very simple, but if user wants to do operation on the parent window, he/she needs to wait until the animation is done.
What do you think? Which one is the better solution to you, or if this issue has already been solved in the latest code? (I'm not sure since we're using Weston-10.0.0 locally).
Please help give some advices, thanks in advance.