Description
LV_ASSERT_OBJ fires when performing a screen transition with delay.
What MCU/Processor/Board and compiler are you using?
Occurs on two platforms: STM32 and Qt on a Mac
What do you experience?
When a delay is used for the transition, we take the assert.
Changing the delay from 100 to 0 prevents the assert. I have not tried further variants of time or transition style.
It appears to be timing related, sometimes the example code gets through 20 cycles and sometimes just one or two.
What do you expect?
No assert.
Code to reproduce
// If 'delay' in the lv_scr_load_anim() call is 100, after some
// number of cycles (1-20 typically) this happens:
//
// Error: lv_obj_get_local_style (lv_obj.c #2927 lv_obj_get_local_style())
// Error: Invalid object (0x00000001001ECE50) (lv_debug.c #127 lv_debug_log_error())
//
// The check that fails is:
// lv_debug_check_obj_valid()
//
// And the object that is invalid is the screen being transitioned to.
//
// Setting the delay to 0 appears to fix it. (can run for thousands of cycles)
//
// Occurs on 7.7.1, although seen on earlier releases as well.
#include <stdio.h>
#include "lvgl/lvgl.h"
static void next_screen( lv_task_t *task );
lv_obj_t *make_screen( const char *name );
void ui_init(void)
{
// Make sure any printf() output gets flushed.
setvbuf( stdout, NULL, _IOLBF, 0 );
lv_task_create( next_screen, 500, LV_TASK_PRIO_MID, NULL );
}
static void next_screen( lv_task_t *task )
{
static int count;
static bool f = true;
const char *name;
if( f )
{
name = "Screen A";
f = false;
}
else
{
name = "Screen B";
f = true;
}
lv_obj_t *next = make_screen( name );
printf( "Begin %s load (%d) %p -> %p\n", name, ++count, lv_scr_act(), next );
// If 'delay' is 0 the problem goes away.
lv_scr_load_anim( next, LV_SCR_LOAD_ANIM_MOVE_TOP, 200, 100, true );
}
lv_obj_t *make_screen( const char *name )
{
lv_obj_t *screen = lv_obj_create( NULL, NULL );
lv_obj_t * btn = lv_btn_create( screen, NULL );
lv_obj_set_pos( btn, 10, 10 );
lv_obj_set_size( btn, 120, 50 );
lv_obj_t * label = lv_label_create( btn, NULL );
lv_label_set_text( label, name );
return screen;
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current issue.