Commit 98943f6
committed
[MSE] Change canPlayThroughRange to check buffered data at the current position https://bugs.webkit.org/show_bug.cgi?id=265023
Reviewed by Xabier Rodriguez-Calvar.
The current SourceBuffer::canPlayThroughRange() implementation is based on average buffering
rate. While this approach makes sense in a context of continuous playback, where the JS app
is always trying to append data, this isn't always the case in some real life apps. For
instance, an app may append a lot of data on page load (enough for sustained playback), then
decide to wait for whatever reason, and then start playback. In those circumstances, wait
would cause the average buffering rate to be artificially low. There are more examples of
the kind of problems that a time-based/average buffering rate-based approach may cause.
See: #928
This patch uses the Firefox strategy to this problem[1]: if the ranges to be checked have 3
seconds or more buffered after the current position, we consider that sustained playback is
possible. This solves the issues seen in some real world apps.
All the logic to monitor and compute the buffering rate has been removed, because it would
have remained unused after this change.
Based on code from Arnaud Vrac <avrac@freebox.fr> and Jean-Yves Avenard <jyavenard@mozilla.com>.
[1] https://github.com/mozilla/gecko-dev/blob/master/dom/media/mediasource/MediaSourceDecoder.cpp#L320
* LayoutTests/media/media-source/media-source-monitor-playing-event-expected.txt: Changed expectation after second append to be HAVE_CURRENT_DATA instead of HAVE_ENOUGH_DATA because the current playback implementation in MockMediaPlayerMediaSource advances playback to the end of the buffered range, so there's no 3s buffered slack after that (needed to get enough data).
* LayoutTests/media/media-source/media-source-monitor-playing-event.html: Added some clarification comments. Coalesce multiple 'waiting' events, since they're time dependant and can change between platforms.
* LayoutTests/media/media-source/media-managedmse-resume-after-stall-expected.txt: Changed expectation to conform to 3s + 3s buffered segments.
* LayoutTests/media/media-source/media-managedmse-resume-after-stall.html: Buffer a minimum of 3s (3 segments) instead of 2, because 3s is the new limit to reach canPlayThrough.
* Source/WebCore/Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::appendBuffer): Remove call to monitorBufferingRate().
(WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): Ditto.
(WebCore::SourceBuffer::canPlayThroughRange): Removed implementation based on m_averageBufferRate. Now return true if the ranges have at least 3 seconds of data after currentTime (with a special case that accounts for the end of the video). Use a tolerance to prevent small errors.
(WebCore::SourceBuffer::sourceBufferPrivateDidParseSample): Deleted.
(WebCore::SourceBuffer::monitorBufferingRate): Deleted.
* Source/WebCore/Modules/mediasource/SourceBuffer.h: Deleted sourceBufferPrivateDidParseSample() and monitorBufferingRate().
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::processMediaSample): Remove call to sourceBufferPrivateDidParseSample(). Added comment about the tolerance being the same as in SourceBuffer::canPlayThroughRange().
* Source/WebCore/platform/graphics/SourceBufferPrivateClient.h: Deleted sourceBufferPrivateDidParseSample().
* Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp:
(WebKit::RemoteSourceBufferProxy::sourceBufferPrivateDidParseSample): Deleted.
* Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h: Deleted sourceBufferPrivateDidParseSample().
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::sourceBufferPrivateDidParseSample): Deleted.
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h: Deleted sourceBufferPrivateDidParseSample().
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in: Deleted sourceBufferPrivateDidParseSample message.
Canonical link: https://commits.webkit.org/272762@main1 parent f7120b4 commit 98943f6
11 files changed
Lines changed: 26 additions & 75 deletions
File tree
- LayoutTests/media/media-source
- Source
- WebCore
- Modules/mediasource
- platform/graphics
- WebKit
- GPUProcess/media
- WebProcess/GPU/media
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | | - | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| |||
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| 83 | + | |
77 | 84 | | |
78 | | - | |
| 85 | + | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
| |||
227 | 226 | | |
228 | 227 | | |
229 | 228 | | |
230 | | - | |
231 | 229 | | |
232 | 230 | | |
233 | 231 | | |
| |||
593 | 591 | | |
594 | 592 | | |
595 | 593 | | |
596 | | - | |
597 | 594 | | |
598 | 595 | | |
599 | 596 | | |
| |||
1174 | 1171 | | |
1175 | 1172 | | |
1176 | 1173 | | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | 1174 | | |
1183 | 1175 | | |
1184 | 1176 | | |
| |||
1209 | 1201 | | |
1210 | 1202 | | |
1211 | 1203 | | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
1232 | 1204 | | |
1233 | 1205 | | |
1234 | 1206 | | |
1235 | 1207 | | |
1236 | 1208 | | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | 1209 | | |
| 1210 | + | |
| 1211 | + | |
1247 | 1212 | | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
| 1213 | + | |
| 1214 | + | |
1253 | 1215 | | |
1254 | 1216 | | |
1255 | | - | |
1256 | | - | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1257 | 1226 | | |
1258 | 1227 | | |
1259 | 1228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
166 | 165 | | |
167 | 166 | | |
168 | 167 | | |
| |||
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
204 | | - | |
205 | | - | |
206 | 203 | | |
207 | 204 | | |
208 | 205 | | |
| |||
243 | 240 | | |
244 | 241 | | |
245 | 242 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | 243 | | |
250 | 244 | | |
251 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
961 | 961 | | |
962 | 962 | | |
963 | 963 | | |
| 964 | + | |
964 | 965 | | |
965 | 966 | | |
966 | 967 | | |
| |||
1108 | 1109 | | |
1109 | 1110 | | |
1110 | 1111 | | |
1111 | | - | |
1112 | 1112 | | |
1113 | | - | |
1114 | 1113 | | |
1115 | 1114 | | |
1116 | 1115 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 150 | | |
159 | 151 | | |
160 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | 79 | | |
81 | 80 | | |
82 | 81 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | 444 | | |
451 | 445 | | |
452 | 446 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | 117 | | |
119 | 118 | | |
120 | 119 | | |
| |||
0 commit comments