[251124] fix: PlayerPanel,VideoPlayer 최적화
🕐 커밋 시간: 2025. 11. 24. 17:26:27 📊 변경 통계: • 총 파일: 2개 • 추가: +22줄 📝 수정된 파일: ~ com.twin.app.shoptime/src/reducers/playReducer.js ~ com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx 🔧 주요 변경 내용: • 핵심 비즈니스 로직 개선 • 소규모 기능 개선
This commit is contained in:
@@ -93,6 +93,7 @@ export const playReducer = (state = initialState, action) => {
|
||||
return {
|
||||
...state,
|
||||
chatData: {},
|
||||
subTitleBlobs: {},
|
||||
};
|
||||
}
|
||||
case types.UPDATE_VIDEO_PLAY_STATE: {
|
||||
|
||||
@@ -260,6 +260,7 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props
|
||||
const showNowInfos = USE_SELECTOR('showNowInfos', (state) => state.main.showNowInfo);
|
||||
const liveShowInfos = USE_SELECTOR('liveShowInfos', (state) => state.main.liveShowInfos);
|
||||
const vodSubtitleData = USE_SELECTOR('vodSubtitleData', (state) => state.play.subTitleBlobs);
|
||||
const previousSubtitleBlobRef = useRef(null);
|
||||
const broadcast = USE_SELECTOR('broadcast', (state) => state.common.broadcast);
|
||||
const videoPlayState = USE_SELECTOR('videoPlayState', (state) => state.play.videoPlayState);
|
||||
|
||||
@@ -1892,6 +1893,26 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props
|
||||
return vodSubtitleData[currentSubtitleUrl];
|
||||
}, [vodSubtitleData, currentSubtitleUrl]);
|
||||
|
||||
// 자막 Blob URL 수명 관리: 이전 Blob을 해제해 메모리 누수 방지
|
||||
useEffect(() => {
|
||||
const prevBlobUrl = previousSubtitleBlobRef.current;
|
||||
if (prevBlobUrl && prevBlobUrl !== currentSubtitleBlob && typeof prevBlobUrl === 'string') {
|
||||
if (prevBlobUrl.startsWith('blob:')) {
|
||||
URL.revokeObjectURL(prevBlobUrl);
|
||||
}
|
||||
}
|
||||
|
||||
previousSubtitleBlobRef.current = currentSubtitleBlob;
|
||||
|
||||
return () => {
|
||||
const lastBlobUrl = previousSubtitleBlobRef.current;
|
||||
if (lastBlobUrl && typeof lastBlobUrl === 'string' && lastBlobUrl.startsWith('blob:')) {
|
||||
URL.revokeObjectURL(lastBlobUrl);
|
||||
}
|
||||
previousSubtitleBlobRef.current = null;
|
||||
};
|
||||
}, [currentSubtitleBlob]);
|
||||
|
||||
const isReadyToPlay = useMemo(() => {
|
||||
if (!currentPlayingUrl) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user