Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Give the user feedback for SVGs that take a while#1766

Merged
3b1b merged 5 commits into3b1b:masterfrom
sunkisser:SVGfeedback
Mar 28, 2022
Merged

Give the user feedback for SVGs that take a while#1766
3b1b merged 5 commits into3b1b:masterfrom
sunkisser:SVGfeedback

Conversation

@sunkisser
Copy link
Contributor

Motivation

Manim does not provide feedback to the user while processing a long-running SVG mobject.
Since manim typically runs so fast, a long-running SVG catches the user by surprise. Personally it took me a few hours to figure out that manim was not freezing, rather it was just taking a long time on a complicated SVG.

Proposed changes

This change gives the user some feedback while processing a complicated SVG.
Specifically:
If the SVG has over 100 rings to process, we display a counter to log.info once per 100 processed rings. Thus the user learns manim is working on a long-running operation.
If the SVG has under 100 rings, this change has no effect. Manim will process it quick enough.

Test

Code:
I tested with the Noto emoji - Afghan flag SVG. Here is the complete scene code, which automatically gets the SVG from the internet so no additional files are needed.
Paste into a blank _.py file and run manimgl _.py
Try it without the pull request, and it will seem that manimgl has frozen with a blank screen.
Try it with the pull request, and rest reassured manim is working.

from manimlib import *

class Flagtest(Scene):
    def construct(self):
        flag_url = "https://raw.githubusercontent.com/googlefonts/noto-emoji/main/third_party/region-flags/svg/AF.svg"
        flag_mob = SVGMobject(flag_url, svg_default = { "stroke_width": 0 } )
        flag_mob.scale( min( self.camera.frame.get_width()/flag_mob.get_width(), self.camera.frame.get_height()/flag_mob.get_height() ) )
        self.add(flag_mob)

Result:

(manimlib) sunkisser@localhost ~/manimlib $ manimgl flagtest.py
ManimGL v1.5.0
[00:30:09] INFO     Using the default configuration file, which you can modify in            config.py:265
                    `/home/sunkisser/manimlib/manim/manimlib/default_config.yml`                          
           INFO     If you want to create a local configuration file, you can create a file  config.py:266
                    named `custom_config.yml`, or run `manimgl --config`                                  
[00:30:12] INFO     Tips: You are now in the interactive mode. Now you can use the keyboard   scene.py:119
                    and the mouse to interact with the scene. Just press `q` if you want to               
                    quit.                                                                                 
           INFO     SVG triangulation: 0/753                                              space_ops.py:420
[00:30:19] INFO     SVG triangulation: 100/753                                            space_ops.py:420
[00:30:33] INFO     SVG triangulation: 200/753                                            space_ops.py:420
[00:30:53] INFO     SVG triangulation: 300/753                                            space_ops.py:420
[00:31:17] INFO     SVG triangulation: 400/753                                            space_ops.py:420
[00:31:47] INFO     SVG triangulation: 500/753                                            space_ops.py:420
[00:32:20] INFO     SVG triangulation: 600/753                                            space_ops.py:420
[00:32:57] INFO     SVG triangulation: 700/753                                            space_ops.py:420
[00:33:13] INFO     SVG triangulation: 752/753                                            space_ops.py:420

@sunkisser sunkisser requested a review from TonyCrane March 27, 2022 22:02
@TonyCrane TonyCrane requested a review from 3b1b March 28, 2022 00:06
@3b1b
Copy link
Owner

3b1b commented Mar 28, 2022

I think it would be better to use something like tqmd, which you can see imported as ProgressDisplay in scene.py, with "leave" set to false.

That way, it doesn't linger in the terminal and is more consistent with how things look in manim elsewhere.

@sunkisser
Copy link
Contributor Author

I agree that will be better, I will refactor. I will commit a change that removes these three lines of code so we get back to the beginning and from there I will add subsequent commits for the tqdm logic.

@sunkisser
Copy link
Contributor Author

Testing right now, working great. I used delay=3 so that SVGs that run instantly will not flash a progress bar. I will upload video which can take longer than the coding or testing. Guess I would be singing to the choir.

@sunkisser
Copy link
Contributor Author

flagtest.mp4

@sunkisser
Copy link
Contributor Author

flashtest.mp4

@sunkisser sunkisser requested a review from TonyCrane March 28, 2022 14:47
@3b1b 3b1b merged commit 393f77c into 3b1b:master Mar 28, 2022
@sunkisser sunkisser deleted the SVGfeedback branch March 28, 2022 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments