<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277433] trunk/Source/WebKit</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277433">277433</a></dd>
<dt>Author</dt> <dd>peng.liu6@apple.com</dd>
<dt>Date</dt> <dd>2021-05-13 07:12:22 -0700 (Thu, 13 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Subtitles in Safari fail to appear after switching language
https://bugs.webkit.org/show_bug.cgi?id=225738

Reviewed by Jer Noble.

`TextTrackPrivateRemote::setMode()` calls `InbandTextTrackPrivate::setMode()`, but
it does not set the value of `TextTrackPrivateRemote::mode` properly. Therefore,
`TextTrackPrivateRemote::mode` will always be `Disabled`. When we switch text track
in the WebContent process side, we will only send the IPC message `TextTrackSetMode`
to `RemoteMediaPlayerProxy` in the GPU process to change the mode from `Disabled`
to `Showing`, but cannot change its value back to `Disabled`. When a user keeps
switching text track, all text tracks in the GPU process will become `Showing`,
and `MediaPlayerPrivateAVFoundation` cannot deal with that. As a result,
the WebContent process won't get the correct subtitles from the GPU process.
`cueFormat()` has the similar issue, it does not impact the functionality though.

Actually, `TextTrackPrivateRemote` can simply use the implementations of its
base class `InbandTextTrackPrivate` regarding mode and cue format.

In addition, `TextTrackPrivateRemote` does not need to get the "mode" value from
`RemoteTextTrackProxy` in the GPU process. So this patch removes the `mode` attribute
of `TextTrackPrivateRemoteConfiguration`.

* GPUProcess/media/RemoteTextTrackProxy.cpp:
(WebKit::RemoteTextTrackProxy::configuration):
* GPUProcess/media/TextTrackPrivateRemoteConfiguration.h:
(WebKit::TextTrackPrivateRemoteConfiguration::encode const):
(WebKit::TextTrackPrivateRemoteConfiguration::decode):
* WebProcess/GPU/media/TextTrackPrivateRemote.cpp:
(WebKit::TextTrackPrivateRemote::setMode):
(WebKit::TextTrackPrivateRemote::updateConfiguration):
* WebProcess/GPU/media/TextTrackPrivateRemote.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitGPUProcessmediaRemoteTextTrackProxycpp">trunk/Source/WebKit/GPUProcess/media/RemoteTextTrackProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitGPUProcessmediaTextTrackPrivateRemoteConfigurationh">trunk/Source/WebKit/GPUProcess/media/TextTrackPrivateRemoteConfiguration.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUmediaTextTrackPrivateRemotecpp">trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUmediaTextTrackPrivateRemoteh">trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277432 => 277433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-05-13 13:54:43 UTC (rev 277432)
+++ trunk/Source/WebKit/ChangeLog       2021-05-13 14:12:22 UTC (rev 277433)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2021-05-13  Peng Liu  <peng.liu6@apple.com>
+
+        Subtitles in Safari fail to appear after switching language
+        https://bugs.webkit.org/show_bug.cgi?id=225738
+
+        Reviewed by Jer Noble.
+
+        `TextTrackPrivateRemote::setMode()` calls `InbandTextTrackPrivate::setMode()`, but
+        it does not set the value of `TextTrackPrivateRemote::mode` properly. Therefore,
+        `TextTrackPrivateRemote::mode` will always be `Disabled`. When we switch text track
+        in the WebContent process side, we will only send the IPC message `TextTrackSetMode`
+        to `RemoteMediaPlayerProxy` in the GPU process to change the mode from `Disabled`
+        to `Showing`, but cannot change its value back to `Disabled`. When a user keeps
+        switching text track, all text tracks in the GPU process will become `Showing`,
+        and `MediaPlayerPrivateAVFoundation` cannot deal with that. As a result,
+        the WebContent process won't get the correct subtitles from the GPU process.
+        `cueFormat()` has the similar issue, it does not impact the functionality though.
+
+        Actually, `TextTrackPrivateRemote` can simply use the implementations of its
+        base class `InbandTextTrackPrivate` regarding mode and cue format.
+
+        In addition, `TextTrackPrivateRemote` does not need to get the "mode" value from
+        `RemoteTextTrackProxy` in the GPU process. So this patch removes the `mode` attribute
+        of `TextTrackPrivateRemoteConfiguration`.
+
+        * GPUProcess/media/RemoteTextTrackProxy.cpp:
+        (WebKit::RemoteTextTrackProxy::configuration):
+        * GPUProcess/media/TextTrackPrivateRemoteConfiguration.h:
+        (WebKit::TextTrackPrivateRemoteConfiguration::encode const):
+        (WebKit::TextTrackPrivateRemoteConfiguration::decode):
+        * WebProcess/GPU/media/TextTrackPrivateRemote.cpp:
+        (WebKit::TextTrackPrivateRemote::setMode):
+        (WebKit::TextTrackPrivateRemote::updateConfiguration):
+        * WebProcess/GPU/media/TextTrackPrivateRemote.h:
+
</ins><span class="cx"> 2021-05-13  Carlos Garcia Campos  <cgarcia@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r277262): test imported/w3c/web-platform-tests/css/selectors/focus-visible-002.html is crashing
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessmediaRemoteTextTrackProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/media/RemoteTextTrackProxy.cpp (277432 => 277433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/media/RemoteTextTrackProxy.cpp    2021-05-13 13:54:43 UTC (rev 277432)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteTextTrackProxy.cpp       2021-05-13 14:12:22 UTC (rev 277433)
</span><span class="lines">@@ -69,7 +69,6 @@
</span><span class="cx">     configuration->startTimeVariance = m_trackPrivate->startTimeVariance();
</span><span class="cx"> 
</span><span class="cx">     configuration->cueFormat = m_trackPrivate->cueFormat();
</span><del>-    configuration->mode = m_trackPrivate->mode();
</del><span class="cx">     configuration->isClosedCaptions = m_trackPrivate->isClosedCaptions();
</span><span class="cx">     configuration->isSDH = m_trackPrivate->isSDH();
</span><span class="cx">     configuration->containsOnlyForcedSubtitles = m_trackPrivate->containsOnlyForcedSubtitles();
</span></span></pre></div>
<a id="trunkSourceWebKitGPUProcessmediaTextTrackPrivateRemoteConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/GPUProcess/media/TextTrackPrivateRemoteConfiguration.h (277432 => 277433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/GPUProcess/media/TextTrackPrivateRemoteConfiguration.h       2021-05-13 13:54:43 UTC (rev 277432)
+++ trunk/Source/WebKit/GPUProcess/media/TextTrackPrivateRemoteConfiguration.h  2021-05-13 14:12:22 UTC (rev 277433)
</span><span class="lines">@@ -42,7 +42,6 @@
</span><span class="cx">     int trackIndex;
</span><span class="cx"> 
</span><span class="cx">     WebCore::InbandTextTrackPrivate::CueFormat cueFormat { WebCore::InbandTextTrackPrivate::CueFormat::Generic };
</span><del>-    WebCore::InbandTextTrackPrivate::Mode mode { WebCore::InbandTextTrackPrivate::Mode::Disabled };
</del><span class="cx">     WebCore::InbandTextTrackPrivate::Kind kind { WebCore::InbandTextTrackPrivate::Kind::None };
</span><span class="cx"> 
</span><span class="cx">     bool isClosedCaptions { false };
</span><span class="lines">@@ -62,7 +61,6 @@
</span><span class="cx">         encoder << startTimeVariance;
</span><span class="cx">         encoder << trackIndex;
</span><span class="cx">         encoder << cueFormat;
</span><del>-        encoder << mode;
</del><span class="cx">         encoder << kind;
</span><span class="cx">         encoder << isClosedCaptions;
</span><span class="cx">         encoder << isSDH;
</span><span class="lines">@@ -110,11 +108,6 @@
</span><span class="cx">         if (!cueFormat)
</span><span class="cx">             return WTF::nullopt;
</span><span class="cx"> 
</span><del>-        Optional<WebCore::InbandTextTrackPrivate::Mode> mode;
-        decoder >> mode;
-        if (!mode)
-            return WTF::nullopt;
-
</del><span class="cx">         Optional<WebCore::InbandTextTrackPrivate::Kind> kind;
</span><span class="cx">         decoder >> kind;
</span><span class="cx">         if (!kind)
</span><span class="lines">@@ -158,7 +151,6 @@
</span><span class="cx">             WTFMove(*startTimeVariance),
</span><span class="cx">             *trackIndex,
</span><span class="cx">             *cueFormat,
</span><del>-            *mode,
</del><span class="cx">             *kind,
</span><span class="cx">             *isClosedCaptions,
</span><span class="cx">             *isSDH,
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUmediaTextTrackPrivateRemotecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp (277432 => 277433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp      2021-05-13 13:54:43 UTC (rev 277432)
+++ trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.cpp 2021-05-13 14:12:22 UTC (rev 277433)
</span><span class="lines">@@ -51,9 +51,10 @@
</span><span class="cx">     if (!m_gpuProcessConnection)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (mode != m_mode)
-        m_gpuProcessConnection->connection().send(Messages::RemoteMediaPlayerProxy::TextTrackSetMode(m_identifier, mode), m_playerIdentifier);
</del><ins>+    if (mode == InbandTextTrackPrivate::mode())
+        return;
</ins><span class="cx"> 
</span><ins>+    m_gpuProcessConnection->connection().send(Messages::RemoteMediaPlayerProxy::TextTrackSetMode(m_identifier, mode), m_playerIdentifier);
</ins><span class="cx">     InbandTextTrackPrivate::setMode(mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -84,9 +85,7 @@
</span><span class="cx">     m_inBandMetadataTrackDispatchType = configuration.inBandMetadataTrackDispatchType;
</span><span class="cx">     m_startTimeVariance = configuration.startTimeVariance;
</span><span class="cx"> 
</span><del>-    m_format = configuration.cueFormat;
</del><span class="cx">     m_kind = configuration.kind;
</span><del>-    m_mode = configuration.mode;
</del><span class="cx">     m_isClosedCaptions = configuration.isClosedCaptions;
</span><span class="cx">     m_isSDH = configuration.isSDH;
</span><span class="cx">     m_containsOnlyForcedSubtitles = configuration.containsOnlyForcedSubtitles;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUmediaTextTrackPrivateRemoteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h (277432 => 277433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h        2021-05-13 13:54:43 UTC (rev 277432)
+++ trunk/Source/WebKit/WebProcess/GPU/media/TextTrackPrivateRemote.h   2021-05-13 14:12:22 UTC (rev 277433)
</span><span class="lines">@@ -80,15 +80,11 @@
</span><span class="cx">     int trackIndex() const final { return m_trackIndex; }
</span><span class="cx">     AtomString inBandMetadataTrackDispatchType() const final { return m_inBandMetadataTrackDispatchType; }
</span><span class="cx"> 
</span><del>-    using TextTrackCueFormat = WebCore::InbandTextTrackPrivate::CueFormat;
-    TextTrackCueFormat cueFormat() const final { return m_format; }
-
</del><span class="cx">     using TextTrackKind = WebCore::InbandTextTrackPrivate::Kind;
</span><span class="cx">     TextTrackKind kind() const final { return m_kind; }
</span><span class="cx"> 
</span><span class="cx">     using TextTrackMode = WebCore::InbandTextTrackPrivate::Mode;
</span><span class="cx">     void setMode(TextTrackMode) final;
</span><del>-    TextTrackMode mode() const final { return m_mode; }
</del><span class="cx"> 
</span><span class="cx">     bool isClosedCaptions() const final { return m_isClosedCaptions; }
</span><span class="cx">     bool isSDH() const final { return m_isSDH; }
</span><span class="lines">@@ -110,9 +106,7 @@
</span><span class="cx">     WebCore::MediaPlayerIdentifier m_playerIdentifier;
</span><span class="cx">     TrackPrivateRemoteIdentifier m_identifier;
</span><span class="cx"> 
</span><del>-    TextTrackCueFormat m_format { TextTrackCueFormat::Generic };
</del><span class="cx">     TextTrackKind m_kind { TextTrackKind::None };
</span><del>-    TextTrackMode m_mode { TextTrackMode::Disabled };
</del><span class="cx">     bool m_isClosedCaptions { false };
</span><span class="cx">     bool m_isSDH { false };
</span><span class="cx">     bool m_containsOnlyForcedSubtitles { false };
</span></span></pre>
</div>
</div>

</body>
</html>