🌊 Волна 12: frontend утечки + достижения (7 багов)
Утечки ObjectURL: - URL_LEAK_FLASHCARDS: audioUrlRef + revoke (FlashcardsPage.tsx) - URL_LEAK_PRONUNCIATION: audioUrlRef + revoke (PronunciationPage.tsx) - URL_LEAK_TYPING: audioUrlRef + revoke (TypingPage.tsx) - URL_LEAK_TESTVIEW: audioUrlRef + revoke (TestViewPage.tsx) UI: - ALERT_IN_TELEGRAM_MINIAPP: toast вместо alert() в TestViewPage (3 места) Достижения: - achievements_queue_overwrite_loses_new_items: функциональный update очереди (useAchievements.ts) - achievements_reset_does_not_clear_timeout: clearTimeout в reset (useAchievements.ts) Аудит v2: Issue #4, frontend 7/14 задач
This commit is contained in:
@@ -30,6 +30,8 @@ const FlashcardsPage: React.FC = () => {
|
||||
const { activeAchievement, showAchievement } = useAchievements();
|
||||
const isMountedRef = useRef(true);
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
// 🔧 ФИКС (24.09.2026): URL_LEAK_FLASHCARDS — храним URL для revoke.
|
||||
const audioUrlRef = useRef<string | null>(null);
|
||||
|
||||
const brandColor = '#2ECC71';
|
||||
const textColor = '#1A1A2E';
|
||||
@@ -82,6 +84,12 @@ const FlashcardsPage: React.FC = () => {
|
||||
audioRef.current = null;
|
||||
}
|
||||
|
||||
// 🔧 ФИКС (24.09.2026): URL_LEAK_FLASHCARDS — освобождаем предыдущий URL
|
||||
if (audioUrlRef.current) {
|
||||
try { URL.revokeObjectURL(audioUrlRef.current); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
|
||||
if ('speechSynthesis' in window) {
|
||||
window.speechSynthesis.cancel();
|
||||
}
|
||||
@@ -91,15 +99,26 @@ const FlashcardsPage: React.FC = () => {
|
||||
try {
|
||||
const audioBlob = await getTTS(word, 'male');
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
audioUrlRef.current = audioUrl; // 🔧 сохраняем для revoke
|
||||
|
||||
const audio = new Audio(audioUrl);
|
||||
audioRef.current = audio;
|
||||
|
||||
audio.onended = () => {
|
||||
if (isMountedRef.current) setIsPlayingLetter(false);
|
||||
// 🔧 ФИКС (24.09.2026): освобождаем URL после воспроизведения
|
||||
if (audioUrlRef.current === audioUrl) {
|
||||
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
};
|
||||
|
||||
audio.onerror = () => {
|
||||
// 🔧 Освобождаем URL перед fallback
|
||||
if (audioUrlRef.current === audioUrl) {
|
||||
try { URL.revokeObjectURL(audioUrl); } catch { /* ignore */ }
|
||||
audioUrlRef.current = null;
|
||||
}
|
||||
playWebSpeech(word);
|
||||
};
|
||||
|
||||
@@ -153,6 +172,11 @@ const FlashcardsPage: React.FC = () => {
|
||||
audioRef.current.pause();
|
||||
audioRef.current = null;
|
||||
}
|
||||
// 🔧 ФИКС (24.09.2026): URL_LEAK_FLASHCARDS — освобождаем URL при unmount
|
||||
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