Stories: Fix false positive media compatibility check (#4337)
This commit is contained in:
parent
f46acb5ab7
commit
543a9383b6
@ -348,9 +348,11 @@ function Story({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoadedStory || isDeletedStory || areViewsExpired) return;
|
if (!isLoadedStory || isDeletedStory || areViewsExpired) return;
|
||||||
|
|
||||||
|
if (!isOut && !isChannelStory) return;
|
||||||
|
|
||||||
// Refresh counters each time
|
// Refresh counters each time
|
||||||
loadStoryViews({ peerId, storyId });
|
loadStoryViews({ peerId, storyId });
|
||||||
}, [isDeletedStory, areViewsExpired, isLoadedStory, peerId, storyId]);
|
}, [isDeletedStory, areViewsExpired, isLoadedStory, peerId, storyId, isOut, isChannelStory]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { ApiMediaFormat } from '../../../api/types';
|
|||||||
|
|
||||||
import { getStoryMediaHash } from '../../../global/helpers';
|
import { getStoryMediaHash } from '../../../global/helpers';
|
||||||
import { selectPeerStories } from '../../../global/selectors';
|
import { selectPeerStories } from '../../../global/selectors';
|
||||||
|
import unloadVideo from '../../../util/browser/unloadVideo';
|
||||||
import { preloadImage } from '../../../util/files';
|
import { preloadImage } from '../../../util/files';
|
||||||
import * as mediaLoader from '../../../util/mediaLoader';
|
import * as mediaLoader from '../../../util/mediaLoader';
|
||||||
import { getProgressiveUrl } from '../../../util/mediaLoader';
|
import { getProgressiveUrl } from '../../../util/mediaLoader';
|
||||||
@ -125,9 +126,7 @@ function preloadProgressive(url: string) {
|
|||||||
head.appendChild(video);
|
head.appendChild(video);
|
||||||
video.load();
|
video.load();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
video.pause();
|
unloadVideo(video);
|
||||||
video.src = '';
|
|
||||||
video.load();
|
|
||||||
head.removeChild(video);
|
head.removeChild(video);
|
||||||
}, PROGRESSIVE_PRELOAD_DURATION);
|
}, PROGRESSIVE_PRELOAD_DURATION);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { useEffect } from '../lib/teact/teact';
|
|||||||
import { DEBUG } from '../config';
|
import { DEBUG } from '../config';
|
||||||
import { requestMutation } from '../lib/fasterdom/fasterdom';
|
import { requestMutation } from '../lib/fasterdom/fasterdom';
|
||||||
import { applyStyles } from '../util/animation';
|
import { applyStyles } from '../util/animation';
|
||||||
|
import unloadVideo from '../util/browser/unloadVideo';
|
||||||
import { makeProgressiveLoader } from '../util/progressieveLoader';
|
import { makeProgressiveLoader } from '../util/progressieveLoader';
|
||||||
import { IS_SAFARI } from '../util/windowEnvironment';
|
import { IS_SAFARI } from '../util/windowEnvironment';
|
||||||
|
|
||||||
@ -78,9 +79,7 @@ export function useStreaming(videoRef: RefObject<HTMLVideoElement>, url?: string
|
|||||||
return () => {
|
return () => {
|
||||||
requestMutation(() => {
|
requestMutation(() => {
|
||||||
const src = video.src;
|
const src = video.src;
|
||||||
video.pause();
|
unloadVideo(video);
|
||||||
video.src = '';
|
|
||||||
video.load();
|
|
||||||
mediaSource.removeEventListener('sourceopen', onSourceOpen);
|
mediaSource.removeEventListener('sourceopen', onSourceOpen);
|
||||||
if (mediaSource.readyState === 'open') {
|
if (mediaSource.readyState === 'open') {
|
||||||
endOfStream(mediaSource);
|
endOfStream(mediaSource);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import type { RefObject } from 'react';
|
|||||||
import { useEffect } from '../lib/teact/teact';
|
import { useEffect } from '../lib/teact/teact';
|
||||||
|
|
||||||
import { requestNextMutation } from '../lib/fasterdom/fasterdom';
|
import { requestNextMutation } from '../lib/fasterdom/fasterdom';
|
||||||
|
import unloadVideo from '../util/browser/unloadVideo';
|
||||||
|
|
||||||
// Fix for memory leak when unmounting video element
|
// Fix for memory leak when unmounting video element
|
||||||
export default function useVideoCleanup(videoRef: RefObject<HTMLVideoElement>, dependencies: any[]) {
|
export default function useVideoCleanup(videoRef: RefObject<HTMLVideoElement>, dependencies: any[]) {
|
||||||
@ -12,9 +13,7 @@ export default function useVideoCleanup(videoRef: RefObject<HTMLVideoElement>, d
|
|||||||
if (videoEl) {
|
if (videoEl) {
|
||||||
// It may be slow (specifically on iOS), so we postpone it after unmounting
|
// It may be slow (specifically on iOS), so we postpone it after unmounting
|
||||||
requestNextMutation(() => {
|
requestNextMutation(() => {
|
||||||
videoEl.pause();
|
unloadVideo(videoEl);
|
||||||
videoEl.src = '';
|
|
||||||
videoEl.load();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
6
src/util/browser/unloadVideo.ts
Normal file
6
src/util/browser/unloadVideo.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export default function unloadVideo(video: HTMLVideoElement) {
|
||||||
|
video.pause();
|
||||||
|
// https://github.com/shaka-project/shaka-player/commit/0e3d10e61cb08cc35750e48face4e58f24542fc8
|
||||||
|
video.removeAttribute('src');
|
||||||
|
video.load();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user