🌊 Волна 6: frontend данные + утечки (8 багов)
Утечки памяти: - animated_cat_timeout_leak: timersRef + cleanup (AnimatedCat.tsx) - compress_fallback_objecturl_leak: revokeObjectURL в onload/onerror (FeedPostComposer.tsx) - lightbox_timeout_leak: safeTimeout + timersRef (ImageLightbox.tsx) - OBJECT_URL_LEAK_TTS: audioUrlRef + revoke на onended/onerror (TeacherChatPage.tsx) Данные: - existing_image_removal_no_delete: removed_images в payload (FeedPostComposer.tsx + api.ts, ТРЕБУЕТ BACKEND) - post_created_images_failed: пост создан → не даём дубль (FeedPostComposer.tsx) - GET_INIT_DATA_EMPTY_STRING: логирование + безопасный fallback (telegram.ts) - unvalidated_lang_from_url: валидация ['pl','ru','uk','en'] (LanguageContext.tsx) Производительность: - LEADERBOARD_O_N2_FILTER: filter вынесен из map (LeaderboardPage.tsx) TTS_VOICE_NOT_ENCODED — уже сделано в Волне 4. Аудит: Issue #3, frontend 8/34 задач
This commit is contained in:
@@ -103,6 +103,8 @@ const TeacherChatPage: React.FC = () => {
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
// 🔧 ФИКС (23.09.2026): OBJECT_URL_LEAK_TTS — храним URL для revoke.
|
||||
const audioUrlRef = useRef<string | null>(null);
|
||||
const idRef = useRef(messages.length > 0 ? Math.max(...messages.map(m => m.id)) + 1 : 0);
|
||||
const startTimeRef = useRef<number>(Date.now());
|
||||
|
||||
@@ -277,7 +279,11 @@ const TeacherChatPage: React.FC = () => {
|
||||
audioRef.current.pause();
|
||||
audioRef.current = null;
|
||||
}
|
||||
|
||||
// 🔧 ФИКС (23.09.2026): OBJECT_URL_LEAK_TTS — освобождаем предыдущий URL
|
||||
if (audioUrlRef.current) {
|
||||
try { URL.revokeObjectURL(audioUrlRef.current); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
if ('speechSynthesis' in window) {
|
||||
window.speechSynthesis.cancel();
|
||||
}
|
||||
@@ -287,12 +293,26 @@ const TeacherChatPage: React.FC = () => {
|
||||
try {
|
||||
const audioBlob = await getTTS(polishText, 'male');
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
audioUrlRef.current = audioUrl; // 🔧 сохраняем для revoke
|
||||
|
||||
const audio = new Audio(audioUrl);
|
||||
audioRef.current = audio;
|
||||
|
||||
audio.onended = () => setIsPlaying(null);
|
||||
audio.onerror = () => setIsPlaying(null);
|
||||
audio.onended = () => {
|
||||
setIsPlaying(null);
|
||||
// 🔧 ФИКС (23.09.2026): освобождаем URL после воспроизведения
|
||||
if (audioUrlRef.current === audioUrl) {
|
||||
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
};
|
||||
audio.onerror = () => {
|
||||
setIsPlaying(null);
|
||||
if (audioUrlRef.current === audioUrl) {
|
||||
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
};
|
||||
|
||||
await audio.play();
|
||||
} catch (e) {
|
||||
@@ -314,6 +334,11 @@ const TeacherChatPage: React.FC = () => {
|
||||
audioRef.current.pause();
|
||||
audioRef.current = null;
|
||||
}
|
||||
// 🔧 ФИКС (23.09.2026): OBJECT_URL_LEAK_TTS
|
||||
if (audioUrlRef.current) {
|
||||
try { URL.revokeObjectURL(audioUrlRef.current); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
if ('speechSynthesis' in window) {
|
||||
window.speechSynthesis.cancel();
|
||||
}
|
||||
@@ -323,10 +348,23 @@ const TeacherChatPage: React.FC = () => {
|
||||
try {
|
||||
const audioBlob = await getTTS(polishText, 'male');
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
audioUrlRef.current = audioUrl;
|
||||
const audio = new Audio(audioUrl);
|
||||
audioRef.current = audio;
|
||||
audio.onended = () => setPlayingExampleLine(null);
|
||||
audio.onerror = () => setPlayingExampleLine(null);
|
||||
audio.onended = () => {
|
||||
setPlayingExampleLine(null);
|
||||
if (audioUrlRef.current === audioUrl) {
|
||||
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
};
|
||||
audio.onerror = () => {
|
||||
setPlayingExampleLine(null);
|
||||
if (audioUrlRef.current === audioUrl) {
|
||||
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
};
|
||||
await audio.play();
|
||||
} catch (e) {
|
||||
console.error('TTS error:', e);
|
||||
@@ -356,6 +394,11 @@ const TeacherChatPage: React.FC = () => {
|
||||
audioRef.current.pause();
|
||||
audioRef.current = null;
|
||||
}
|
||||
// 🔧 ФИКС (23.09.2026): OBJECT_URL_LEAK_TTS — освобождаем URL при размонтировании
|
||||
if (audioUrlRef.current) {
|
||||
try { URL.revokeObjectURL(audioUrlRef.current); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
if ('speechSynthesis' in window) {
|
||||
window.speechSynthesis.cancel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user