jeertmans/manim-slides

[BUG] Slides are shuffled when exporting mutliple files to revealjs format

Closed this issue · 5 comments

Description

Hello everyone!

As the "default" gui is not working properly for me (black screen at the end of each slides, due to this bug of pyside #293 ), I'm planning on using revealjs instead.

Following the doc, I'm using the convert command and can thus successfully convert one slide.
The problem comes when I try to gather mutliple slides into one .html file. For that, as the doc suggests, I'm using:

manim-slides convert Scene1 Scene2 ... Scene 15

I would like the slides to be simply "concatenated": first show me Scene1, then Scene2, etc.
Unfortunately, the result is an unordered mixture of everything; in my case, exerpts of Scene2 appears in Scene3 and it's like that all along.

I strangely did not see this issue reported anywhere else; maybe I'm doing something wrong here.

Version

manim-slides, version 5.1.7

Platform

Linux, ArcoLinux

Screenshots

No response

Additional information

No response

Wait, now that I run my manim codes with the command line (manim-slides render file.py Scene), it works.

I used to run my manim codes with tempconfig code snippet at the end of the file such as:
with tempconfig(
{
"quality": "high_quality",
"preview": False,
"disable_caching": True,
"save_last_frame": False,
}):
scene = Scene()
scene.render()

which somehow seems to wreck havoc in the produced files.

Hello @Judafa, do you have a minimal working examples that I could easily test locally?

Yes, here are two files:
In an empty directory containing only those two files, I did:

  1. run file slide_1.py
  2. run file slide_2.py
  3. enter command "manim-slides convert Slide1 Slide2 test.html"

The first slide always has "Slide 1" written, for the second it's always "Slide 2".
I obtain a shuffled pres where at least two excerpts of Slide1 are into Slide2.

slide_1.py:

from manim import *
from manim_slides import *


class Slide1(Slide):
    def construct(self):

        ### Display title
        title = Text("Slide 1").shift(3 * UP)
        self.play(
            Write(title),
        )

        ### Next slide
        self.next_slide()

        self.play(
            Write(Text(f"Some text {1}").shift(1.5 * UP))
        )

        # Create a rectangle
        switch = Rectangle(height=2, width=3, color=BLUE, fill_color=BLACK, fill_opacity=1)


        self.play(
            Create(switch),
        )

        ### Next slide
        self.next_slide()
        self.play(
            Write(Text(f"Some text {2}").shift(1.5 * UP + 1 * DOWN))
        )




        ### Next slide
        self.next_slide()
        self.play(
            Write(Text(f"Some text {3}").shift(1.5 * UP + 2 * DOWN))
        )

        ### Next slide
        self.next_slide()
        self.play(
            *[FadeOut(mob) for mob in self.mobjects]
        )

        ### Next slide
        self.next_slide()


# To create the video at scrip run
with tempconfig(
        {
        "quality": "low_quality",
        "preview": False,
        "disable_caching": True,
        "save_last_frame": False,
        }):
    scene = Slide1()
    scene.render()

and slide_2.py:

from manim import *
from manim_slides import *


class Slide2(Slide):
    def construct(self):

        # Write the title 2
        title = Text("Slide 2").shift(3 * UP)
        self.play(
            Write(title)
        )


        text1 = Tex("Some text 1").shift(1.5 * UP)
        text2 = Tex("Some text 2").shift(0.5 * UP)
        text3 = Tex("Some text 3").shift(-0.5 * UP)

        self.next_slide()
        self.play(
            Write(text1)
        )

        self.next_slide()
        self.play(
            Write(text2)
        )

        self.next_slide()
        self.play(
            Write(text3)
        )

        # Remove all mobject
        self.next_slide()
        self.play(
            *[FadeOut(mob) for mob in self.mobjects]
        )


# To create the video at scrip run
with tempconfig(
        {
        "quality": "low_quality",
        "preview": False,
        "disable_caching": True,
        "save_last_frame": False,
        }):
    scene = Slide2()
    scene.render()

Ok so this is actually a very interesting bug you found!

Apparently, Manim can produce different animations with the same hash... I'll report this issue to their repo, but I already created a PR that fixes your issue, see #429.

Would you mind testing it?

Ohhh Ok this is not really a bug from Manim, but, when disable_caching is set to True, Manim uses index-based filenames, e.g., uncached_000x.mp4, which would anyway collide.