nimadez / voxel-builder

Voxel-based 3D modeling application
https://nimadez.github.io/voxel-builder/
MIT License
123 stars 22 forks source link

File > Save As does not work on non-Chromium browsers. #25

Closed AntiBlueQuirk closed 5 months ago

AntiBlueQuirk commented 5 months ago

Cool project, I've only been using it for an hour or so, but it seems pretty sharp so far.

I did have a problem where I don't seem to be able to save my models. I'm using Firefox on desktop, and clicking the save as button just causes... nothing to happen.

This appears to be caused by the use of the Window.showSaveFilePicker() API, which is experimental and only available on some Chromium based browsers. The usage happens on in main.js:5756 (saveFile): https://github.com/nimadez/voxel-builder/blob/386b977020c0a97f360ec4174c6f510cf3b6ba23/src/main.js#L5753-L5774

It looks like this function can already fallback in some conditions. I'm guessing the isMobile check was done for this reason, but it would probably be more accurate to just check whether window.showSaveFilePicker is defined. The other arm of the if block even mentions the function. I'm guessing the exception caused by calling an undefined function is getting swallowed by the empty catch block in the function. Nothing appears in the console when you press Save.

I was able to patch it until reload by running window.saveFile = async function(blob, filename, reject) { reject(); } in the console. This is equivalent to always using the else block and causes the functions that use saveFile to fall back to just downloading the file as a blob, which works fine in all modern browsers, as far as I know.

nimadez commented 5 months ago

Thanks for your report and solution Yes, I am aware of this issue, I will fix it in the next update.