shbatm / MMM-Carousel

Displays a single magic mirror module at a time, rotating through the list of configured modules in a carousel-like fashion.
MIT License
42 stars 14 forks source link

Please make the animation time a parameter, it has a big performance impact for me #4

Closed Txukie closed 6 years ago

Txukie commented 6 years ago

Hi, I have noticed how this module has a big performance hit when transitioning from one slide to another, when the fade-in/fade-out occurs. I use RPi3 Model B and yet I see CPU usage skyrockets when the animation occurs. I fix this by manually editing MMM-Carousel.js and setting the 1500 ms to 0: line 169: this[i].show(0, {lockString: "mmmc"}); line 178: this[i].show(0, {lockString: "mmmc"}); line 205: this[i].show(0, {lockString: "mmmc"});

IMHO this should be a parameter (or maybe several, not really sure).

shbatm commented 6 years ago

Done. This has been added to the wip branch for now. Please test before I migrate to the master branch.

Parameter name: slideTransitionSpeed, Default: 1500 (ms), Add slideTransitionSpeed: 0, to your config.js to disable transition effects when showing a module.

To switch to the wip branch:

cd ~/MagicMirror/modules/MMM-Carousel
git checkout wip
git pull
# Restart or refresh MM
Txukie commented 6 years ago

Ok, tested it and it works. Thanks a lot for that.

Could you please tell me what each line determines? I think that one defines fade-in and another one defines fade-out, but I'm not sure which one does what.

shbatm commented 6 years ago

They are all the animation time it takes to "show" a particular module. Just three different places in the conditionals. The "hide" animation time is set to 0 always.

For each "transition", this module loops through MM's list of all modules and calls the module.show() function on that module.

L169 -- 'global' or 'positional' mode, individual modules are cycled and module should be shown (in scope) for that index. L178 -- 'slides' mode where the slide is given as a string only. L205 -- 'slides' mode where the slide is given as an object with advanced properties (handled after things like moving the module or changing the classes)

Modules that are "out-of-scope" for a particular transition are hidden at lines L211 or L214.

Txukie commented 6 years ago

Ok thanks for the info.

TheBogueRat commented 6 years ago

Your performance issue may be with the version of Electron. This thread discusses that issue and the latest MagicMirror source reverted to an older version of Electron partially because of this issue. The transitions look great on my RasPi 3 B after I tracked down this solution.

Txukie commented 6 years ago

It sure sounds like it. I will try to look into it. Thanks.