After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 753891 - animation: Use Tweener to animate instead of a timeout
animation: Use Tweener to animate instead of a timeout
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2015-08-20 17:23 UTC by Rui Matos
Modified: 2016-01-19 08:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
animation: Use Tweener to animate instead of a timeout (3.06 KB, patch)
2015-08-20 17:23 UTC, Rui Matos
rejected Details | Review
native: block main loop if on another VT (4.04 KB, patch)
2015-08-20 19:09 UTC, Ray Strode [halfline]
rejected Details | Review
authPrompt: stop spinner after its hidden (3.84 KB, patch)
2015-08-21 14:16 UTC, Ray Strode [halfline]
committed Details | Review
authPrompt: hide/stop spinner after verfiication completes (2.81 KB, patch)
2015-08-31 19:24 UTC, Ray Strode [halfline]
committed Details | Review

Description Rui Matos 2015-08-20 17:23:28 UTC
aruiz pointed out on IRC that gdm's gnome-shell was constantly burning
a bit of CPU.

As far as I can tell (using gdb) this is was the only timeout causing
mainloop wakeups. In particular it was the js/gdm/authPrompt.js
instance because this._spinner.stop() is itself called from a Tweener
onComplete() handler which isn't reached before the VT switch to the
user session and thus never happens (actually it does if you VT switch
back to gdm).
Comment 1 Rui Matos 2015-08-20 17:23:34 UTC
Created attachment 309755 [details] [review]
animation: Use Tweener to animate instead of a timeout

This way, if the clutter master clock is frozen, perhaps because we're
VT switched away, we won't needlessly run the animation.
Comment 2 Ray Strode [halfline] 2015-08-20 17:45:09 UTC
Review of attachment 309755 [details] [review]:

So i don't think the below is going to work generally.  Two possible ideas: 1) use imports.misc.loginManager to detect vt switch and stop the spinner 2) add a signal to clutter master clock to emit when it's freezing and stop the spinner then

::: js/ui/animation.js
@@ +45,3 @@
+    _tween: function() {
+        this._lastFrameTime = GLib.get_monotonic_time() / 1000.0;
+        Tweener.addTween(this.actor,

this is going to break spinners in a VM (or remote connection) where animations are disabled.
Comment 3 Ray Strode [halfline] 2015-08-20 17:49:20 UTC
or maybe 2) could be generalized to complete all pending tweens before freezing the clock ?
Comment 4 Jasper St. Pierre (not reading bugmail) 2015-08-20 17:53:56 UTC
(In reply to Ray Strode [halfline] from comment #2)
> ::: js/ui/animation.js
> @@ +45,3 @@
> +    _tween: function() {
> +        this._lastFrameTime = GLib.get_monotonic_time() / 1000.0;
> +        Tweener.addTween(this.actor,
> 
> this is going to break spinners in a VM (or remote connection) where
> animations are disabled.

And this matches what GTK+ does as well. We want the "disable animations" button to disable animations.
Comment 5 Ray Strode [halfline] 2015-08-20 17:56:48 UTC
so there's no frontend api to ClutterMasterClock, so the signal can actually just go in mutter right before we pause it, here:

static void•
session_pause (void)•
{•
  clutter_evdev_release_devices ();•
  clutter_egl_freeze_master_clock ();•
}•
Comment 6 Ray Strode [halfline] 2015-08-20 17:57:12 UTC
no, spinners shouldn't get disabled when animations are disabled.  it's a bug that that happens in gtk.
Comment 7 Jasper St. Pierre (not reading bugmail) 2015-08-20 17:59:30 UTC
Are you sure about that? I thought it was intentional that we disabled animations when the "disable animations" button was pressed.

Anyway, there is a front-end API to ClutterMasterClock -- it's ClutterTimeline. You can use that to tick independently.
Comment 8 Ray Strode [halfline] 2015-08-20 18:07:08 UTC
Yea, I really don't think we should be disabling "functional" animations.  Only big animations that cause a lot of screen flicker and are primarily provided for transition aesthetics.  You can drop the latter without taking functionality away.

ClutterTimeline isn't going to help us here, unless we adopt it more completely (see the code in comment 5, it's using master clock backend api).
Comment 9 Ray Strode [halfline] 2015-08-20 18:10:18 UTC
to give a concrete example of what i mean...right now the timed login animation uses tweener, so if you turn on timed login in a vm, it logs you in immediately.  That animation shouldn't get disabled.
Comment 10 Ray Strode [halfline] 2015-08-20 18:34:49 UTC
we could also be really heavy handed and make session_pause() block until sd_login_monitor says the session is active again.
Comment 11 Ray Strode [halfline] 2015-08-20 19:09:15 UTC
Created attachment 309764 [details] [review]
native: block main loop if on another VT

If we're not visible, there's little reason to dispatch events.
We try to avoid drawing by freezing the master clock, but it's
easy for a stray g_timeout_add to keep running anyway.

This commit makes us block the main loop wholesale, which is closer
to how we behave on X11 (which blocks the main loop waiting on the
glx lock).
Comment 12 Ray Strode [halfline] 2015-08-20 19:11:40 UTC
so attachment 309764 [details] [review] comes with a few caveats:

1) I haven't tested it (yet)
2) the code could be cleaned up more (we're still freezing the master clock, when we probably don't need to anymore, we're monitoring for vt switches in two different ways, etc)
3) i'm not sure if doing this heavy handed of an approach is a good idea or not.

i'm mainly posting it for feedback, at this point.
Comment 13 Ray Strode [halfline] 2015-08-20 19:12:54 UTC
Review of attachment 309764 [details] [review]:

::: src/backends/native/meta-launcher.c
@@ +150,3 @@
+        }
+
+      is_active = ret;

this needs a if (is_active) break;
Comment 14 Jasper St. Pierre (not reading bugmail) 2015-08-20 19:39:46 UTC
Review of attachment 309764 [details] [review]:

This is absolutely broken. We can't do this.
Comment 15 Ray Strode [halfline] 2015-08-20 19:42:45 UTC
> This is absolutely broken. We can't do this.
so you think it's a bad idea, and I'm on the fence, but it's not absolutely broken. it's pretty equivalent to how X11 behaves, which was status quo for a very long time.
Comment 16 Jasper St. Pierre (not reading bugmail) 2015-08-20 20:16:22 UTC
Wayland clients might crash if the compositor is blocked and doesn't respond in time. Xwayland crashing would take the session down.

We used to do something similar (run a blocking nested main loop when switched away) until being VT switched away for a minute meant Xwayland wouldn't get a response, crash, and then mutter responds by taking down its session as well.
Comment 17 Ray Strode [halfline] 2015-08-20 20:55:01 UTC
(In reply to Jasper St. Pierre from comment #16)
> We used to do something similar (run a blocking nested main loop when
> switched away) until being VT switched away for a minute meant Xwayland
> wouldn't get a response, crash, and then mutter responds by taking down its
> session as well.
did Xwayland get fixed to not crash?
Comment 18 Jasper St. Pierre (not reading bugmail) 2015-08-20 20:57:35 UTC
Nope, but any client can crash when the client buffer is full. We need to make sure to always be parsing client messages, even when VT switched away.
Comment 19 Ray Strode [halfline] 2015-08-21 12:42:41 UTC
okay you've convinced me, unless we blocked all the clients too, blocking just the compositor isn't a good idea. let's just abandon that idea.
Comment 20 Ray Strode [halfline] 2015-08-21 12:54:10 UTC
so maybe we're going about this the wrong way...  instead of stopping the spinner in response to the vt change, why not stop the spinner before telling gdm to change vts?

Solving the more general problems related to the master clock are fine, but it's a bigger task and I guess it isn't really necessary for solving this bug.
Comment 21 Ray Strode [halfline] 2015-08-21 14:15:51 UTC
so I found one problem in the code that I think fixing, might help with this problem. Unfortunately, when I try to reproduce the problem I can't...  my login screen gnome-shell is stuck at 0% cpu. if i strace it, it wakes up once every several seconds, not several times every second. hmmm will post the patch anyway, but we probably shouldn't commit it until we can get a better handle on the situation.
Comment 22 Ray Strode [halfline] 2015-08-21 14:16:17 UTC
Created attachment 309821 [details] [review]
authPrompt: stop spinner after its hidden

The code previously tried to stop spinner after it was hidden, but
due to an incorrect check was only stoppig it after it was shown.

Also, it was only stopping after hiding due to an animation, and
failing to stop it in the non-animated case.

This left the spinner hidden and running while VT switched away
from the login screen, only stopping when the auth prompt was
reset when switching back.
Comment 23 Ray Strode [halfline] 2015-08-21 14:27:26 UTC
(no idea if attachment 309821 [details] [review] is sufficient to fix the problem)
Comment 24 Rui Matos 2015-08-31 12:42:54 UTC
Review of attachment 309821 [details] [review]:

This makes sense in itself but doesn't fix the original issue of the spinner not stopping after a successful log in.

Adding a this.stopSpinning() call to _onVerificationComplete() seems to fix it and seems like the right thing to do since all other userVerifier signal handlers except this one end up calling reset() or clear() which does stopSpinning()
Comment 25 Matthias Clasen 2015-08-31 18:18:59 UTC
Do we have a committable fix here ?
Comment 26 Ray Strode [halfline] 2015-08-31 19:24:10 UTC
yup, i'll just push the two changes talked about here (well s/stopSpinning/setDefaultActorInButtonWell(null)/)
Comment 27 Ray Strode [halfline] 2015-08-31 19:24:31 UTC
Created attachment 310378 [details] [review]
authPrompt: hide/stop spinner after verfiication completes

When the user successfully types their password, we should hide
the spinner from the button well right away, so it doesn't
consume resources until reset (which may happen significantly later
if the user is vt switched away)
Comment 28 Ray Strode [halfline] 2015-08-31 19:25:00 UTC
Attachment 309821 [details] pushed as 030a22d - authPrompt: stop spinner after its hidden
Attachment 310378 [details] pushed as f2d4aa0 - authPrompt: hide/stop spinner after verfiication completes
Comment 29 Rui Matos 2015-09-01 11:25:08 UTC
Comment on attachment 309755 [details] [review]
animation: Use Tweener to animate instead of a timeout

This isn't needed
Comment 30 Rui Matos 2015-09-01 11:25:23 UTC
I think we're done here.
Comment 31 Hussam Al-Tayeb 2015-10-02 11:46:06 UTC
Hello, this may be causing bug 754814 which somehow pauses logging in until the user presses Escape key on his/her keyboard.
Comment 32 Hussam Al-Tayeb 2016-01-11 08:51:50 UTC
Hi. I think this isn't really fixed.
I have to ctrl+alt+f1 then ctrl+alt+f2 back to my session to stop the gdm version of gnome-shell from constantly eating 20% CPU. This is very rough on my core2duo 2.9GHz processor with nvidia GPU.
I am working around this by using autologin. It would be however nice if I didn't have to.
Comment 33 Ray Strode [halfline] 2016-01-11 15:30:51 UTC
Probably because of 

bug 754814 comment 66

so we're not getting verification-complete signal anymore at login time so attachment 310378 [details] [review] isn't effective.
Comment 34 Ray Strode [halfline] 2016-01-11 15:31:32 UTC
I need to see if i can reproduce grawity's crasher and then add the gdm patch back.
Comment 35 Hussam Al-Tayeb 2016-01-19 08:48:11 UTC
(In reply to Ray Strode [halfline] from comment #34)
> I need to see if i can reproduce grawity's crasher and then add the gdm
> patch back.

I just reapplied the patch to 3.18.2 and restarted gdm.
No crashes on unlock with normal logon. I tried both unlocking from ctrl+alt+f1 (greeter session) and ctrl+alt+f2 (my session).
Then re-enabled auto-login and still unlocking works so this covers all cases.
But I am using Nvidia.
Maybe it now crashes on non-nvidia for grawity haha.
Comment 36 Hussam Al-Tayeb 2016-01-19 08:49:27 UTC
And more importantly, it got rid of the constant 20% CPU on gdm's version of gnome-shell.