From 2ecacf6c3ea6b558b96aac1f7a5efe0faf4c4ad3 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Wed, 23 May 2018 00:12:44 -0500 Subject: [PATCH] [RN] Fix a "TypeError: Cannot read property handlers of undefined" in ImageCache With some of the preceding commits in the "multiplying remote thumbnails" story line, I started hitting this error with 100% reproducibility: 1. Have a remote participant prepared in conferenceA. Web will do as well. 2. On iOS prepare to join conferenceB in Safari and use the same device for step 3. 3. Join conferenceA on the iOS device from step 2 with audio-only. The audio-only is so that avatars are always visible. Wait for the remote participant prepared in step 1 to appear. 4. Switch to Safari and hit "Continue in the app" to have the app leave conferenceA and join conferenceB. What happens: After the iOS device joins conferenceB in the Jitsi Meet app, the local participant is on the large video (as expected) but the avatar of the local participant is the default audo-generated auto-colored placeholder. That's because this error was hit and the avatar couldn't be "fetched". --- react/features/mobile/image-cache/middleware.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/react/features/mobile/image-cache/middleware.js b/react/features/mobile/image-cache/middleware.js index 97b207bef..dd9d18b4f 100644 --- a/react/features/mobile/image-cache/middleware.js +++ b/react/features/mobile/image-cache/middleware.js @@ -1,7 +1,6 @@ /* @flow */ import { APP_WILL_MOUNT } from '../../app'; -import { CONFERENCE_FAILED, CONFERENCE_LEFT } from '../../base/conference'; import { getAvatarURL, getLocalParticipant, @@ -37,8 +36,15 @@ const _PREFETCH_AVATAR_URLS = false; MiddlewareRegistry.register(({ getState }) => next => action => { switch (action.type) { case APP_WILL_MOUNT: - case CONFERENCE_FAILED: - case CONFERENCE_LEFT: + // XXX CONFERENCE_FAILED/LEFT are no longer used here because they + // are tricky to get right as detectors of the moments in time at which + // CachedImage is not used. Anyway, if ImageCache is to be cleared from + // time to time, SET_LOCATION_URL is a much easier detector of such + // opportune times. Fixes at least one 100%-reproducible case of + // "TypeError: Cannot read property handlers of undefined." Anyway, in + // order to reduce the re-downloading of the same avatars, eventually we + // decided to not clear during the runtime of the app (other that at the + // beginning that is). ImageCache && ImageCache.get().clear(); break;