Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to download bug on Safari #115

Open
Ahmad-S792 opened this issue Jul 16, 2024 · 5 comments
Open

Unable to download bug on Safari #115

Ahmad-S792 opened this issue Jul 16, 2024 · 5 comments
Labels
Issue Something to look into

Comments

@Ahmad-S792
Copy link

Steps to Reproduce

  1. Go to https://commitmono.com
  2. Go to 'Customize'
  3. Click on Download custom for dev

Expected Results

It should download without issue.

Actual Result

I get error and nothing gets logged in Web Console (Inspector) as well.

image

Just raising so this can be fixed.

If you need any help from WebKit side - please don't hesitate to raise bug on bugs.webkit.org.

Thanks!

@karlcow
Copy link

karlcow commented Jul 17, 2024

So indeed Firefox, Chrome OK
Safari not ok.

The link is a button…

<button class="button_link safari"
        onclick="downloadFont('dev', this)"
        tabindex="0"
        contenteditable="false">
    Download custom for dev
</button>

Which is calling downloadFont

{
    // console.log("downloadFont")

    // detect safari
    const userAgentString = navigator.userAgent || "."
    let usingChrome = userAgentString.indexOf("Chrome") > -1 || false
    let usingSafari = userAgentString.indexOf("Safari") > -1 || false
    if (usingChrome && usingSafari) usingSafari = false

    // block download if from Safari since zip is corrupted
    if (usingSafari) {
        button.classList.remove("loaded", "error", "safari")
        button.classList.add("loading")
        setTimeout(() => {
            button.classList.remove("loading")
            button.classList.add("safari")
        }, 500)
    } else {
        if (!downloadStarted) {
            downloadStarted = true
            button.classList.remove("loaded", "error", "safari")
            button.classList.add("loading")

   // cut for brevity

            Promise.all(Object.values(allSettings).map((settings) => makeCustomFont(settings)))
                .then((resolve) => getZipFileBlob(kindOfDownload, resolve))
                .then((resolve) => initializeDownload(button, resolve))
                .catch((error) => catchError(button, error))
        }
    }
}

The reason in the comments for blocking Safari seems to be because the zip is corrupted.

    // block download if from Safari since zip is corrupted
    if (usingSafari) {
        button.classList.remove("loaded", "error", "safari")
        button.classList.add("loading")
        setTimeout(() => {
            button.classList.remove("loading")
            button.classList.add("safari")
        }, 500)

With a UA override to be chrome on Safari, for example, I get the confirm download window.

It is downloading locally the zip file after choosing where I want to save it.
It unzips without issues.

Inside the folder.

% ls -a1 ~/Downloads/CommitMonoV143
CommitMono-400-Italic.otf
CommitMono-400-Regular.otf
CommitMono-700-Italic.otf
CommitMono-700-Regular.otf
custom-settings.json
installation.txt
license.txt

So maybe there was a reason in the past which is not valid anymore. And the UA sniffing could be removed.

if (usingSafari) {
button.classList.remove("loaded", "error", "safari")
button.classList.add("loading")
setTimeout(() => {
button.classList.remove("loading")
button.classList.add("safari")
}, 500)
} else {

@karlcow
Copy link

karlcow commented Jul 17, 2024

This was created in #19 to solve probably #17

@eigilnikolajsen
Copy link
Owner

I should have a look at this again, I should be able to get the ZIP on Safari to work.

@eigilnikolajsen eigilnikolajsen added the Issue Something to look into label Sep 25, 2024
@karlcow
Copy link

karlcow commented Sep 27, 2024

If you identify new troubles @eigilnikolajsen do not hesitate to contact me.

@fpigeonjr
Copy link

confirmed on Orion (Version 0.99.130.2-beta (WebKit 621.1.2.111.4))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue Something to look into
Projects
None yet
Development

No branches or pull requests

4 participants