excalidraw: Save file picker is repeatedly not working

Error message: Failed to execute 'showSaveFilePicker' on 'Window': Must be handling a user gesture to show a file picker.

Browser: Chrome OS: MacOS Monterrey

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 53 (25 by maintainers)

Most upvoted comments

Installing it as a chrome app first makes it work for me.

Happens to me everytime on https://excalidraw.com/ when trying to export a large schema to PNG (using Google Chrome, or the app installed through Google Chrome)

  • x1 scale => no issue
  • x2 scale => no issue
  • x3 scale => Failed to execute 'showSaveFilePicker' on 'Window': Must be handling a user gesture to show a file picker.
DOMException: Failed to execute 'showSaveFilePicker' on 'Window': Must be handling a user gesture to show a file picker.
    at Module.y (https://excalidraw.com/assets/file-save-745eba88-h9NxcJsg.js:1:525)
    at pU (https://excalidraw.com/assets/index-pzqFbuE1.js:119:11238)
    at async rm (https://excalidraw.com/assets/index-pzqFbuE1.js:145:101481)
    at async https://excalidraw.com/assets/index-pzqFbuE1.js:191:7327

I created a new issue for this a few weeks ago since the bug seems to be different

https://github.com/excalidraw/excalidraw/issues/7456

if u electron app have this issue,u can try: app.commandLine.appendSwitch('enable-experimental-web-platform-features');

if u sloved it,give me a star! https://github.com/TrumanDu/toolkit

@tomayac - I’m seeing it happen even with a very simple drawing. See attached example.

2022-04-28 14 15 49

Thanks for running the test. Additional question: is this happening when the scene is very complex? Here is one theory:

  1. The user clicks the Save button (this is the user gesture, which is valid a period of time Δuser_gesture).
  2. Excalidraw prepares the to-be-saved data, which may take some time Δprep.
  3. The browser tries to show the file save dialog, but if Δprep > Δuser_gesture, the user gesture is no longer good.

In browser-fs-access, the library used by Excalidraw under the hood, we now support a new programming model, where the to-be-saved data may be passed as a Promise<Blob> as well (apart from a pre-prepared Blob and streaming Response).

// `blobOrPromiseBlobOrResponse` is a `Blob`, a `Promise<Blob>`, or a `Response`.
await fileSave(
  blobOrResponseOrPromiseBlob,
  options,
  existingHandle,
  throwIfExistingHandleNotGood
);

Before we explore this, it would be helpful to know if this is the problem. Judging from your video (where apparently the data is available immediately), it’s not, but I wanted to be sure.

Screen Shot 2022-04-28 at 10 46 37

Cannot reproduce either. This is via BrowserStack.