Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(reactions): prevent Android OOM from repeated animated node creation

Calin-Teodor003412518088
diff --git a/react/features/reactions/components/native/ReactionEmoji.tsx b/react/features/reactions/components/native/ReactionEmoji.tsx
index 0db935b2b6..7276436ba2 100644
--- a/react/features/reactions/components/native/ReactionEmoji.tsx
+++ b/react/features/reactions/components/native/ReactionEmoji.tsx
@@ -60,6 +60,32 @@ function ReactionEmoji({ reaction, uid, index }: IProps) {
}, [ animationVal ]);
+ // Memoized to avoid recreating interpolation nodes on every re-render.
+ const animatedStyle = useMemo(() => ({
+ transform: [
+ { translateY: animationVal.interpolate({
+ inputRange: [ 0, 0.70, 0.75, 1 ],
+ outputRange: [ 0, coordinates.topY * vh, coordinates.topY * vh, coordinates.bottomY * vh ]
+ })
+ }, {
+ translateX: animationVal.interpolate({
+ inputRange: [ 0, 0.70, 0.75, 1 ],
+ outputRange: [ 0, coordinates.topX, coordinates.topX,
+ coordinates.topX < 0 ? -coordinates.bottomX : coordinates.bottomX ]
+ })
+ }, {
+ scale: animationVal.interpolate({
+ inputRange: [ 0, 0.70, 0.75, 1 ],
+ outputRange: [ 0.6, 1.5, 1.5, 1 ]
+ })
+ }
+ ],
+ opacity: animationVal.interpolate({
+ inputRange: [ 0, 0.7, 0.75, 1 ],
+ outputRange: [ 1, 1, 1, 0 ]
+ })
+ }), [ animationVal, coordinates, vh ]);
+
if (!(reaction in REACTIONS)) {
return null;
}
@@ -68,28 +94,7 @@ function ReactionEmoji({ reaction, uid, index }: IProps) {
<Animated.Text
style = {{
..._styles.emojiAnimation,
- transform: [
- { translateY: animationVal.interpolate({
- inputRange: [ 0, 0.70, 0.75, 1 ],
- outputRange: [ 0, coordinates.topY * vh, coordinates.topY * vh, coordinates.bottomY * vh ]
- })
- }, {
- translateX: animationVal.interpolate({
- inputRange: [ 0, 0.70, 0.75, 1 ],
- outputRange: [ 0, coordinates.topX, coordinates.topX,
- coordinates.topX < 0 ? -coordinates.bottomX : coordinates.bottomX ]
- })
- }, {
- scale: animationVal.interpolate({
- inputRange: [ 0, 0.70, 0.75, 1 ],
- outputRange: [ 0.6, 1.5, 1.5, 1 ]
- })
- }
- ],
- opacity: animationVal.interpolate({
- inputRange: [ 0, 0.7, 0.75, 1 ],
- outputRange: [ 1, 1, 1, 0 ]
- })
+ ...animatedStyle
}}>
{REACTIONS[reaction].emoji}
</Animated.Text>
diff --git a/react/features/reactions/constants.ts b/react/features/reactions/constants.ts
index e968556863..a115f4d19c 100644
--- a/react/features/reactions/constants.ts
+++ b/react/features/reactions/constants.ts
@@ -124,6 +124,11 @@ export interface IReactionEmojiProps {
export const SOUNDS_THRESHOLDS = [ 1, 4, 10 ];
+/**
+ * The maximum number of reactions kept in the animation queue at once.
+ */
+export const MAX_REACTIONS_QUEUE_SIZE = 50;
+
interface IReactions {
[key: string]: {
emoji: string;
diff --git a/react/features/reactions/middleware.ts b/react/features/reactions/middleware.ts
index ce753e2740..f32880941b 100644
--- a/react/features/reactions/middleware.ts
+++ b/react/features/reactions/middleware.ts
@@ -38,6 +38,7 @@ import {
import {
ENDPOINT_REACTION_NAME,
IMuteCommandAttributes,
+ MAX_REACTIONS_QUEUE_SIZE,
MUTE_REACTIONS_COMMAND,
RAISE_HAND_SOUND_ID,
REACTIONS,
@@ -150,7 +151,9 @@ MiddlewareRegistry.register((store: IStore) => (next: Function) => (action: AnyA
dispatch(playSound(`${REACTIONS[reaction.reaction].soundId}${reaction.threshold}`))
);
}
- dispatch(setReactionQueue([ ...queue, ...getReactionsWithId(reactions) ]));
+ dispatch(setReactionQueue(
+ [ ...queue, ...getReactionsWithId(reactions) ].slice(-MAX_REACTIONS_QUEUE_SIZE)
+ ));
});
break;
}