MSE-in-Workers: Cross-thread registry with stubbed attachment

Introduces a concrete CrossThreadMediaSourceAttachment with minimum
implementation necessary to enable worker thread MediaSource object URL
creation. To enable registration of worker-thread MediaSource object
URLs, which is inherent in the createObjectURL implementation, updates
MediaSourceRegistryImpl to perform registration and unregistration while
holding a mutex in the singleton, main-thread-owned, registry instance.
Mutexes previously were thought unusable for this, but that was due to
the registry previously using an Oilpan HeapHashMap bound to the main
thread's Oilpan heap. The current registry now uses a non-Oilpan
HashMap, so any thread can update the singleton so long as such
accesses or updates are mutex-protected. Also, using cross-thread task
posting to perform these tasks led to complex races whose solution is
much simpler using the mutex approach herein. See
CrossThreadMediaSourceAttachment::Unregister() for more detail.

Includes a necessary update which makes both types of attachments manage
the registered media source in appropriate Oilpan type: the cross thread
attachment must hold that reference as CrossThreadPersistent. The URL
registry implementation already unregisters all entries created on an
execution context if that context is destroyed, so this
CrossThreadPersistent registry entry will not outlive the worker
thread's context. See PublicURLManager::ContextDestroyed() for where
that logic exists already. Rationale for not also making the
SameThreadMediaSourceAttachment use a CrossThreadPersistent type is that
such type introduces a new root in all Oilpan heaps, and resulting
performance hit can be avoided by just using regular Persistents for
same thread attachments' |registered_media_source_|.

Includes new web_tests that exercise basic worker context MediaSource
construction, object URL creation and revocation (with revocation of
worker MediaSource object URL also tested on main thread). Starting an
attachment to a worker MediaSource is also tested, but is currently
expected by the test to fail until upcoming
CrossThreadMediaSourceAttachment changes land.

BUG=878133

Change-Id: I367b6610da9aca3aca7c78f4a11f571e48afc6c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2407075
Reviewed-by: Will Cassella <cassew@google.com>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810002}
4 files changed
tree: 91ce0448859c5ece93c8d8ce5ccbe01d4c0889e3
  1. .github/
  2. .well-known/
  3. accelerometer/
  4. accname/
  5. acid/
  6. ambient-light/
  7. animation-worklet/
  8. annotation-model/
  9. annotation-protocol/
  10. annotation-vocab/
  11. apng/
  12. appmanifest/
  13. audio-output/
  14. background-fetch/
  15. BackgroundSync/
  16. badging/
  17. battery-status/
  18. beacon/
  19. bluetooth/
  20. clear-site-data/
  21. client-hints/
  22. clipboard-apis/
  23. common/
  24. compat/
  25. compression/
  26. conformance-checkers/
  27. console/
  28. contacts/
  29. content-dpr/
  30. content-index/
  31. content-security-policy/
  32. contenteditable/
  33. cookie-store/
  34. cookies/
  35. core-aam/
  36. cors/
  37. credential-management/
  38. css/
  39. custom-elements/
  40. custom-state-pseudo-class/
  41. delegated-ink/
  42. deprecation-reporting/
  43. device-memory/
  44. docs/
  45. document-policy/
  46. dom/
  47. domparsing/
  48. domxpath/
  49. dpub-aam/
  50. dpub-aria/
  51. editing/
  52. element-timing/
  53. encoding/
  54. encoding-detection/
  55. encrypted-media/
  56. entries-api/
  57. event-timing/
  58. eventsource/
  59. feature-policy/
  60. fetch/
  61. FileAPI/
  62. focus/
  63. font-access/
  64. fonts/
  65. forced-colors-mode/
  66. fullscreen/
  67. gamepad/
  68. generic-sensor/
  69. geolocation-API/
  70. geolocation-sensor/
  71. graphics-aam/
  72. gyroscope/
  73. hr-time/
  74. html/
  75. html-longdesc/
  76. html-media-capture/
  77. idle-detection/
  78. imagebitmap-renderingcontext/
  79. images/
  80. import-maps/
  81. IndexedDB/
  82. inert/
  83. infrastructure/
  84. input-device-capabilities/
  85. input-events/
  86. installedapp/
  87. interfaces/
  88. intersection-observer/
  89. intervention-reporting/
  90. is-input-pending/
  91. js/
  92. js-self-profiling/
  93. keyboard-lock/
  94. keyboard-map/
  95. largest-contentful-paint/
  96. layout-instability/
  97. lifecycle/
  98. loading/
  99. longtask-timing/
  100. magnetometer/
  101. mathml/
  102. measure-memory/
  103. media/
  104. media-capabilities/
  105. media-feeds/
  106. media-playback-quality/
  107. media-source/
  108. mediacapture-depth/
  109. mediacapture-fromelement/
  110. mediacapture-image/
  111. mediacapture-record/
  112. mediacapture-streams/
  113. mediasession/
  114. mimesniff/
  115. mixed-content/
  116. mst-content-hint/
  117. native-file-system/
  118. native-io/
  119. navigation-timing/
  120. netinfo/
  121. network-error-logging/
  122. notifications/
  123. old-tests/
  124. orientation-event/
  125. orientation-sensor/
  126. origin-isolation/
  127. origin-policy/
  128. page-lifecycle/
  129. page-visibility/
  130. paint-timing/
  131. payment-handler/
  132. payment-method-basic-card/
  133. payment-method-id/
  134. payment-request/
  135. performance-timeline/
  136. periodic-background-sync/
  137. permissions/
  138. permissions-request/
  139. permissions-revoke/
  140. picture-in-picture/
  141. pointerevents/
  142. pointerlock/
  143. portals/
  144. preload/
  145. presentation-api/
  146. priority-hints/
  147. proximity/
  148. push-api/
  149. quirks/
  150. raw-sockets/
  151. referrer-policy/
  152. remote-playback/
  153. reporting/
  154. requestidlecallback/
  155. resize-observer/
  156. resource-timing/
  157. resources/
  158. sanitizer-api/
  159. savedata/
  160. screen-capture/
  161. screen-orientation/
  162. screen-wake-lock/
  163. screen_enumeration/
  164. scroll-animations/
  165. scroll-to-text-fragment/
  166. secure-contexts/
  167. selection/
  168. serial/
  169. server-timing/
  170. service-workers/
  171. shadow-dom/
  172. shape-detection/
  173. signed-exchange/
  174. speech-api/
  175. storage/
  176. storage-access-api/
  177. streams/
  178. subresource-integrity/
  179. svg/
  180. svg-aam/
  181. timing-entrytypes-registry/
  182. tools/
  183. touch-events/
  184. trust-tokens/
  185. trusted-types/
  186. ua-client-hints/
  187. uievents/
  188. upgrade-insecure-requests/
  189. url/
  190. user-timing/
  191. vibration/
  192. video-rvfc/
  193. visual-viewport/
  194. wai-aria/
  195. wasm/
  196. web-animations/
  197. web-bundle/
  198. web-locks/
  199. web-nfc/
  200. web-otp/
  201. web-share/
  202. webaudio/
  203. webauthn/
  204. webcodecs/
  205. WebCryptoAPI/
  206. webdriver/
  207. webgl/
  208. webgpu/
  209. webhid/
  210. WebIDL/
  211. webmessaging/
  212. webmidi/
  213. webrtc/
  214. webrtc-extensions/
  215. webrtc-identity/
  216. webrtc-insertable-streams/
  217. webrtc-priority/
  218. webrtc-quic/
  219. webrtc-stats/
  220. webrtc-svc/
  221. websockets/
  222. webstorage/
  223. webtransport/
  224. webusb/
  225. webvr/
  226. webvtt/
  227. webxr/
  228. window-segments/
  229. workers/
  230. worklets/
  231. x-frame-options/
  232. xhr/
  233. xslt/
  234. .azure-pipelines.yml
  235. .codecov.yml
  236. .gitattributes
  237. .gitignore
  238. .mailmap
  239. .pyup.yml
  240. .taskcluster.yml
  241. CODE_OF_CONDUCT.md
  242. CODEOWNERS
  243. CONTRIBUTING.md
  244. LICENSE.md
  245. lint.ignore
  246. README.md
  247. testharness_runner.html
  248. update-built-tests.sh
  249. wpt
  250. wpt.py
README.md

The web-platform-tests Project

Taskcluster CI Status documentation manifest Python 3

The web-platform-tests Project is a cross-browser test suite for the Web-platform stack. Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations. This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors.

The most important sources of information and activity are:

  • github.com/web-platform-tests/wpt: the canonical location of the project's source code revision history and the discussion forum for changes to the code
  • web-platform-tests.org: the documentation website; details how to set up the project, how to write tests, how to give and receive peer review, how to serve as an administrator, and more
  • wpt.live: a public deployment of the test suite, allowing anyone to run the tests by visiting from an Internet-enabled browser of their choice
  • wpt.fyi: an archive of test results collected from an array of web browsers on a regular basis
  • Real-time chat room: the IRC chat room named #testing on irc.w3.org; includes participants located around the world, but busiest during the European working day; all discussion is archived here
  • Mailing list: a public and low-traffic discussion list
  • RFCs: a repo for requesting comments on substantial changes that would impact other stakeholders or users; people who work on WPT infra are encouraged to watch the repo.

If you'd like clarification about anything, don't hesitate to ask in the chat room or on the mailing list.

Setting Up the Repo

Clone or otherwise get https://github.com/web-platform-tests/wpt.

Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune (or git fetch -p && git merge).

Running the Tests

See the documentation website and in particular the system setup for running tests locally.

Command Line Tools

The wpt command provides a frontend to a variety of tools for working with and running web-platform-tests. Some of the most useful commands are:

  • wpt serve - For starting the wpt http server
  • wpt run - For running tests in a browser
  • wpt lint - For running the lint against all tests
  • wpt manifest - For updating or generating a MANIFEST.json test manifest
  • wpt install - For installing the latest release of a browser or webdriver server on the local machine.
  • wpt serve-wave - For starting the wpt http server and the WAVE test runner. For more details on how to use the WAVE test runner see the documentation.

Windows Notes

On Windows wpt commands must be prefixed with python or the path to the python binary (if python is not in your %PATH%).

python wpt [command]

Alternatively, you may also use Bash on Ubuntu on Windows in the Windows 10 Anniversary Update build, then access your windows partition from there to launch wpt commands.

Please make sure git and your text editor do not automatically convert line endings, as it will cause lint errors. For git, please set git config core.autocrlf false in your working tree.

Publication

The master branch is automatically synced to http://w3c-test.org/.

Pull requests are automatically mirrored except those that modify sensitive resources (such as .py). The latter require someone with merge access to comment with “LGTM” or “w3c-test:mirror” to indicate the pull request has been checked.

Branches

In the vast majority of cases the only upstream branch that you should need to care about is master. If you see other branches in the repository, you can generally safely ignore them.

Contributing

Save the Web, Write Some Tests!

Absolutely everyone is welcome to contribute to test development. No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser.

The way to contribute is just as usual:

  • Fork this repository (and make sure you're still relatively in sync with it if you forked a while ago).
  • Create a branch for your changes: git checkout -b topic.
  • Make your changes.
  • Run ./wpt lint as described above.
  • Commit locally and push that to your repo.
  • Create a pull request based on the above.

Issues with web-platform-tests

If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue. Thank you!