replayContext.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. import {
  2. createContext,
  3. memo,
  4. useCallback,
  5. useContext,
  6. useEffect,
  7. useRef,
  8. useState,
  9. } from 'react';
  10. import {useTheme} from '@emotion/react';
  11. import {Replayer, ReplayerEvents} from '@sentry-internal/rrweb';
  12. import type {
  13. PrefsStrategy,
  14. ReplayPrefs,
  15. } from 'sentry/components/replays/preferences/replayPreferences';
  16. import useReplayHighlighting from 'sentry/components/replays/useReplayHighlighting';
  17. import {trackAnalytics} from 'sentry/utils/analytics';
  18. import clamp from 'sentry/utils/number/clamp';
  19. import type useInitialOffsetMs from 'sentry/utils/replays/hooks/useInitialTimeOffsetMs';
  20. import useRAF from 'sentry/utils/replays/hooks/useRAF';
  21. import type ReplayReader from 'sentry/utils/replays/replayReader';
  22. import useOrganization from 'sentry/utils/useOrganization';
  23. import usePrevious from 'sentry/utils/usePrevious';
  24. import useProjectFromId from 'sentry/utils/useProjectFromId';
  25. import {useUser} from 'sentry/utils/useUser';
  26. import {CanvasReplayerPlugin} from './canvasReplayerPlugin';
  27. import {VideoReplayer} from './videoReplayer';
  28. type Dimensions = {height: number; width: number};
  29. type RootElem = null | HTMLDivElement;
  30. type HighlightCallbacks = ReturnType<typeof useReplayHighlighting>;
  31. // Important: Don't allow context Consumers to access `Replayer` directly.
  32. // It has state that, when changed, will not trigger a react render.
  33. // Instead only expose methods that wrap `Replayer` and manage state.
  34. interface ReplayPlayerContextProps extends HighlightCallbacks {
  35. /**
  36. * The context in which the replay is being viewed.
  37. */
  38. analyticsContext: string;
  39. /**
  40. * The time, in milliseconds, where the user focus is.
  41. * The user focus can be reported by any collaborating object, usually on
  42. * hover.
  43. */
  44. currentHoverTime: undefined | number;
  45. /**
  46. * The current time of the video, in milliseconds
  47. * The value is updated on every animation frame, about every 16.6ms
  48. */
  49. currentTime: number;
  50. /**
  51. * Original dimensions in pixels of the captured browser window
  52. */
  53. dimensions: Dimensions;
  54. /**
  55. * The calculated speed of the player when fast-forwarding through idle moments in the video
  56. * The value is set to `0` when the video is not fast-forwarding
  57. * The speed is automatically determined by the length of each idle period
  58. */
  59. fastForwardSpeed: number;
  60. /**
  61. * Set to true while the library is reconstructing the DOM
  62. */
  63. isBuffering: boolean;
  64. /**
  65. * Is the data inside the `replay` complete, or are we waiting for more.
  66. */
  67. isFetching;
  68. /**
  69. * Set to true when the replay finish event is fired
  70. */
  71. isFinished: boolean;
  72. /**
  73. * Whether the video is currently playing
  74. */
  75. isPlaying: boolean;
  76. /**
  77. * Whether fast-forward mode is enabled if RRWeb detects idle moments in the video
  78. */
  79. isSkippingInactive: boolean;
  80. /**
  81. * Set to true while the current video is loading (this is used
  82. * only for video replays and in lieu of `isBuffering`)
  83. */
  84. isVideoBuffering: boolean;
  85. /**
  86. * Whether the replay is considered a video replay
  87. */
  88. isVideoReplay: boolean;
  89. /**
  90. * The core replay data
  91. */
  92. replay: ReplayReader | null;
  93. /**
  94. * Restart the replay
  95. */
  96. restart: () => void;
  97. /**
  98. * Set the currentHoverTime so collaborating components can highlight related
  99. * information
  100. */
  101. setCurrentHoverTime: (time: undefined | number) => void;
  102. /**
  103. * Jump the video to a specific time
  104. */
  105. setCurrentTime: (time: number) => void;
  106. /**
  107. * Required to be called with a <div> Ref
  108. * Represents the location in the DOM where the iframe video should be mounted
  109. *
  110. * @param root
  111. */
  112. setRoot: (root: RootElem) => void;
  113. /**
  114. * Set speed for normal playback
  115. */
  116. setSpeed: (speed: number) => void;
  117. /**
  118. * Set the timeline width to the specific scale, starting at 1x and growing larger
  119. */
  120. setTimelineScale: (size: number) => void;
  121. /**
  122. * The speed for normal playback
  123. */
  124. speed: number;
  125. /**
  126. * Scale of the timeline width, starts from 1x and increases by 1x
  127. */
  128. timelineScale: number;
  129. /**
  130. * Start or stop playback
  131. *
  132. * @param play
  133. */
  134. togglePlayPause: (play: boolean) => void;
  135. /**
  136. * Allow RRWeb to use Fast-Forward mode for idle moments in the video
  137. *
  138. * @param skip
  139. */
  140. toggleSkipInactive: (skip: boolean) => void;
  141. }
  142. const ReplayPlayerContext = createContext<ReplayPlayerContextProps>({
  143. analyticsContext: '',
  144. clearAllHighlights: () => {},
  145. currentHoverTime: undefined,
  146. currentTime: 0,
  147. dimensions: {height: 0, width: 0},
  148. fastForwardSpeed: 0,
  149. addHighlight: () => {},
  150. isBuffering: false,
  151. isVideoBuffering: false,
  152. isFetching: false,
  153. isFinished: false,
  154. isPlaying: false,
  155. isVideoReplay: false,
  156. isSkippingInactive: true,
  157. removeHighlight: () => {},
  158. replay: null,
  159. restart: () => {},
  160. setCurrentHoverTime: () => {},
  161. setCurrentTime: () => {},
  162. setRoot: () => {},
  163. setSpeed: () => {},
  164. setTimelineScale: () => {},
  165. speed: 1,
  166. timelineScale: 1,
  167. togglePlayPause: () => {},
  168. toggleSkipInactive: () => {},
  169. });
  170. type Props = {
  171. /**
  172. * The context in which the replay is being viewed.
  173. * Attached to certain analytics events.
  174. */
  175. analyticsContext: string;
  176. children: React.ReactNode;
  177. /**
  178. * Is the data inside the `replay` complete, or are we waiting for more.
  179. */
  180. isFetching: boolean;
  181. /**
  182. * The strategy for saving/loading preferences, like the playback speed
  183. */
  184. prefsStrategy: PrefsStrategy;
  185. replay: ReplayReader | null;
  186. /**
  187. * Start the video as soon as it's ready
  188. */
  189. autoStart?: boolean;
  190. /**
  191. * Time, in seconds, when the video should start
  192. */
  193. initialTimeOffsetMs?: ReturnType<typeof useInitialOffsetMs>;
  194. /**
  195. * Override return fields for testing
  196. */
  197. value?: Partial<ReplayPlayerContextProps>;
  198. };
  199. function useCurrentTime(callback: () => number) {
  200. const [currentTime, setCurrentTime] = useState(0);
  201. useRAF(() => setCurrentTime(callback));
  202. return currentTime;
  203. }
  204. function ProviderNonMemo({
  205. analyticsContext,
  206. children,
  207. initialTimeOffsetMs,
  208. isFetching,
  209. prefsStrategy,
  210. replay,
  211. autoStart,
  212. value = {},
  213. }: Props) {
  214. const user = useUser();
  215. const organization = useOrganization();
  216. const projectSlug = useProjectFromId({
  217. project_id: replay?.getReplay().project_id,
  218. })?.slug;
  219. const events = replay?.getRRWebFrames();
  220. const savedReplayConfigRef = useRef<ReplayPrefs>(prefsStrategy.get());
  221. const theme = useTheme();
  222. const oldEvents = usePrevious(events);
  223. // Note we have to check this outside of hooks, see `usePrevious` comments
  224. const hasNewEvents = events !== oldEvents;
  225. const replayerRef = useRef<Replayer>(null);
  226. const [dimensions, setDimensions] = useState<Dimensions>({height: 0, width: 0});
  227. const [currentHoverTime, setCurrentHoverTime] = useState<undefined | number>();
  228. const [isPlaying, setIsPlaying] = useState(false);
  229. const [finishedAtMS, setFinishedAtMS] = useState<number>(-1);
  230. const [isSkippingInactive, setIsSkippingInactive] = useState(
  231. savedReplayConfigRef.current.isSkippingInactive
  232. );
  233. const [speed, setSpeedState] = useState(savedReplayConfigRef.current.playbackSpeed);
  234. const [fastForwardSpeed, setFFSpeed] = useState(0);
  235. const [buffer, setBufferTime] = useState({target: -1, previous: -1});
  236. const [isVideoBuffering, setVideoBuffering] = useState(false);
  237. const playTimer = useRef<number | undefined>(undefined);
  238. const didApplyInitialOffset = useRef(false);
  239. const [timelineScale, setTimelineScale] = useState(1);
  240. const [rootEl, setRoot] = useState<HTMLDivElement | null>(null);
  241. const durationMs = replay?.getDurationMs() ?? 0;
  242. const clipWindow = replay?.getClipWindow() ?? undefined;
  243. const startTimeOffsetMs = replay?.getStartOffsetMs() ?? 0;
  244. const videoEvents = replay?.getVideoEvents();
  245. const startTimestampMs = replay?.getStartTimestampMs();
  246. const isVideoReplay = Boolean(
  247. organization.features.includes('session-replay-mobile-player') && videoEvents?.length
  248. );
  249. const forceDimensions = (dimension: Dimensions) => {
  250. setDimensions(dimension);
  251. };
  252. const onFastForwardStart = (e: {speed: number}) => {
  253. setFFSpeed(e.speed);
  254. };
  255. const onFastForwardEnd = () => {
  256. setFFSpeed(0);
  257. };
  258. const {addHighlight, clearAllHighlights, removeHighlight} = useReplayHighlighting({
  259. replayerRef,
  260. });
  261. const getCurrentPlayerTime = useCallback(
  262. () => (replayerRef.current ? Math.max(replayerRef.current.getCurrentTime(), 0) : 0),
  263. []
  264. );
  265. const isFinished = getCurrentPlayerTime() === finishedAtMS;
  266. const setReplayFinished = useCallback(() => {
  267. setFinishedAtMS(getCurrentPlayerTime());
  268. setIsPlaying(false);
  269. }, [getCurrentPlayerTime]);
  270. const privateSetCurrentTime = useCallback(
  271. (requestedTimeMs: number) => {
  272. const replayer = replayerRef.current;
  273. if (!replayer) {
  274. return;
  275. }
  276. const skipInactive = replayer.config;
  277. if (skipInactive) {
  278. // If the replayer is set to skip inactive, we should turn it off before
  279. // manually scrubbing, so when the player resumes playing its not stuck
  280. replayer.setConfig({skipInactive: false});
  281. }
  282. const time = clamp(requestedTimeMs, 0, startTimeOffsetMs + durationMs);
  283. // Sometimes rrweb doesn't get to the exact target time, as long as it has
  284. // changed away from the previous time then we can hide then buffering message.
  285. setBufferTime({target: time, previous: getCurrentPlayerTime()});
  286. // Clear previous timers. Without this (but with the setTimeout) multiple
  287. // requests to set the currentTime could finish out of order and cause jumping.
  288. if (playTimer.current) {
  289. window.clearTimeout(playTimer.current);
  290. }
  291. if (skipInactive) {
  292. replayer.setConfig({skipInactive: true});
  293. }
  294. if (isPlaying) {
  295. playTimer.current = window.setTimeout(() => replayer.play(time), 0);
  296. setIsPlaying(true);
  297. } else {
  298. playTimer.current = window.setTimeout(() => replayer.pause(time), 0);
  299. setIsPlaying(false);
  300. }
  301. },
  302. [startTimeOffsetMs, durationMs, getCurrentPlayerTime, isPlaying]
  303. );
  304. const setCurrentTime = useCallback(
  305. (requestedTimeMs: number) => {
  306. privateSetCurrentTime(requestedTimeMs + startTimeOffsetMs);
  307. clearAllHighlights();
  308. },
  309. [privateSetCurrentTime, startTimeOffsetMs, clearAllHighlights]
  310. );
  311. const applyInitialOffset = useCallback(() => {
  312. const offsetMs = (initialTimeOffsetMs?.offsetMs ?? 0) + startTimeOffsetMs;
  313. if (
  314. !didApplyInitialOffset.current &&
  315. (initialTimeOffsetMs || offsetMs) &&
  316. events &&
  317. replayerRef.current
  318. ) {
  319. const highlightArgs = initialTimeOffsetMs?.highlight;
  320. if (offsetMs > 0) {
  321. privateSetCurrentTime(offsetMs);
  322. }
  323. if (highlightArgs) {
  324. addHighlight(highlightArgs);
  325. setTimeout(() => {
  326. clearAllHighlights();
  327. addHighlight(highlightArgs);
  328. });
  329. }
  330. didApplyInitialOffset.current = true;
  331. }
  332. }, [
  333. clearAllHighlights,
  334. events,
  335. addHighlight,
  336. initialTimeOffsetMs,
  337. privateSetCurrentTime,
  338. startTimeOffsetMs,
  339. ]);
  340. useEffect(clearAllHighlights, [clearAllHighlights, isPlaying]);
  341. const initRoot = useCallback(
  342. (root: RootElem) => {
  343. if (events === undefined || root === null || isFetching) {
  344. return;
  345. }
  346. if (replayerRef.current) {
  347. if (!hasNewEvents) {
  348. return;
  349. }
  350. if (replayerRef.current.iframe.contentDocument?.body.childElementCount === 0) {
  351. // If this is true, then no need to clear old iframe as nothing was rendered
  352. return;
  353. }
  354. // We have new events, need to clear out the old iframe because a new
  355. // `Replayer` instance is about to be created
  356. while (root.firstChild) {
  357. root.removeChild(root.firstChild);
  358. }
  359. }
  360. // eslint-disable-next-line no-new
  361. const inst = new Replayer(events, {
  362. root,
  363. blockClass: 'sentry-block',
  364. mouseTail: {
  365. duration: 0.75 * 1000,
  366. lineCap: 'round',
  367. lineWidth: 2,
  368. strokeStyle: theme.purple200,
  369. },
  370. plugins: organization.features.includes('session-replay-enable-canvas-replayer')
  371. ? [CanvasReplayerPlugin(events)]
  372. : [],
  373. skipInactive: savedReplayConfigRef.current.isSkippingInactive,
  374. speed: savedReplayConfigRef.current.playbackSpeed,
  375. });
  376. // @ts-expect-error: rrweb types event handlers with `unknown` parameters
  377. inst.on(ReplayerEvents.Resize, forceDimensions);
  378. inst.on(ReplayerEvents.Finish, setReplayFinished);
  379. // @ts-expect-error: rrweb types event handlers with `unknown` parameters
  380. inst.on(ReplayerEvents.SkipStart, onFastForwardStart);
  381. inst.on(ReplayerEvents.SkipEnd, onFastForwardEnd);
  382. // `.current` is marked as readonly, but it's safe to set the value from
  383. // inside a `useEffect` hook.
  384. // See: https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables
  385. // @ts-expect-error
  386. replayerRef.current = inst;
  387. applyInitialOffset();
  388. if (autoStart) {
  389. inst.play(startTimeOffsetMs);
  390. setIsPlaying(true);
  391. }
  392. },
  393. [
  394. applyInitialOffset,
  395. events,
  396. hasNewEvents,
  397. isFetching,
  398. organization.features,
  399. setReplayFinished,
  400. theme.purple200,
  401. startTimeOffsetMs,
  402. autoStart,
  403. ]
  404. );
  405. const initVideoRoot = useCallback(
  406. (root: RootElem) => {
  407. if (root === null || isFetching) {
  408. return null;
  409. }
  410. // check if this is a video replay and if we can use the video replayer
  411. if (!isVideoReplay || !videoEvents || !startTimestampMs) {
  412. return null;
  413. }
  414. const inst = new VideoReplayer(videoEvents, {
  415. videoApiPrefix: `/api/0/projects/${
  416. organization.slug
  417. }/${projectSlug}/replays/${replay?.getReplay().id}/videos/`,
  418. root,
  419. start: startTimestampMs,
  420. onFinished: setReplayFinished,
  421. onLoaded: event => {
  422. const {videoHeight, videoWidth} = event.target;
  423. if (!videoHeight || !videoWidth) {
  424. return;
  425. }
  426. setDimensions({
  427. height: videoHeight,
  428. width: videoWidth,
  429. });
  430. },
  431. onBuffer: buffering => {
  432. setVideoBuffering(buffering);
  433. },
  434. clipWindow,
  435. durationMs,
  436. });
  437. // `.current` is marked as readonly, but it's safe to set the value from
  438. // inside a `useEffect` hook.
  439. // See: https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables
  440. // @ts-expect-error
  441. replayerRef.current = inst;
  442. applyInitialOffset();
  443. if (autoStart) {
  444. inst.play(startTimeOffsetMs);
  445. setIsPlaying(true);
  446. }
  447. return inst;
  448. },
  449. [
  450. applyInitialOffset,
  451. autoStart,
  452. isFetching,
  453. isVideoReplay,
  454. videoEvents,
  455. organization.slug,
  456. projectSlug,
  457. replay,
  458. setReplayFinished,
  459. startTimestampMs,
  460. startTimeOffsetMs,
  461. clipWindow,
  462. durationMs,
  463. ]
  464. );
  465. const setSpeed = useCallback(
  466. (newSpeed: number) => {
  467. const replayer = replayerRef.current;
  468. savedReplayConfigRef.current = {
  469. ...savedReplayConfigRef.current,
  470. playbackSpeed: newSpeed,
  471. };
  472. prefsStrategy.set(savedReplayConfigRef.current);
  473. if (!replayer) {
  474. return;
  475. }
  476. if (isPlaying) {
  477. replayer.pause();
  478. replayer.setConfig({speed: newSpeed});
  479. replayer.play(getCurrentPlayerTime());
  480. } else {
  481. replayer.setConfig({speed: newSpeed});
  482. }
  483. setSpeedState(newSpeed);
  484. },
  485. [prefsStrategy, getCurrentPlayerTime, isPlaying]
  486. );
  487. const togglePlayPause = useCallback(
  488. (play: boolean) => {
  489. const replayer = replayerRef.current;
  490. if (!replayer) {
  491. return;
  492. }
  493. if (play) {
  494. replayer.play(getCurrentPlayerTime());
  495. } else {
  496. replayer.pause(getCurrentPlayerTime());
  497. }
  498. setIsPlaying(play);
  499. trackAnalytics('replay.play-pause', {
  500. organization,
  501. user_email: user.email,
  502. play,
  503. context: analyticsContext,
  504. });
  505. },
  506. [organization, user.email, analyticsContext, getCurrentPlayerTime]
  507. );
  508. useEffect(() => {
  509. const handleVisibilityChange = () => {
  510. if (document.visibilityState !== 'visible' && replayerRef.current) {
  511. togglePlayPause(false);
  512. }
  513. };
  514. document.addEventListener('visibilitychange', handleVisibilityChange);
  515. return () => {
  516. document.removeEventListener('visibilitychange', handleVisibilityChange);
  517. };
  518. }, [togglePlayPause]);
  519. // Initialize replayer for Video Replays
  520. useEffect(() => {
  521. const instance =
  522. isVideoReplay && rootEl && !replayerRef.current && initVideoRoot(rootEl);
  523. return () => {
  524. if (instance && !rootEl) {
  525. instance.destroy();
  526. }
  527. };
  528. }, [rootEl, isVideoReplay, initVideoRoot, videoEvents]);
  529. // For non-video (e.g. rrweb) replays, initialize the player
  530. useEffect(() => {
  531. if (!isVideoReplay && events) {
  532. if (replayerRef.current) {
  533. // If it's already been initialized, we still call initRoot, which
  534. // should clear out existing dom element
  535. initRoot(replayerRef.current.wrapper.parentElement as RootElem);
  536. } else if (rootEl) {
  537. initRoot(rootEl);
  538. }
  539. }
  540. }, [rootEl, initRoot, events, isVideoReplay]);
  541. // Clean-up rrweb replayer when root element is unmounted
  542. useEffect(() => {
  543. return () => {
  544. if (rootEl && replayerRef.current) {
  545. replayerRef.current.destroy();
  546. // @ts-expect-error Cleaning up
  547. replayerRef.current = null;
  548. }
  549. };
  550. }, [rootEl]);
  551. const restart = useCallback(() => {
  552. if (replayerRef.current) {
  553. replayerRef.current.play(startTimeOffsetMs);
  554. setIsPlaying(true);
  555. }
  556. }, [startTimeOffsetMs]);
  557. const toggleSkipInactive = useCallback(
  558. (skip: boolean) => {
  559. const replayer = replayerRef.current;
  560. savedReplayConfigRef.current = {
  561. ...savedReplayConfigRef.current,
  562. isSkippingInactive: skip,
  563. };
  564. prefsStrategy.set(savedReplayConfigRef.current);
  565. if (!replayer) {
  566. return;
  567. }
  568. if (skip !== replayer.config.skipInactive) {
  569. replayer.setConfig({skipInactive: skip});
  570. }
  571. setIsSkippingInactive(skip);
  572. },
  573. [prefsStrategy]
  574. );
  575. const currentPlayerTime = useCurrentTime(getCurrentPlayerTime);
  576. const [isBuffering, currentBufferedPlayerTime] =
  577. buffer.target !== -1 &&
  578. buffer.previous === currentPlayerTime &&
  579. buffer.target !== buffer.previous
  580. ? [true, buffer.target]
  581. : [false, currentPlayerTime];
  582. const currentTime = currentBufferedPlayerTime - startTimeOffsetMs;
  583. useEffect(() => {
  584. if (!isBuffering && events && events.length >= 2 && replayerRef.current) {
  585. applyInitialOffset();
  586. }
  587. }, [isBuffering, events, applyInitialOffset]);
  588. useEffect(() => {
  589. if (!isBuffering && buffer.target !== -1) {
  590. setBufferTime({target: -1, previous: -1});
  591. }
  592. }, [isBuffering, buffer.target]);
  593. return (
  594. <ReplayPlayerContext.Provider
  595. value={{
  596. analyticsContext,
  597. clearAllHighlights,
  598. currentHoverTime,
  599. currentTime,
  600. dimensions,
  601. fastForwardSpeed,
  602. addHighlight,
  603. setRoot,
  604. isBuffering: isBuffering && !isVideoReplay,
  605. isVideoBuffering,
  606. isFetching,
  607. isVideoReplay,
  608. isFinished,
  609. isPlaying,
  610. isSkippingInactive,
  611. removeHighlight,
  612. replay,
  613. restart,
  614. setCurrentHoverTime,
  615. setCurrentTime,
  616. setSpeed,
  617. setTimelineScale,
  618. speed,
  619. timelineScale,
  620. togglePlayPause,
  621. toggleSkipInactive,
  622. ...value,
  623. }}
  624. >
  625. {children}
  626. </ReplayPlayerContext.Provider>
  627. );
  628. }
  629. export const useReplayContext = () => useContext(ReplayPlayerContext);
  630. export const Provider = memo(ProviderNonMemo);