This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/302/head
in repository efl.
View the commit online.
commit 5306391aeadd33e6216ea2e4592d47384b4cfc91
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 16:29:14 2026 -0600
ecore_evas: let canvases that tick themselves leave the source alone
_ecore_evas_tick_source_find() decides what drives the animators of the
process. It counts a canvas that ticks its own window only, which is
what animator_tick_local is for, among those that need the timer: such
a canvas is never the source, so the function fell back to the timer
for it, even over a source another canvas supplies or one that the
application chose. Nothing made a canvas like that other than the X11
present window, which hides the problem behind its have_x test; the
offscreen canvas of the gl_drm engine is about to be the second, and
has no such cover.
The function now ignores those canvases. When none of the canvases
left has a say, it gives the source back to the timer if it was this
function that made it custom, which it remembers, and leaves it alone
if the application chose it. The first part matters because the
function is run both when a canvas registers (_ecore_evas_register())
and when one that has animator functions is freed (_ecore_evas_free()):
when a Wayland or ecore_evas_drm_new() window goes while others only
tick themselves, or when none is left, the animators must go back to
the timer as they did, and not freeze on a custom source that nothing
ticks.
A canvas that ticks itself only has no say in the source, so neither
its registering nor its being freed can change what is found, and
neither runs the search any more. For the X11 present window, the
other canvas like that, this is the same as before: registering it
never changed anything, since its own driver makes have_x true, and
freeing it gave the same result as before except that freeing the last
one used to hand a custom source chosen by the application back to the
timer, and no longer does.
The combinations, with S a canvas that supplies the source, B one that
cannot (a buffer canvas), L one that ticks itself only; before is the
previous code:
- S alone registered: custom, as before.
- S with L registered: custom; before, the timer, since L counted as a
canvas that needs it.
- B registered, with or without S or L: timer, as before, whatever the
application chose.
- L alone registered: untouched; before, the timer.
- S freed with L left, or alone: timer, as before.
- B freed with only L left: untouched, and so the timer that B forced
stays; before, the timer.
- A source the application chose, only L around, L registered or
freed: untouched; before, the timer. With a B around the timer is
forced as before, by B.
- L and have_x: untouched, as before.
Changing this function is why it is its own commit.
No headless backend supplies a source, so the free path of a real
windowing canvas cannot run in the test suite. The tests here give
buffer canvases animator functions and the flag of a canvas that ticks
itself only, once the canvas is registered, so the register path never
sees them and only the free path does; the register path of a canvas
like that runs in the tests of the offscreen canvas, which need a GPU.
They fail with the previous code, with a version that only returns early
when nothing has a say, and without the two guards.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/lib/ecore_evas/ecore_evas.c | 43 +++++++--
src/tests/ecore/ecore_test_ecore_evas.c | 162 ++++++++++++++++++++++++++++++++
2 files changed, 196 insertions(+), 9 deletions(-)
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index 41522282bf..68bf2ea254 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -3199,18 +3199,35 @@ _ecore_evas_custom_tick_end(void *data EINA_UNUSED)
ecore_evas_tick_end(ee);
}
+// The source of the animators was made custom by _ecore_evas_tick_source_find()
+// and not by the application, which makes it the one that gives it back
+static Eina_Bool _ecore_evas_tick_source_custom = EINA_FALSE;
+
+static void
+_ecore_evas_tick_source_timer_set(void)
+{
+ ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
+ ecore_animator_custom_source_tick_end_callback_set(NULL, NULL);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ _ecore_evas_tick_source_custom = EINA_FALSE;
+}
+
static void
_ecore_evas_tick_source_find(void)
{
Ecore_Evas *ee;
Eina_Bool source = EINA_FALSE;
Eina_Bool have_x = EINA_FALSE;
+ Eina_Bool have_say = EINA_FALSE;
// Check if we do have a potential tick source for legacy
EINA_INLIST_FOREACH(ecore_evases, ee)
{
if (!ee->deleted)
{
+ // One that ticks its own window only has no say in the source
+ if (!ee->animator_tick_local)
+ have_say = EINA_TRUE;
if (_ecore_evas_is_global_tick_source(ee))
source = EINA_TRUE;
if (ee->driver)
@@ -3222,12 +3239,22 @@ _ecore_evas_tick_source_find(void)
}
}
+ if (!have_say)
+ {
+ // Nothing left that has a say: what this function made is given
+ // back, and what the application chose is not ours to change
+ if (_ecore_evas_tick_source_custom && !have_x)
+ _ecore_evas_tick_source_timer_set();
+ return;
+ }
+
// If just one source require fallback, we can't be sure that
// we are not running enlightenment and that this source might
// actually be the true tick source of all other window. In
// that scenario, we have to forcefully fallback.
EINA_INLIST_FOREACH(ecore_evases, ee)
- if (!ee->deleted && !_ecore_evas_is_global_tick_source(ee))
+ if (!ee->deleted && !ee->animator_tick_local &&
+ !_ecore_evas_is_global_tick_source(ee))
{
source = EINA_FALSE;
break;
@@ -3235,12 +3262,7 @@ _ecore_evas_tick_source_find(void)
if (!source)
{
- if (!have_x)
- {
- ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
- ecore_animator_custom_source_tick_end_callback_set(NULL, NULL);
- ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
- }
+ if (!have_x) _ecore_evas_tick_source_timer_set();
}
else
{
@@ -3249,6 +3271,7 @@ _ecore_evas_tick_source_find(void)
ecore_animator_custom_source_tick_begin_callback_set(_ecore_evas_custom_tick_begin, NULL);
ecore_animator_custom_source_tick_end_callback_set(_ecore_evas_custom_tick_end, NULL);
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+ _ecore_evas_tick_source_custom = EINA_TRUE;
}
}
@@ -3364,7 +3387,9 @@ _ecore_evas_register(Ecore_Evas *ee)
_ecore_evas_register_animators(ee);
- _ecore_evas_tick_source_find();
+ // One that ticks its own window only has no say in the source: it
+ // cannot change what is found by coming or going
+ if (!ee->animator_tick_local) _ecore_evas_tick_source_find();
if (_ecore_evas_render_sync) ee->first_frame = EINA_TRUE;
if (!ee->engine.func->fn_render)
evas_event_callback_priority_add(ee->evas, EVAS_CALLBACK_RENDER_POST, EVAS_CALLBACK_PRIORITY_AFTER,
@@ -3437,7 +3462,7 @@ _ecore_evas_free(Ecore_Evas *ee)
{
// Backend support per window vsync
ee->engine.func->fn_animator_unregister(ee);
- _ecore_evas_tick_source_find();
+ if (!ee->animator_tick_local) _ecore_evas_tick_source_find();
}
ee->animator_count = 0;
diff --git a/src/tests/ecore/ecore_test_ecore_evas.c b/src/tests/ecore/ecore_test_ecore_evas.c
index 9728ce61d1..60b75b4831 100644
--- a/src/tests/ecore/ecore_test_ecore_evas.c
+++ b/src/tests/ecore/ecore_test_ecore_evas.c
@@ -158,10 +158,172 @@ EFL_START_TEST(ecore_test_ecore_evas_buffer_resize_async)
}
EFL_END_TEST
+/* No backend that runs headless has animator functions of its own, which
+ * the choice of the source of the animators is about: a buffer canvas that
+ * is given some stands for one, a window system canvas that supplies the
+ * source or one that ticks its own window only. */
+typedef struct
+{
+ Ecore_Evas *ee;
+ Ecore_Evas_Engine_Func func;
+} Fake_Canvas;
+
+static void
+_fake_animator_function(Ecore_Evas *ee EINA_UNUSED)
+{
+}
+
+static void
+_fake_animator_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+}
+
+static void
+_fake_canvas_new(Fake_Canvas *fake, Eina_Bool local)
+{
+ fake->ee = ecore_evas_buffer_new(WINDOW_WIDTH, WINDOW_HEIGHT);
+ fail_if(fake->ee == NULL);
+
+ fake->func = *fake->ee->engine.func;
+ fake->func.fn_animator_register = _fake_animator_function;
+ fake->func.fn_animator_unregister = _fake_animator_function;
+ fake->ee->engine.func = &fake->func;
+ fake->ee->animator_tick_local = local;
+
+ /* Something animates on it, which is what makes freeing it look at the
+ * source again */
+ efl_event_callback_add(ecore_evas_get(fake->ee),
+ EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK,
+ _fake_animator_cb, NULL);
+}
+
+// The source that this made custom is given back when the last canvas that
+// has a say in it goes, whatever the ones that tick themselves only do.
+EFL_START_TEST(ecore_test_ecore_evas_tick_source_given_back)
+{
+ Fake_Canvas local, other, source;
+
+ fail_if(ecore_evas_init() == 0);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+
+ _fake_canvas_new(&local, EINA_TRUE);
+ _fake_canvas_new(&other, EINA_FALSE);
+ _fake_canvas_new(&source, EINA_FALSE);
+
+ // The canvas that goes sees to it that the source is looked for again:
+ // another canvas supplies it, and the one that ticks itself does not
+ // matter.
+ ecore_evas_free(other.ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ ecore_evas_free(source.ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+
+ ecore_evas_free(local.ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+
+ fail_if(ecore_evas_shutdown() != 0);
+}
+EFL_END_TEST
+
+// What the application chose is not given back, nor taken, by canvases that
+// tick themselves only.
+EFL_START_TEST(ecore_test_ecore_evas_tick_source_application_kept)
+{
+ Fake_Canvas local, other;
+
+ fail_if(ecore_evas_init() == 0);
+
+ _fake_canvas_new(&local, EINA_TRUE);
+ _fake_canvas_new(&other, EINA_TRUE);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ ecore_evas_free(other.ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+ ecore_evas_free(local.ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ fail_if(ecore_evas_shutdown() != 0);
+}
+EFL_END_TEST
+
+static unsigned int _custom_ticks_begun = 0;
+
+static void
+_custom_tick_begin(void *data EINA_UNUSED)
+{
+ _custom_ticks_begun++;
+}
+
+static Eina_Bool
+_custom_animator_cb(void *data EINA_UNUSED)
+{
+ return ECORE_CALLBACK_CANCEL;
+}
+
+// A source that the application chose, with ticks of its own, is not
+// touched by a canvas that ticks itself only going, whatever other canvas
+// is there: it has no say, so its going cannot change what is found.
+EFL_START_TEST(ecore_test_ecore_evas_tick_source_local_freed)
+{
+ Fake_Canvas local;
+ Ecore_Evas *buffer;
+ Ecore_Animator *animator;
+
+ fail_if(ecore_evas_init() == 0);
+
+ _fake_canvas_new(&local, EINA_TRUE);
+ buffer = ecore_evas_buffer_new(WINDOW_WIDTH, WINDOW_HEIGHT);
+ fail_if(buffer == NULL);
+
+ _custom_ticks_begun = 0;
+ ecore_animator_custom_source_tick_begin_callback_set(_custom_tick_begin, NULL);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ ecore_evas_free(local.ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_CUSTOM);
+
+ // Its ticks are still the application's
+ animator = ecore_animator_add(_custom_animator_cb, NULL);
+ ck_assert_uint_eq(_custom_ticks_begun, 1);
+ ecore_animator_del(animator);
+
+ ecore_evas_free(buffer);
+ ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
+ fail_if(ecore_evas_shutdown() != 0);
+}
+EFL_END_TEST
+
+// A canvas with nothing of its own to tick with still needs the timer, over
+// what the application chose, as before.
+EFL_START_TEST(ecore_test_ecore_evas_tick_source_timer_forced)
+{
+ Ecore_Evas *ee;
+
+ fail_if(ecore_evas_init() == 0);
+
+ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
+ ee = ecore_evas_buffer_new(WINDOW_WIDTH, WINDOW_HEIGHT);
+ fail_if(ee == NULL);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+
+ ecore_evas_free(ee);
+ ck_assert_int_eq(ecore_animator_source_get(), ECORE_ANIMATOR_SOURCE_TIMER);
+
+ fail_if(ecore_evas_shutdown() != 0);
+}
+EFL_END_TEST
+
void ecore_test_ecore_evas(TCase *tc)
{
tcase_add_test(tc, ecore_test_ecore_evas_associate);
tcase_add_test(tc, ecore_test_ecore_evas_cocoa);
tcase_add_test(tc, ecore_test_ecore_evas_fallback_selection);
tcase_add_test(tc, ecore_test_ecore_evas_buffer_resize_async);
+ tcase_add_test(tc, ecore_test_ecore_evas_tick_source_given_back);
+ tcase_add_test(tc, ecore_test_ecore_evas_tick_source_application_kept);
+ tcase_add_test(tc, ecore_test_ecore_evas_tick_source_local_freed);
+ tcase_add_test(tc, ecore_test_ecore_evas_tick_source_timer_forced);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.