zephyr: display: Writing too fast to SDL display with native_sim causes display to stay blank forever
Describe the bug Writing too fast to SDL display with native_sim causes display to stay blank forever. This is not a issue on device with a normal display.
To Reproduce
Attached file contains a app that reproduces the bug.
Uncommenting the sleep at the start, or adding display_blanking_on(display_device); before set format fixes the bug (display goes black instead of staying blank forever)
Expected behavior Display goes black without the sleep.
Impact Annoyance, trap if unknown.
Environment (please complete the following information):
- OS: Arch linux latest
- Toolchain: Zephyr SDK 17.0 and native toolchain
- Commit 3c2d2a6ee586f2d72d7dbb553c6fa9cecf2d6fb1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (20 by maintainers)
Yes, exactly. That’s why I don’t think it’s a thread priority issue but a bug somewhere else. Because if thread priority was the issue, the writes would all happen after main is done.
That sounds like the real issue.
Is it possible to temporarily lift thread priority by waiting on it from another higher priority thread?
It sound like there’s a synchronization missing; wherever the device gets initialized should wait until the thread has performed the SDL initialization. It should never reach
mainbefore that.That’s why I think the priority modification is just a hack; it happens to reorder actions in the correct order by accident, while the real solution would be a synchronization primitive that enforces order regardless of priority.
@faxe1008 @Finomnis I think we should just increase the default
CONFIG_SDL_DISPLAY_THREAD_PRIORITYto 0 or even to-CONFIG_NUM_COOP_PRIORITIES(Note this discussion https://github.com/zephyrproject-rtos/zephyr/pull/87883#discussion_r2023211796 )