simplewebrtc / SimpleWebRTC

Simplest WebRTC ever
Other
4.65k stars 1.19k forks source link

Filetransfer issue between Chrome and Safari #664

Open bbrcan opened 6 years ago

bbrcan commented 6 years ago

G'day!

I'm having trouble transferring files from Chrome on a desktop machine, to Safari running on iOS. Chrome to Chrome works fine, however.

It's strange. I'll sit there and slowly transfer one file after another, and the fileTransfer event will be triggered occasionally, but most of the time it just doesn't fire. However, the channelMessage event does fire, with labels like filetransfer1517703458432. I can only assume that the file is getting broken up into separate messages, and only some parts are making it across?

this._webrtc.on('createdPeer', peer => {
  console.log('createdPeer')
  this.peer = peer
  this.peer.on('fileTransfer', (metadata, receiver) => {
    console.log('fileTransfer')
    receiver.on('receivedFile', (file, metadata) => {
      console.log(`receivedFile (size=${file.size/1000}KB)`)
      this._snapshotReceivedCallback(URL.createObjectURL(file))
      receiver.channel.close()
    })
  })
})
this._webrtc.on('channelMessage', (peer, label, data) => {
  console.log('channelMessage', label, data)
  if (label.startsWith('filetransfer')) {
    console.log('startswith filetransfer')
    const url = URL.createObjectURL(data) // this does not work, I imagine because it's only part of the file
    this._snapshotReceivedCallback(url)
  }
})
this.canvas.toBlob(blob => { this.peer.sendFile(blob) })

The files are just PNG images, around 900KB in size.

Running Chrome 64.0.3282.140 and iOS 11.2.5. I don't have a Mac at the moment, so I'm having to debug the iOS side with Weinre, so apologies if I've missed anything obvious!

The signalling server & web server are hosted in the cloud, but both devices are on the same LAN (using WiFi), so file transfer should be very speedy.

Any help would be awesome!

Thanks guys :)

fippo commented 6 years ago

there are a couple of bugs in the datachannel implementation in chrome which you might be hitting, see https://bugs.chromium.org/p/chromium/issues/detail?id=795865 for example.

bbrcan commented 6 years ago

Thanks fippo

It looks like there's nothing you can do, then.

Are there any workarounds I can adopt?

bbrcan commented 6 years ago

G'day again!

It seems that issue refers only to a Chrome to Chrome issue, which has been cleared up. As I mentioned, Chrome to Chrome works for me, but Chrome to Safari does not.

I tried https://simplewebrtc.com/filetransfer between two instances of Safari (11.0.3) but I could not even get them to connect to each other, for whatever reason. SimpleWebRTC state goes from "checking" to "failed".

When I tried https://simplewebrtc.com/filetransfer between Chrome and Safari, they connect but the file transfer only works sporadically.

Any ideas?