Lottie4J 1.2.7

1.2.7 Stops Doing the Same Work Every Frame

Lottie4J 1.2.7 is a performance release. While profiling a JavaFX application with an animated logo, about 80% of the JavaFX thread’s time went to one thing: decoding the same embedded PNG image over and over again, on every single frame.

Two fixes in the player:

  • Image assets are decoded once. Each LottiePlayer now caches the decoded images per asset, and preloads them all when the animation is loaded, so the first frame doesn’t stall. Assets that fail to load are cached too, so a broken image no longer logs a warning 60 times per second.
  • Cheaper track mattes. The matte renderer now reuses its off-screen canvases, snapshot images and pixel buffers between frames, and skips the pixel sampling that was only needed for debug logging.

In the profiling run, GC pauses dropped from 531 to 177 in 22 seconds, PNG decoding disappeared from the hot methods, and allocations in the matte compositing went from 30% to almost nothing. Animations with embedded images or mattes should use noticeably less CPU and battery.

The file viewer also got fixes for leaked players and bindings when loading another file, and a non-blocking shutdown of the WebView comparison. A new profiling harness in tools/profiling makes it easy to repeat these leak and threading checks.

See the full changelog for the details, or the GitHub diff between 1.2.6 and 1.2.7.