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

Downloads continue after PeerConnection closes #1468

Closed
bemasc opened this issue May 1, 2015 · 5 comments
Closed

Downloads continue after PeerConnection closes #1468

bemasc opened this issue May 1, 2015 · 5 comments
Assignees
Labels

Comments

@bemasc
Copy link
Contributor

bemasc commented May 1, 2015

I have been testing the copypaste sample app with CHURN enabled, over the public internet, to an endpoint that is also running a webserver. The client then requests a large file on this webserver.

The PeerConnection often fails due to ICE disconnection (presumably related to CHURN), and both sides indicate that the connection is "stopped" in the UI. However, the server continues to download the file until it completes and the webserver terminates the transfer.

Setting breakpoints showed strange behavior:

  • In RtcToNet
    • `this.sendOnSocket_ is never called
    • but its returned Promise fires over and over (updating the UI's reported bytes transferred), each time with a different 4096-byte ArrayBuffer
  • In PoolChannel
    • this.dc_.onceClosed has fired
    • but this.state_ is 0 (OPEN), and this.onceClosed has not fired

The former suggests a problem with setPaused and a huge backlog of promises. The latter suggests a logic error in PoolChannel. More investigation is needed.

@bemasc bemasc self-assigned this May 1, 2015
@trevj trevj added the P2 label May 4, 2015
@trevj trevj added this to the v-focus-2015-05-18 milestone May 4, 2015
@bemasc
Copy link
Contributor Author

bemasc commented May 4, 2015

The observed issue with PoolChannel seems to have been due to testing with an old version of the code. With the latest from dev branch this no longer happens, but some version of the issue persists: downloads still appear to continue for some time after the PeerConnection closes.

Breakpoint debugging shows that data channel closing triggers the expect sequence of close calls, and RtcToNet logs "discarded session" ... but "bytes sent to remote party" in the UI continues to increase for tens of megabytes. It's now clear that this is the known issue of pathological web worker scheduling on ultra-fast downloads: in the time that it takes to hit DataChannel's 250 KB overflow threshold, and deliver the pause message upstream, 40-60 MB can be delivered to the browser.

The best short-term mitigation I know of to this is to make backpressure reaction time faster: #1474

@bemasc
Copy link
Contributor Author

bemasc commented May 5, 2015

After some investigation, backpressure is already about as fast as we know how to make it without a change to freedom, such as freedomjs/freedom#255.

@trevj
Copy link
Contributor

trevj commented May 11, 2015

Question: did you try having SocksToRtc.stopResources_ call this.tcpConnection_.dataFromSocketQueue.claerHandler();:
https://github.com/uProxy/uproxy-lib/blob/dev/src/socks-to-rtc/socks-to-rtc.ts#L358

@bemasc
Copy link
Contributor Author

bemasc commented May 11, 2015

Effectively, yes, I landed that change last week: https://github.com/uProxy/uproxy-lib/pull/167/files

Indeed, that seems to make this problem much less severe, so I'll mark it as closed.

@bemasc bemasc closed this as completed May 11, 2015
@trevj
Copy link
Contributor

trevj commented May 11, 2015

Apologies, I totally forgot I reviewed just this :-)

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

No branches or pull requests

2 participants