I forgot to add the picture of the screen when the bug happens.
This is the screenshot of step 5
0_1629056297913_core2bug1.jpg
it seems like a part of M5Img (in a rectangle (35,132, 274,16) is written back onto the text.
and this is the screenshot of the code above (right after calling lcd.rect(...) )
0_1629056411470_core2bug2.jpg
and the rectangle (35,132,274,16) is overwritten with the background.
when you use M5Img instead of screen.set_screen_bg_color, you will see a part of the image instead of the background.
in both screenshots, text must be shown without a black/yellow rectangle.