Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Sidebar divider keeps jumping back and forth after a drag is released, then the UI freezes

Open blsz opened this issue 1 week ago • 3 comments

Markpad version

2.9.2

How did you install it?

Windows — installer (Markpad_…_setup.exe)

OS and version

Windows 10 Pro 22H2 (build 19045.6466), WebView2 158.0.4370.33, Radeon RX 580, two 2560×1440 monitors

What happens, and what you expected instead

I drag the divider between the left file-tree sidebar and the document, then release it. Instead of staying where I dropped it, the divider keeps jumping back and forth for a minute or more, and then the whole UI freezes.

The attached clip shows the jumping phase. The divider moves between a handful of fixed positions, about 150 px apart, several times a second. It keeps returning to the same positions rather than drifting.

I expected the divider to stay where I released it.

This has happened twice. I haven't found what triggers it: most drags behave normally.

Steps to reproduce

  1. Open a folder so that the file tree is shown in the left sidebar.
  2. Drag the divider between the sidebar and the document, and release it.
  3. Occasionally, the divider keeps moving on its own after the release, and the UI freezes after a minute or more.

The Markdown that triggers it


Screenshots, and anything else

https://github.com/user-attachments/assets/403186f1-c474-45ec-84fc-490875296575

A guess, in case it helps: in Sidebar.svelte the width only changes from the pointermove listener that drag() adds and then removes on pointerup. That suggests the jumping is a backlog of queued drag events being replayed after the release, perhaps because each width change re-lays out the preview. That would also explain why the positions repeat.

Possibly related: #1047 (freeze while resizing the window, AppImage).

Thanks for Markpad — I use it a lot.


Drafted with Claude Code. The cause guess comes from reading Sidebar.svelte at 61aee3c, not from debugging.

blsz avatar Nov 26 '26 03:11 blsz

Thanks for the clip, the repeating positions were the key clue.

It isn't leftover drag events. The app stops listening to the mouse as soon as you release the divider. The likely cause is two Markpad windows handing each other older sidebar widths. Each window tells the others when a setting changes. When those notices arrive late, a window applies a width that is already out of date and passes it back, the other window does the same, and they keep cycling through the same few positions.

A fix is up in #1108.

One question: did you have a second Markpad window open when this happened, for example on your other monitor? If there was only one window, this fix may not cover it and we'll keep looking.

The technical side — you can skip this
  • drag() removes its pointermove listener on pointerup, so nothing replays after the release.
  • Every window listens for the browser's storage event and applied event.newValue. A drag writes the width every frame, so a late event carries a width that's already been overwritten. The window applied it, its compare-and-set saw a difference and wrote it back, which sent a storage event to the dragging window, which did the same. That loop has no end.
  • #1108 applies the value stored now (localStorage.getItem) instead of the one the event carries, so a late event changes nothing and isn't written back.
  • Not reproduced in the app. The test checks the handler logic only, not two real WebView2 windows.

PathGao avatar Nov 27 '26 05:11 PathGao

I think I had at least 2 Markpad windows open both times that this happened.

blsz avatar Nov 27 '26 05:11 blsz

Thanks, that matches what we found. The fix is merged and will ship in the next release. If you still see the divider jump with it, please reopen this.

PathGao avatar Nov 27 '26 05:11 PathGao