You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iOS Safari drops photos when the file input is garbage collected #1333
On iPhone Safari, photos chosen with the image button are sometimes dropped. The picker closes back to the editor, nothing is inserted, no error shows and no upload starts.
It depends on how long the picker stays open, not on how many photos are picked. Quick picks work, even with 10 photos. After about 10 seconds in the picker, nothing is inserted however many are picked. I saw this in Safari 27.2 on Lexxy 1.0.3.
Steps to reproduce
Waiting makes this intermittent, because it depends on when Safari collects garbage. Forcing a collection from Web Inspector on the Mac makes it repeat every time:
Connect the iPhone and open Safari Web Inspector on a page with an editor
Tap the image button and wait 2 seconds, leaving the picker open
Run console.takeHeapSnapshot() in the console
Pick one photo and tap the tick
Nothing is inserted.
Cause
#dispatchUploadAttachment removes the file input a second after clicking it and keeps no reference to it:
While the picker is open, the input can be garbage collected. In WebKit, a disconnected input's wrapper isn't kept alive (JSNodeOwner::isReachableFromOpaqueRoots), ~FileInputType invalidates the chooser, and FileChooser::chooseFiles then returns without a client. So neither change nor cancel fires.
WebKit hit the same thing in its own Web Inspector and fixed it the same way: "Keep the input element alive so it doesn't get garbage collected, which makes the file chooser do nothing" (bug 201290).
To confirm it, I repeated the steps above with a reference to the input held in window, and the photo was inserted.
Activity