thomasp85/gganimate

Rendering split animations hangs

py9mrg opened this issue · 1 comments

Hello,

I am using split_animation to split an animation up and I've noticed that anim_save or even just printing seem to hang when not using default options. I've even left it overnight and it never finished.

Using all the default settings works fine:

library(tidyverse)
library(gganimate)

data <- tibble(
  x = rep(1:100, 3),
  y = 1:300,
  category = c(rep("A", 100), rep("B", 100), rep("C", 100))
)

p <- ggplot(data, aes(x, y, colour = category)) +
  geom_point(size = 12) +
  transition_reveal(x, keep_last = FALSE)

anim_reveal <- animate(p,
                       renderer = gifski_renderer(loop = FALSE))

split_anim <- split_animation(anim_reveal, by = frame_along < 50)

anim_save("~/split1.gif", split_anim$`FALSE`)

However, if I now change some rendering options to make it a little more taxing then it never finishes.

# initial rendering is fine (as is saving the whole animation with anim_save)
anim_reveal <- animate(p, width = 2888, height = 2166, units = "px",
                       renderer = gifski_renderer(loop = FALSE))

# splitting works ok, if slow
split_anim <- split_animation(anim_reveal, by = frame_along < 50)

# but trying to save or print the split animation will cause a hang
# don't run these lines or you will need to force interrupt R for either of them
# anim_save("~/split2.gif", split_anim$`FALSE`)
# split_anim$`FALSE`

If I do the same as above but do the splitting manually and then render/save using gifski directly it works fine again (and the splitting is much faster):

split_anim <- frame_vars(anim_reveal)[frame_vars(anim_reveal)$frame_along < 50,]$frame_source

gifski::gifski(split_anim, "~/split3.gif", width = 2888, height = 2166, delay = 1/10, loop = FALSE)

Not sure what's happening sorry, but thought I better raise an issue.

This seems to be an issue with magick/ImageMagick when handling larger gif files.

Currently magick is used for splitting, but I may have to revisit that