Social media giant https://help.pinterest.com/en/guide/all-about-pinterest improved Android video performance by optimizing warm-ups, configurations, and player pooling with a few simple steps, according to a recent blog post from company engineers. Engineers of the site consider their work a “never-ending” investigation into the inner workings of https://github.com/google/ExoPlayer, their preferred application-level media player for Android.
ExoPlayer’s default is to parse the video URL to: calculate the aspect ratio invoke on onContentAspectRarioChanged() inform the AspectRatioFrameLayout of the aspect ratio. Since most of the video’s aspect ratios are pre-determined, the following functions can prevent that work from happening: setting the video aspect ratio via AspectRatioFrameLayout.setAspectRatio()
This callback informed Pinterest when it was time to clear out their player cache pool when they got close to sending OOMs.