0

I'm using expo-video library in my Expo managed RN project to create a background for one of the screens. Since it is a background, I have 10s video that I'm playing in a loop. It plays fine, however I've noticed an issue that whenever video plays from the beginning (another loop pass begins), RAM usage goes up - it looks like the video is being loaded into memory again. This of course causes RAM usage to go up indefinitely, which is concerning, even though my video is 2MB big.

I've searched basically anywhere, asked on Expo forums too but I couldn't find any similar issue.

The component for background is extremely simple, I doubt that it's configuration could be the issue:

const StyledVideo = styled(Video).attrs({
  isMuted: true,
  usePoster: true,
  isLooping: true,
  source: VIDEO_SRC, // require(<LOCAL_ASSSET>)
  posterSource: STATIC_SRC, // require(<LOCAL_ASSSET>)
  resizeMode: ResizeMode.STRETCH,
})`
  ${ratioCss};
`;

export const Background: FunctionComponent = () => {
  const [isVideoReady, setIsVideoReady] = useState<boolean>(false);

  const screenFocused = useIsFocused();
  const reduceMotion = useReducedMotionEnabled();

  return (
    <CenteringWrapper>
      <StyledVideo
        shouldPlay={screenFocused && !reduceMotion && isVideoReady}
        PosterComponent={({ source }) => <StaticBackground source={source} />}
        onReadyForDisplay={() => setIsVideoReady(true)}
      />
    </CenteringWrapper>
  );
};

I'm currently using Expo SDK 48, and expo-av 13.2.1. For now I left that as is, but it is concerning as I don't think that should happen.

Zając
  • 147
  • 1
  • 1
  • 9

0 Answers0