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 755357 - timeline: Minor fixes for debuggability with ClutterMasterClockGdk
timeline: Minor fixes for debuggability with ClutterMasterClockGdk
Status: RESOLVED FIXED
Product: clutter
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: clutter-maint
clutter-maint
Depends on:
Blocks:
 
 
Reported: 2015-09-21 16:02 UTC by Philip Withnall
Modified: 2015-09-22 18:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
timeline: Ensure waiting_first_tick is set before adding the timeline (1.12 KB, patch)
2015-09-21 16:02 UTC, Philip Withnall
committed Details | Review
timeline: Add more debug output (2.23 KB, patch)
2015-09-21 16:02 UTC, Philip Withnall
committed Details | Review
gdk: Enable clock updates when timelines are added to the clock (3.53 KB, patch)
2015-09-21 16:02 UTC, Philip Withnall
none Details | Review
gdk: Use frame time when calculating the tick time for clock updates (1.14 KB, patch)
2015-09-21 16:02 UTC, Philip Withnall
committed Details | Review
gdk: Fix frame budget diagnostics (1.13 KB, patch)
2015-09-21 16:03 UTC, Philip Withnall
committed Details | Review
gdk: Enable clock updates when timelines are added to the clock (3.53 KB, patch)
2015-09-21 17:16 UTC, Philip Withnall
none Details | Review
gdk: Enable clock updates when timelines are added to the clock (4.47 KB, patch)
2015-09-21 19:32 UTC, Lionel Landwerlin
committed Details | Review
Here’s another version of my approach which fixes the warnings from examples/actor-model. It doesn’t use GObject data like Lionel’s approach. The problem was that clutter_master_clock_gdk_remove_timeline() was not checking whether the given timeline (3.61 KB, patch)
2015-09-22 10:27 UTC, Philip Withnall
none Details | Review

Description Philip Withnall 2015-09-21 16:02:37 UTC
Here are a few small fixes I made in the course of debugging a ClutterTimeline problem with MX (it turned out MX was causing one frame to take 400ms due to emitting ::style-changed on thousands of widgets). This wasn’t immediately obvious, and so I added some more debug output to ClutterTimeline.

Since my understanding of ClutterMasterClock is somewhat limited, some of these fixes (such as using gdk_frame_clock_get_frame_time()) might not be correct, so close review is needed.
Comment 1 Philip Withnall 2015-09-21 16:02:45 UTC
Created attachment 311770 [details] [review]
timeline: Ensure waiting_first_tick is set before adding the timeline

Just in case the timeline starts being prodded by the ClutterMasterClock
before the add function returns. (This has not been verified.)
Comment 2 Philip Withnall 2015-09-21 16:02:49 UTC
Created attachment 311771 [details] [review]
timeline: Add more debug output
Comment 3 Philip Withnall 2015-09-21 16:02:53 UTC
Created attachment 311772 [details] [review]
gdk: Enable clock updates when timelines are added to the clock

Enable animation updates from the GdkFrameClock whenever any timeline is
added to the ClutterMasterClockGdk. This may improve animation
smoothness (depending on the GDK backend in use) because it allows GDK
to tweak its frame timing for animation purposes.
Comment 4 Philip Withnall 2015-09-21 16:02:58 UTC
Created attachment 311773 [details] [review]
gdk: Use frame time when calculating the tick time for clock updates

This is how GdkFrameClock is meant to be used: the frame time is meant
to be queried from the GdkFrameClock within its frame signals, rather
from the system monotonic time source.
Comment 5 Philip Withnall 2015-09-21 16:03:02 UTC
Created attachment 311774 [details] [review]
gdk: Fix frame budget diagnostics

Set the frame budget so that CLUTTER_ENABLE_DIAGNOSTIC correctly outputs
timing diagnostics from the ClutterMasterClockGdk.
Comment 6 Emmanuele Bassi (:ebassi) 2015-09-21 16:11:02 UTC
Review of attachment 311770 [details] [review]:

Sure, this makes sense.
Comment 7 Emmanuele Bassi (:ebassi) 2015-09-21 16:11:30 UTC
Review of attachment 311771 [details] [review]:

Sure.
Comment 8 Emmanuele Bassi (:ebassi) 2015-09-21 16:22:41 UTC
Review of attachment 311772 [details] [review]:

This patch generates a warning:

Gdk-CRITICAL **: gdk_frame_clock_idle_end_updating: assertion 'priv->updating_count > 0' failed

Simply test with examples/actor-model.

::: clutter/gdk/clutter-master-clock-gdk.c
@@ +303,3 @@
+  /* Finish updating for each timeline in progress. */
+  for (l = master_clock->timelines; l != NULL; l = l->next)
+    gdk_frame_clock_begin_updating (frame_clock);

If this is 'Finish updating', shouldn't it be calling gdk_frame_clock_end_updating()?
Comment 9 Emmanuele Bassi (:ebassi) 2015-09-21 16:23:05 UTC
Review of attachment 311773 [details] [review]:

Yes, that's a good point.
Comment 10 Emmanuele Bassi (:ebassi) 2015-09-21 16:23:24 UTC
Review of attachment 311774 [details] [review]:

Sure.
Comment 11 Philip Withnall 2015-09-21 17:13:26 UTC
Attachment 311770 [details] pushed as ae1a848 - timeline: Ensure waiting_first_tick is set before adding the timeline
Attachment 311771 [details] pushed as 5545b69 - timeline: Add more debug output
Attachment 311773 [details] pushed as 9e8da64 - gdk: Use frame time when calculating the tick time for clock updates
Attachment 311774 [details] pushed as 3816d5a - gdk: Fix frame budget diagnostics
Comment 12 Philip Withnall 2015-09-21 17:16:27 UTC
Created attachment 311782 [details] [review]
gdk: Enable clock updates when timelines are added to the clock

Enable animation updates from the GdkFrameClock whenever any timeline is
added to the ClutterMasterClockGdk. This may improve animation
smoothness (depending on the GDK backend in use) because it allows GDK
to tweak its frame timing for animation purposes.

---

> ::: clutter/gdk/clutter-master-clock-gdk.c
> @@ +303,3 @@
> +  /* Finish updating for each timeline in progress. */
> +  for (l = master_clock->timelines; l != NULL; l = l->next)
> +    gdk_frame_clock_begin_updating (frame_clock);
> 
> If this is 'Finish updating', shouldn't it be calling gdk_frame_clock_end_updating()?

Indeed. :-(

Fixed, and examples/actor-model seems to work now.
Comment 13 Emmanuele Bassi (:ebassi) 2015-09-21 17:19:07 UTC
Review of attachment 311782 [details] [review]:

Nope, still getting a warning.

You need to press 'Enter' to enable the "activate" animation; at the end of the transition, you'll get a warning.
Comment 14 Lionel Landwerlin 2015-09-21 19:32:48 UTC
Created attachment 311803 [details] [review]
gdk: Enable clock updates when timelines are added to the clock

Enable animation updates from the GdkFrameClock whenever any timeline is
added to the ClutterMasterClockGdk. This may improve animation
smoothness (depending on the GDK backend in use) because it allows GDK
to tweak its frame timing for animation purposes.
Comment 15 Lionel Landwerlin 2015-09-21 19:34:24 UTC
Hope you don't mind, trying to improve upon Philip's attempt.
It's obviously a bit tricky. We need to keep track of the number of begin/end we submit to the GdkFrameClock.
Comment 16 Philip Withnall 2015-09-22 10:27:12 UTC
Created attachment 311844 [details] [review]
Here’s another version of my approach which fixes the warnings from examples/actor-model. It doesn’t use GObject data like Lionel’s approach. The problem was that clutter_master_clock_gdk_remove_timeline() was not checking whether the given timeline

gdk: Enable clock updates when timelines are added to the clock

Enable animation updates from the GdkFrameClock whenever any timeline is
added to the ClutterMasterClockGdk. This may improve animation
smoothness (depending on the GDK backend in use) because it allows GDK
to tweak its frame timing for animation purposes.
Comment 17 Philip Withnall 2015-09-22 10:28:59 UTC
(In reply to Lionel Landwerlin from comment #15)
> Hope you don't mind, trying to improve upon Philip's attempt.
> It's obviously a bit tricky. We need to keep track of the number of
> begin/end we submit to the GdkFrameClock.

I don’t mind at all, but I think it should be possible to track the number of begins/ends implicitly using the lists of timelines, which was what I was originally trying (and failing) to achieve. How does the new version look? :-)
Comment 18 Lionel Landwerlin 2015-09-22 10:47:03 UTC
Review of attachment 311844 [details] [review]:

I don't think that will work.
Let's say you have 2 stages relying on the same frame clock (basically 2 embed stages within the same GdkWindow).

- You start with no timelines.
- You add one stage -> no begin_updating() is called because no timeline
- You add a second stage -> still no begin_updating()
- You add one timeline -> begin_updating() is called once because the 2 stages share the same frame clock
- You remove a stage -> end_updating() is called once because 1 timeline
- You remove the other stage -> end_updating() is called once

begin_updating count = 1
end_updating count = 2
Comment 19 Philip Withnall 2015-09-22 13:51:06 UTC
(In reply to Lionel Landwerlin from comment #18)
> Review of attachment 311844 [details] [review] [review]:
> 
> I don't think that will work.
> Let's say you have 2 stages relying on the same frame clock (basically 2
> embed stages within the same GdkWindow).
> 
> - You start with no timelines.
> - You add one stage -> no begin_updating() is called because no timeline
> - You add a second stage -> still no begin_updating()
> - You add one timeline -> begin_updating() is called once because the 2
> stages share the same frame clock
> - You remove a stage -> end_updating() is called once because 1 timeline
> - You remove the other stage -> end_updating() is called once
> 
> begin_updating count = 1
> end_updating count = 2

Good point. Let’s go with your patch.
Comment 20 Lionel Landwerlin 2015-09-22 16:48:40 UTC
Review of attachment 311803 [details] [review]:

Pushed to master.
Comment 21 Philip Withnall 2015-09-22 18:08:32 UTC
Fixed then, I guess.