CRASH when change screen with animation

Hi @kisvegabor , @embeddedt

Description

I am using lv_scr_load_anim() for change screen with fade animation.
When animation has done, in scr_anim_ready(), I continue to change to other screen as below illustration.

Start screen ----(anim without delay)—> A screen ----(anim with delay)—> B screen

My code is as below:
In A screen: (a_change_screen will be called from Start screen)

void a_change_screen()
{
   lv_scr_load_anim( A_screen, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, true );
}

In B screen: (this func will be called by scr_anim_ready() in lv_disp.c)

void b_change_screen()
{
   lv_scr_load_anim( B_screen, LV_SCR_LOAD_ANIM_FADE_ON, 500, 1000, true );
}

In lv_disp.c (scr_anim_ready() will be called when Start->A or A->B anim has done)

scr_anim_ready()
{
   ... // lvgl code

   if( Start->A == true )
   {
      b_change_screen()
   }
}

What Problem?

Sometimes, the anim of A->B becomes Nothing->B, and after that, application is crashed.
※ Nothing means that is not A, and anim will be fade between B and the disp->bg_color regitered in lv_disp_drv_register().
I think, When the anim of Nothing->B has done, lvgl tries to delete Nothing screen by true setting in lv_scr_load_anim(…, true) and lead to crash.

What’s wrong with doing another animation in scr_anim_ready()?

What LVGL version are you using?

LVGL 7.10.1

What have you tried so far?

After the bug happened,
I checked lv_scr_act(), d->act_scr with A screen object when register anim in lv_disp.c, lv_scr_load_anim( B_screen, … ) , , and there is no problem.

v7 is already not supported officially. Is it an option for you to update to v8?

Hi @kisvegabor

Update to v8 is not an option for my application.
if possible, could you support me below question?

I saw v8, when screen transtion with animation has done, SCREEN_LOADED event will be sent. And this event has not in v7.
But both of version, in scr_anim_ready(), I call an app function which continue to transit screen by lv_scr_load_anim( next_screen, FADE, 500, 1000, true ), is there any problem with this?

I can help to debug it, but please send a minimal code to reproduce the issue. E.g. have 3 screens, each screen with a label like “Screen1”.

Can you updated to v7.11? It’s backward compatible with v7.10.

Hi,

I haven’t tested the code yet, but I see that you have modified lv_disp.c. In general it’s not advised.

If your goal is to loop among the screens you can create an lv_timer e.g with 2000 ms period time and load the next screen on each timer call without any delay.

Hi @kisvegabor

Few days ago, I tested with lv_timer, and this bug did not occur.
If modification in lv_disp.c is not good, could you tell me how to know the timing when screen animation finished without using lv_timer?

My goal as your said, but there is another, that is after screen animation has done, the animation of other objects ( such as arc, bar ) in screen will be run.

If I use lv_timer to recognize the end of screen animation, is it OK?
I am afraid that lv_timer and screen animation time are not match, then lv_timer will run callback before the end of screen animation.

You can also set a delay for the animation which animates the objects of the screen. E.g. if the screen load animation takes 500 ms, you can deal all animation with 500 ms.

Hi @kisvegabor

It’s a good ideal, I will try.

But there are 2 questions, could you help me?

and

For ex,
image

There is no such event in v7 :frowning: It solved by LV_EVENT_SCREEN_LOADED event in v8. To solve it your really need to modify lv_disp.c to fire an event when the screen anim is ready.

1 Like