<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>191698</bug_id>
          
          <creation_ts>2018-11-15 11:05:10 -0800</creation_ts>
          <short_desc>Safari throws error when changing transceiver.direction</short_desc>
          <delta_ts>2018-12-06 03:40:57 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebRTC</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>macOS 10.14</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>191202</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Iñaki Baz">ibc</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1478981</commentid>
    <comment_count>0</comment_count>
      <attachid>354958</attachid>
    <who name="Iñaki Baz">ibc</who>
    <bug_when>2018-11-15 11:05:10 -0800</bug_when>
    <thetext>Created attachment 354958
Script that reproduces the issue. Just run it in Safari 12.1 console with &quot;Unified-Plan&quot; enabled.

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

Scenario:

- Add a mic transceiver with &quot;sendonly&quot; 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 = &quot;sendonly&quot;.

It throws &quot;InvalidStateError: The object is in an invalid state.&quot;

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=&quot;sendonly&quot; since it&apos;s not supposed to be automatically changed after replacing the sending track.

This works in Chrome and Firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1479166</commentid>
    <comment_count>1</comment_count>
    <who name="Iñaki Baz">ibc</who>
    <bug_when>2018-11-15 16:11:18 -0800</bug_when>
    <thetext>UPDATE: The error does not happen when setting transceiver.direction = &quot;sendonly&quot; (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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1479214</commentid>
    <comment_count>2</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2018-11-15 18:18:21 -0800</bug_when>
    <thetext>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 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1479324</commentid>
    <comment_count>3</comment_count>
    <who name="Iñaki Baz">ibc</who>
    <bug_when>2018-11-16 02:56:55 -0800</bug_when>
    <thetext>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/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1485674</commentid>
    <comment_count>4</comment_count>
    <who name="Iñaki Baz">ibc</who>
    <bug_when>2018-12-06 03:40:57 -0800</bug_when>
    <thetext>Confirmed that it&apos;s fixed in latest Safari 12.1, WebKit 14607.1.15.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>354958</attachid>
            <date>2018-11-15 11:05:10 -0800</date>
            <delta_ts>2018-11-15 11:05:10 -0800</delta_ts>
            <desc>Script that reproduces the issue. Just run it in Safari 12.1 console with &quot;Unified-Plan&quot; enabled.</desc>
            <filename>safari-throws-when-changing-transceiver-direction.js</filename>
            <type>text/javascript</type>
            <size>1241</size>
            <attacher name="Iñaki Baz">ibc</attacher>
            
              <data encoding="base64">bGV0IG1pY1RyYWNrOwpsZXQgbWljVHJhbnNjZWl2ZXI7CmNvbnN0IHBjID0gbmV3IFJUQ1BlZXJD
b25uZWN0aW9uKAogIHsKICAgIGljZVNlcnZlcnMgICAgOiBbXSwKICAgIGJ1bmRsZVBvbGljeSAg
OiAnbWF4LWJ1bmRsZScsCiAgICBydGNwTXV4UG9saWN5IDogJ3JlcXVpcmUnLAogICAgc2RwU2Vt
YW50aWNzICA6ICd1bmlmaWVkLXBsYW4nCiAgfSk7CgpuYXZpZ2F0b3IubWVkaWFEZXZpY2VzLmdl
dFVzZXJNZWRpYSh7IGF1ZGlvOiB0cnVlIH0pCiAgLnRoZW4oKHN0cmVhbSkgPT4KICB7CiAgICBt
aWNUcmFjayA9IHN0cmVhbS5nZXRBdWRpb1RyYWNrcygpWzBdOwogIH0pCiAgLnRoZW4oKCkgPT4K
ICB7CiAgICBjb25zb2xlLndhcm4oJ2FkZGluZyBtaWMgdHJhY2snKTsKCiAgICBtaWNUcmFuc2Nl
aXZlciA9CiAgICAgIHBjLmFkZFRyYW5zY2VpdmVyKG1pY1RyYWNrLCB7IGRpcmVjdGlvbjogJ3Nl
bmRvbmx5JyB9KTsKICB9KQogIC50aGVuKCgpID0+IGRvU2RwU3R1ZmYoKSkKICAudGhlbigoKSA9
PgogIHsKICAgIGNvbnNvbGUud2FybigncmVtb3ZpbmcgbWljIHRyYWNrIHVzaW5nIHBjLnJlbW92
ZVRyYWNrKHNlbmRlciknKTsKCiAgICBwYy5yZW1vdmVUcmFjayhtaWNUcmFuc2NlaXZlci5zZW5k
ZXIpOwogIH0pCiAgLnRoZW4oKCkgPT4gZG9TZHBTdHVmZigpKQogIC50aGVuKCgpID0+CiAgewog
ICAgY29uc29sZS53YXJuKCdhZGRpbmcgbWljIHRyYWNrIGFnYWluJyk7CgogICAgLy8gU2FmYXJp
IHRocm93cyBoZXJlLiBJdCBzaG91bGQgbm90LgogICAgbWljVHJhbnNjZWl2ZXIuZGlyZWN0aW9u
ID0gJ3NlbmRvbmx5JzsKCiAgICByZXR1cm4gbWljVHJhbnNjZWl2ZXIuc2VuZGVyLnJlcGxhY2VU
cmFjayhtaWNUcmFjayk7CiAgfSkKICAudGhlbigoKSA9PiBkb1NkcFN0dWZmKCkpCiAgLmNhdGNo
KChlcnJvcikgPT4KICB7CiAgICBjb25zb2xlLmVycm9yKGVycm9yKTsKICB9KTsKCmZ1bmN0aW9u
IGRvU2RwU3R1ZmYoKQp7CiAgbGV0IGVycm9yZWQgPSBmYWxzZTsKCiAgcmV0dXJuIHBjLmNyZWF0
ZU9mZmVyKCkKICAgIC50aGVuKChvZmZlcikgPT4KICAgIHsKICAgICAgY29uc29sZS53YXJuKCdw
Yy5jcmVhdGVPZmZlcigpIHN1Y2NlZWRlZDpcbiVzJywgb2ZmZXIuc2RwKTsKICAgIH0pCiAgICAu
Y2F0Y2goKGVycm9yKSA9PgogICAgewogICAgICBjb25zb2xlLmVycm9yKCdwYy5jcmVhdGVPZmZl
cigpIGZhaWxlZCcpOwoKICAgICAgdGhyb3cgZXJyb3I7CiAgICB9KTsKfQo=
</data>

          </attachment>
      

    </bug>

</bugzilla>