Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Markpad cannot recover from unprocessable file

Open eboth opened this issue 4 months ago • 6 comments

The bug I have opened a 30k MD file with one table in it. Markpad choked on it: The computer slowed down to the point of being unusable, and the Markpad window did not appear (even on clicking the taskbar symbol). Not nice, but perhaps the MD was invalid. However, on subsequent starts, Markpad continued to show the same behavior, even after removing the entire AppData\Local\com.alecdotdev.markpad\EBWebView directory. The app has basically become unusable after opening one offending file.

Expected behavior It would be great if Markpad could somehow detect MD files that it cannot process. Failing that, there should be a way to recover after such an error: Wipe history, open without old tabs, etc.

Device

  • OS: Windows 11
  • App Version 2.6.11.0

Additional context I can provide the MD file privately.

eboth avatar Jul 08 '26 11:07 eboth

Half of this is fixed, half isn't.

Recovery is fixed (#260, in v2.6.14): the app leaves a breadcrumb while restoring a session, so if a previous launch died mid-restore the next one skips restoration and clears the saved state instead of trying again. That is the "wipe history / open without the old tabs" escape you asked for, and it now happens automatically.

Detecting an unprocessable file up front is not done. A 30k-row table still goes into the renderer and the DOM as-is. Recent work reduced the pain (a 50 KB preview loads first, and #354/#375 cut rendering cost) but nothing refuses or degrades a document that is too large to handle.

PathGao avatar Aug 02 '26 21:08 PathGao

Half of this is now in a release. Recovery works (#260, #401): the app leaves a breadcrumb naming the document it is about to read during session restore, so a launch that dies mid-restore skips that one file next time, and after three interruptions it restores the tabs without reading any of them. It deliberately keeps your tab list rather than wiping it, which I think is what you actually wanted. Detection is still not done — a 30k-row table still goes into the renderer as-is; the 50 KB preview is a progressive load, not a refusal. Could you say whether a current build opens normally for you now?

PathGao avatar Aug 06 '26 00:08 PathGao

Thanks @PathGao ! After downloading Markpad_2.7.1_x64.exe and starting it 6 times (I probably didn't wait enough for it to work in 3), it finally restarted in no time. However, it only kept one of the previous tabs, not the full tab list. It is possible that my earlier attempts to remove saved state has caused this. The offending file (which was 30 kB by the way, not 30k rows - sorry for the error in the report) is now opening fine, so I cannot use it to test the recovery mechanism further.

Many thanks once again!

eboth avatar Aug 06 '26 10:08 eboth

Thank you for going back and running it — and for the correction, which matters more than it might look.

30 kB, not 30k rows. My two previous comments here were answering the wrong question. I read "30k" as a row count and wrote about large documents going into the renderer as-is, and about Markpad not refusing a file too big to handle. A 30 kB file is small. Nothing about it should be near a limit, so "detect unprocessable files" was never the right frame — something in that particular file drove the renderer into pathological behaviour, which is a defect rather than a capacity problem. Sorry for sending you down that road.

It also means the useful sample is gone: you say the file opens fine on 2.7.1 now, so something between 2.6.11 and 2.7.1 fixed it, and we do not know which change. If you still have that file and would not mind attaching it (you offered originally), it is the only known trigger and it would become a regression test. If not, no problem — it is not blocking anything.

Your tabs were gone before 2.7.1 ever ran, and the recovery could not have brought them back. This is a correction to what I told you: I said your earlier removal of the app data folder was the likely cause, and that is at most half of it.

Markpad writes the tab list once, when the app closes normally. That was a deliberate choice — writing continuously was unreliable in a way that lost the snapshot outright — but it assumes the app gets to close. Yours never did: every session ended in a hang and a kill, so nothing after your last clean exit was ever recorded. The one tab you got back is that last clean exit, not a partial restore.

So the recovery mechanism did its job here even though the result looks thin. It kept what was on disk and did not delete anything; there simply was not more on disk. That the snapshot depends on a graceful close is a real gap, it is being worked on separately, and it is a different problem from the one this issue is about.

Six launches, when the design says two. The mechanism is: before reading each document at startup, write a note naming it; a launch that finds that note still there knows the last one died on that document and skips it. So the first launch dies, the second recovers. Two.

You needed six, and you guessed you had not waited long enough. That is very likely right, though not for the reason you would expect. It is not that a counter needs time — it is that a launch only counts once it has managed to write the note, and everything before that point (process start, webview startup, loading the snapshot) is invisible to the mechanism. Kill it before then and, as far as the next launch can tell, it never happened. On a machine that is already thrashing, with no window on screen and nothing to indicate progress, killing early is the natural thing to do.

I want to be straight that this is the best available explanation and not a proven one. The code writes a line saying exactly which of these happened on every launch — and writes it to a console that a packaged app gives you no way to open. So the one piece of evidence that would settle it was produced six times and discarded each time.

What is changing (#501, open now):

  • The note is written earlier, before loading the saved session, so fewer launches fall into the invisible window above.
  • It is stored the way the session itself is — a file written by the Rust side — instead of in browser storage, which is asynchronous and can lose the write when a process is killed. This repository had already established that; the session snapshot was moved for exactly this reason, and the note was left behind.
  • The next launch after an interruption now tells you, on screen, that the last start was interrupted and which document was skipped. That is for you, and it is also the diagnostic we did not have here.

What it does not change, since I would rather say it than have you discover it: while Markpad is restoring a session, keyboard shortcuts are inert and there is still nothing on screen indicating progress. That is exactly the stretch during which someone decides to reach for Task Manager, and this change does not help there. It is on the list.

PathGao avatar Aug 06 '26 14:08 PathGao

Can you test it again on 2.7.3? Hope everything is fine.

PathGao avatar Aug 11 '26 09:08 PathGao

No answer so I close it as completed

PathGao avatar Aug 25 '26 08:08 PathGao