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

always_redraw works in 0.18.0 but not in 0.18.1 (single ValueTracker) #3762

Open
fierval opened this issue May 15, 2024 · 5 comments
Open

always_redraw works in 0.18.0 but not in 0.18.1 (single ValueTracker) #3762

fierval opened this issue May 15, 2024 · 5 comments

Comments

@fierval
Copy link

fierval commented May 15, 2024

Description of bug / unexpected behavior

The following code which does not work in 0.18.1 and is fine on 0.17.3:

for i, idx_r in enumerate(r_idxs):

    r = points[idx_r]

    if i == 0:
        track_pt = PointValueTracker(r)

        # lines denoting the prq angle
        pr = always_redraw(lambda: Line(p, track_pt.get_value(), color=YELLOW, buff=0))
        qr = always_redraw(lambda: Line(q, track_pt.get_value(), color=YELLOW, buff=0))
        grp = VGroup(pr, qr)

        self.play(LaggedStartMap(Create, grp, runtime=2, lag_ratio=0.2))

    # move the point of two "angle" lines along the line
    # connecting points[idx_r] and points[idx_r + 1]
    if i < len(r_idxs) - 1:
        r_next = points[r_idxs[i + 1]]
        self.play(track_pt.animate.set_value(r_next))

System specifications

System Details
  • OS Windows11:
  • RAM: 128 Gb
  • Python version (python/py/python3 --version): 3.10.12
  • Installed modules (provide output from pip [list):](url)
PASTE HERE

correct.mp4 and wrong.mp4 show the porblem at 15 sec

correct.mp4
wrong.mp4
@behackl
Copy link
Member

behackl commented May 16, 2024

Please provide a self-contained (minimal) example that illustrates the problem. I can't run the snippet you have posted.

@fierval fierval changed the title always_redraw works in 0.17.3 but not in 0.18.1 (single ValueTracker) always_redraw works in 0.18.0 but not in 0.18.1 (single ValueTracker) May 18, 2024
@fierval
Copy link
Author

fierval commented May 18, 2024

The bug is actually present in 0.18.1 only. 0.18.0 works fine.

From the repo: https://github.com/fierval/beta-skeleton

Run:

python concept.py

@behackl
Copy link
Member

behackl commented May 18, 2024

While I can now theoretically run the snippet, I'd like to avoid digging through a custom Scene class and a medium-sized animation. Can you help us narrow the problem down, can it be isolated to appear with the default Scene class with a short construct method that has at most 1-2 play calls?

@fierval
Copy link
Author

fierval commented May 20, 2024

I have simplified the file in the repo (https://github.com/fierval/beta-skeleton) as you requested and also here is the gist, with the bug identified.

It looks like the LaggedStartMap applied to the VGroup causes problems for the value tracker down the line. Replacing this LaggedStartMap with simple Create works fine. Not a problem for 0.18.0 or below.

@behackl
Copy link
Member

behackl commented May 20, 2024

Thanks, this has made it easier -- although, just for the record, a "minimal example" with 105 subanimations isn't really minimal at all; what I've been looking for is more along the lines of

from manim import *

class BugReport(Scene):
    def construct(self):
        lines = VGroup()
        end_tracker = ValueTracker(0)
        for start in [LEFT*2 + DOWN, RIGHT*2 + DOWN]:
            moving_line = always_redraw(lambda start=start: Line(start, end_tracker.get_value() * RIGHT))
            lines.add(moving_line)

        self.play(LaggedStartMap(Create, lines, lag_ratio=0.5))
        self.play(end_tracker.animate.set_value(2))

In any case, this bug was introduced with #3542; we'll investigate. In the meantime, you can simply add grp.resume_updating() after playing the LaggedStartMap as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants