-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(test): fix memory leak on failed screenshot compare #9088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi 👋, thank you for your PR! We've run benchmarks in an emulated environment. Here are the results: ARM Emulated 32b - lv_conf_perf32b
Detailed Results Per Scene
ARM Emulated 64b - lv_conf_perf64b
Detailed Results Per Scene
Disclaimer: These benchmarks were run in an emulated environment using QEMU with instruction counting mode. 🤖 This comment was automatically generated by a bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
|
I wonder why the CI is failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fix memory leak paths in screenshot comparison tests when the reference image is missing or dimensions mismatch.
- Add missing lv_draw_buf_destroy(ref_draw_buf) before early returns
- Free screen buffer on dimension mismatch path to prevent leaks
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full); | ||
| lv_free(screen_buf_xrgb8888); | ||
| lv_draw_buf_destroy(ref_draw_buf); |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of write_png_file is ignored, which can mask failures to write the reference image. Consider checking the result and returning false (or logging an error) on failure, ensuring cleanup still happens.
| write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full); | |
| lv_free(screen_buf_xrgb8888); | |
| lv_draw_buf_destroy(ref_draw_buf); | |
| unsigned write_res = write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full); | |
| lv_free(screen_buf_xrgb8888); | |
| lv_draw_buf_destroy(ref_draw_buf); | |
| if(write_res) { | |
| LV_LOG_ERROR("Failed to write reference image to %s (error code: %u)", fn_ref_full, write_res); | |
| return false; | |
| } |
| LV_LOG_WARN("%s%s", fn_ref_full, " was not found, creating it now from the rendered screen"); | ||
| write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full); | ||
| lv_free(screen_buf_xrgb8888); | ||
| lv_draw_buf_destroy(ref_draw_buf); |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Cleanup logic is duplicated across early returns. Consider consolidating cleanup into a single block (e.g., a cleanup label) and using a status variable to reduce future drift when adding/removing resources.
| lv_free(screen_buf_xrgb8888); | ||
| lv_draw_buf_destroy(ref_draw_buf); |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Cleanup logic is duplicated across early returns. Consider consolidating cleanup into a single block (e.g., a cleanup label) and using a status variable to reduce future drift when adding/removing resources.
| lv_draw_buf_t * ref_draw_buf = NULL; | ||
| unsigned ref_img_width = 0; | ||
| unsigned ref_img_height = 0; | ||
| unsigned res = read_png_file(&ref_draw_buf, &ref_img_width, &ref_img_height, fn_ref_full); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we have previously discussed, this line is very suspicious. I don't understand how we actually create this lv_draw_buf_t correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we modified lodepng to work with draw_bufs.
Notes
lv_conf_template.hrun lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py(astyle v3.4.12needs to installed by runningcd scripts; ./install_astyle.sh) and follow the Code Conventions.