Open Bug 1681874 Opened 4 years ago Updated 4 years ago

TCPSocket.bufferedAmount doesn't update when it isn't on main process

Categories

(Core :: DOM: Networking, defect, P3)

defect

Tracking

()

Tracking Status
firefox85 --- affected

People

(Reporter: jaliu, Unassigned)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

TCPSocket.bufferedAmount represents the number of bytes which have previously been buffered by calls to TCPSocket.send().
It should be updated and eventually become 0 when the data buffer is sent.
It works as expected on main process but the value wouldn't become 0 if it isn't on main process.

Steps to Reproduce:
Call web API TCPSocket.send on any kind of non-main process.

Here is an example.

  1. Open Firefox browser (Firefox 83.0)
  2. Type about:debugging#/runtime/this-firefox to the URL bar
  3. Inspect a Firefox extension (ex: BugzillaJS)
  4. Send data to any TCP server via TCPSocket in console
socket = navigator.mozTCPSocket.open(IP_OF_TCP_SERVER, PORT_OF_TCP_SERVER, { binaryType: "arraybuffer", });
smallUint8Array = new Uint8Array(128);
for (let i = 0; i < smallUint8Array.length; i++) {
  smallUint8Array[i] = i;
}
socket.send(smallUint8Array.buffer, 0, smallUint8Array.length);
  1. Wait for 1 or 2 seconds and check the value of socket.bufferedAmount
    socket.bufferedAmount is still 128
    P.S. It would be updated to 0 if it's on main process.

The issue can be observed since gecko lands the changes of Bug 1569183.
It seems like the IPC of TCPSocket doesn't cover the update of TCPSocket::mTrackingNumber.

Though, I'm not sure whether all the use cases on Firefox Browser use TCPSocket on main process.
Thanks

(In reply to Jamin Liu [:jaliu][:Jamin] from comment #1)

The issue can be observed since gecko lands the changes of Bug 1569183.
It seems like the IPC of TCPSocket doesn't cover the update of TCPSocket::mTrackingNumber.

Though, I'm not sure whether all the use cases on Firefox Browser use TCPSocket on main process.
Thanks

Thanks for reporting this.
I think it's not common to use TCPSocket on parent process, so mark this as P3.

Severity: -- → S4
Priority: -- → P3
Whiteboard: [necko-triaged]

(In reply to Kershaw Chang [:kershaw] from comment #2)

(In reply to Jamin Liu [:jaliu][:Jamin] from comment #1)

The issue can be observed since gecko lands the changes of Bug 1569183.
It seems like the IPC of TCPSocket doesn't cover the update of TCPSocket::mTrackingNumber.

Though, I'm not sure whether all the use cases on Firefox Browser use TCPSocket on main process.
Thanks

Thanks for reporting this.
I think it's not common to use TCPSocket on parent process, so mark this as P3.

See Jamin's first comment: " It works as expected on main process but the value wouldn't become 0 if it isn't on main process."

EIther way, Jamin can you submit your patch?

(In reply to [:fabrice] Fabrice Desré from comment #3)

EIther way, Jamin can you submit your patch?
Provide a WIP patch that partially undo the change of [1] for correcting the update of TCPSocket.bufferedAmount.
[1] https://phabricator.services.mozilla.com/D45112

The patch is shared here for starting a discussion.
I'm not sure whether the change is suitable for all the use cases of TCPSocket, therefore, I didn't raise the review flag.

Feel free to take this Bug without asking me.
Thanks.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: