Bug 191698 - Safari throws error when changing transceiver.direction
Summary: Safari throws error when changing transceiver.direction
Status: RESOLVED DUPLICATE of bug 191202
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified macOS 10.14
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2018-11-15 11:05 PST by Iñaki Baz
Modified: 2018-12-06 03:40 PST (History)
1 user (show)

See Also:

Script that reproduces the issue. Just run it in Safari 12.1 console with "Unified-Plan" enabled. (1.21 KB, text/javascript)
2018-11-15 11:05 PST, Iñaki Baz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Iñaki Baz 2018-11-15 11:05:10 PST
Created attachment 354958 [details]
Script that reproduces the issue. Just run it in Safari 12.1 console with "Unified-Plan" enabled.

* Latest Safari Tech Preview 12.1 (15-Nov-2018)
* "WebRTC Unified-Plan" enabled in menu "Develop / Experimental Features".


- Add a mic transceiver with "sendonly" direction. Create offer and apply it.

- Remove the mic track using pc.removeTrack(transceiver.sender). Create offer and apply it.

- Add again the mic track using transceiver.replaceTrack(track) and changing transceiver.direction = "sendonly".

It throws "InvalidStateError: The object is in an invalid state."

This should not happen. The app should be able to change transceiver.direction at any time. And in this case, the app does need to set transceiver.direction="sendonly" since it's not supposed to be automatically changed after replacing the sending track.

This works in Chrome and Firefox.
Comment 1 Iñaki Baz 2018-11-15 16:11:18 PST
UPDATE: The error does not happen when setting transceiver.direction = "sendonly" (my fault) but when calling transceiver.sender.replaceTrack(track).

So it seems that, after calling pc.removeTrack(micTransceiver.sender), the transceiver or its sender component becomes unusable for handling new tracks later.
Comment 2 youenn fablet 2018-11-15 18:18:21 PST
Thanks for the report Inaki.

It does not repro on WebKit Tot.
I believe this is a dupe of bug 191202.

*** This bug has been marked as a duplicate of bug 191202 ***
Comment 3 Iñaki Baz 2018-11-16 02:56:55 PST
Hi Youenn, yes, it is the same issue. My fault.

However, according to the latest release notes[*] the issue 191202 is supposed to be fixed in latest Safari Tech Preview, but I can perfectly reproduce the bug by running the attached script.

[*] https://webkit.org/blog/8496/release-notes-for-safari-technology-preview-70/
Comment 4 Iñaki Baz 2018-12-06 03:40:57 PST
Confirmed that it's fixed in latest Safari 12.1, WebKit 14607.1.15.