Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Judafa opened this issue May 9, 2024 · 5 comments · Fixed by #429
Closed

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

Judafa opened this issue May 9, 2024 · 5 comments · Fixed by #429
Labels
bug Something isn't working html-convert Related to converting to HTML slides
Milestone

Comments

@Judafa
Copy link

Judafa commented May 9, 2024

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

@Judafa Judafa added the bug Something isn't working label May 9, 2024
@Judafa
Copy link
Author

Judafa commented May 9, 2024

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.

@jeertmans
Copy link
Owner

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

@jeertmans jeertmans added the html-convert Related to converting to HTML slides label May 9, 2024
@Judafa
Copy link
Author

Judafa commented May 9, 2024

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()

jeertmans added a commit that referenced this issue May 10, 2024
Apparently, ManimCE can produce two different animations with the same name (i.e., the same hash). As documented, ManimGL would any produce files with the same name so this fix was needed.

Closes #428
@jeertmans
Copy link
Owner

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?

@jeertmans
Copy link
Owner

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.

@jeertmans jeertmans added this to the v6 milestone May 13, 2024
@jeertmans jeertmans changed the title Slides are shuffled when exporting mutliple files to revealjs format [BUG] Slides are shuffled when exporting mutliple files to revealjs format May 18, 2024
jeertmans added a commit that referenced this issue May 18, 2024
* fix(lib): prevent filename collision

Apparently, ManimCE can produce two different animations with the same name (i.e., the same hash). As documented, ManimGL would any produce files with the same name so this fix was needed.

Closes #428

* chore(lib): update comment

chore(lib): update comment

* chore(tests): add test

* chore(tests): remove redundant underscore

* chore(docs): add changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working html-convert Related to converting to HTML slides
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants