Cannot upload images with Safari

Starting about one month ago, I have been unable to upload any graphics on Discourse. I get the typical progress information below the composing pane—20%, 40%, 100% uploaded. But once that finishes, the composing pane shows something along these lines (I entered this as preformatted text so everything would show):

[Uploading: Screen Shot 2022-06-14 at 10.58.16 AM.png…]()

and the finished message pane for the same thing will show:

Uploading: Screen Shot 2022-06-14 at 10.58.16 AM.png…

But at that point, no uploading activity is still underway. Obviously, the content that is supposed to be in parentheses isn’t uploading. Waiting for hours doesn’t change anything.

This occurs on a Mac running macOS v10.15.7 and Safari Version 15.5 (15613.2.7.1.9, 15613). When Discourse is accessed on the same machine via Firefox, everything functions normally.

1 Like

Does something appears on the browser DevTools console when this happens?

1 Like

Are there any extensions enabled in Safari? Can you temporarily disable them?

I’m a novice in that regard. Please advise where to look. In my version of Safari, I see only a Develop menu heading on the top bar.

No. This is just the standard installation.

Yes this would be it! I think this random video on YouTube covers how to get to the console? Debugging in Safari | Walkthrough of Safari Dev Tools | Web Inspector Safari - YouTube

2 Likes

Sorry, but that video was so horribly produced I couldn’t follow it. Nevertheless, I think I found the “Console.” If I try to upload a JPG image named Joss-Main to the message I am currently composing in Safari, this is the result:

Uploading: Joss-Main.jpg…

Logging in via Firefox and continuing on the same topic, I can upload a screen shot of the Safari Console window. Everything in the Console window appeared after dragging that one image to the composing pane (while in Safari). As you can see, the screen shot image uploads in Firefox just fine:

What else can I do to try to help sort this out?

1 Like

Given you are using a super recent browser we can try to reproduce here. Assigining it internally to tech advocates so we can see if anyone else can reproduce the issue on Safari 15.5. At the moment I can not even test it on browserstack it is so recent (albeit 100% supported).

Can you upload the problem image here, or is it every single image?

2 Likes

It is every image I have tried. PNG, JPG, PDF…. File type and size do not matter.

2 Likes

Members in my community have the same issue, it seems that safari seems to be the main issue, I will try to fish out the issue for you.

1 Like

Any luck @Noah?

We’ve tried for a simple repro but unfortunately have not been able to replicate it so far. There was another similar topic where the issue turned out to be something to do with a ClearURL browser extension, but I’m not sure that’s helpful here? MacOS Firefox image upload error - #16 by jimkleiber

4 Likes

There are key differences between my problem and the one reported by @jimkleiber:

  • His problem was on Firefox. Firefox works for me.
  • He had a browser extension that was ultimately identified as the problem. I have none.
  • He saw an error message. In my case, Discourse behaves as though the image upload was successful.
2 Likes

Hi @JammyDodger sorry for the slow response, I’m about to conduct a test on my friends version of safari to see if it will pop anything out. @tut Out of interest what device are you using?

1 Like

Screen Shot 2022-07-13 at 3.15.04 PM

A machine nearing the end of its useful life, hence the limitation to macOS v10.15.7.

Oh @david looks to me to be execCommand related per: [BUG] Share > Copy link broken in Safari · Issue #1716 · opensearch-project/OpenSearch-Dashboards · GitHub

My guess is that somehow this version of Safari has bugs with it. This API being flagged “deprecated” is causing all sorts of pain cause browser tend to break it a bit?

We don’t use execCommand when going from upload placeholders → URLs, so I don’t think that’s the cause here. (We can’t easily switch, because execCommand("insertText") requires the textarea to have focus, and uploads may finish when you don’t have the textarea focused).

Uploads still use the set("value", ...) method which we’ve been using for years

It’s technically deprecated from the web standards, but there is not yet any alternative for the insertText command. From MDN:

The Clipboard API can be used instead of execCommand in many cases, but execCommand is still sometimes useful. In particular, the Clipboard API doesn’t replace the insertText command, which you can use to programmatically replace text at the cursor while preserving the undo buffer (edit history) in plain textarea and input elements.

Given the widespread use, it seems incredibly unlikely that browsers are going to drop support for this without first providing an alternative and a deprecation window.

4 Likes

@tut I’ve just added some extra debugging information here on Meta so that we can try and work out what’s happening. Please can you try:

  1. Open Meta in Safari
  2. Open the developer console
  3. Try to upload a file
  4. Click in the developer console
  5. Cmd + a to select all the logs
  6. Right click → save selected
  7. Save the text file somewhere, and then upload it here (using Firefox, I suppose)
2 Likes

@david, here is my attempt to upload a JPEG image named Joss-Main.jpg while in Safari:

Uploading: Joss-Main.jpg…

As expected, the upload did not complete.


Now I have switched to Firefox and picked up composing the same message.

Console.txt (4.1 KB)

1 Like

Ok wow, this is a weird one! Safari is replacing the ... (three periods) with an ellipses character . That then breaks our later attempt to replace the placeholder with the true url.

@tut can you open your system preferences → Keyboard → Text, and see whether you have a replacement configured there. If I add a ... replacement, then I can reproduce the same issue in Safari on my machine:

(yours may look slightly different due to the older macOS version)

So yeah, this seems quite likely - sorry for discarding that idea earlier @sam :sweat_smile:. Looks like Safari is applying OS-level text replacements to text that we add via execCommand("insertText",. I wonder if that’s a new thing in Safari 15.5, or whether it’s always been the case and we just haven’t noticed :thinking:

5 Likes

@david, I have no such substitution set up under Keyboard preferences. Now that I know what to look for, however, I can confirm that the substitution occurs. I can actually see it happen as I type. And I can verify it by using the back arrow. When I get to the ellipses character, the cursor jumps back over all three periods that were entered as separate characters.

The same thing happens in Notes, Preview, Messages, and Mail, but not Calendar, Maps, Photos, or (obviously) Firefox. So it seems to be an app-specific thing, not a system-level one.

2 Likes