-
Notifications
You must be signed in to change notification settings - Fork 7.3k
display: Writing too fast to SDL display with native_sim causes display to stay blank forever #88818
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
Comments
Applying this patch:
And running without the sleep:
vs. running with sleep:
So from what I see the main difference is that the thread starts later. The issue seems to be that the SDL thread is not started unless the main thread is blocked for a short period. |
Does @faxe1008's PR fix your issue? |
Is this a thread priority issue? Does the SDL thread have a lower priority than main? |
No it does not fix the issue, note this is happening with all color schemes, not just L8 (it was just what i was using when i hit this, i also tried rgb 565) Would system configuration be relevant? I'm using sdl2-compat with SDL3 for sdl. |
The other way around: |
ah mb i thought it was centered on 50 for some reason. |
@faxe1008 @Finomnis I think we should just increase the default |
How about |
It does not, it starts working with |
While this feels like a fix for you, I suspect it's actually more of a workaround. Why would the display thread not run at all, even at lower priority? I mean, if the main thread has a higher priority than the display thread (which is sane imo, display usually is less real time critical than the actual control logic of a system), then of course the display thread does not do anything while main is active. I do not consider this a bug. On the other hand, if you have the display thread be a very high priority, maybe even a coop priority, then every other task, no matter how low its own priority is, has the ability to schedule high priority work through the display API. This is not really good for the reliability of an RTOS imo, but maybe that last point is incorrect. If someone else has thinks my opinion is wrong here, feel free to tell me why. |
Negatory, sleeping or yielding in main thread does not cause display to update when main is done, |
Or put differently, device_is_ready is false because it is not okay to write to display and breaks the display when done, but true is returned anyway. |
Actually it doesnt update there either with -1 priority, only when main thread is exited. Edit: that applies witrhout the PR, with the PR the sleep and yield work without exiting main thread when setting priority to 0 or -1. |
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 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. |
Yes the issue is that the display drivers thread needs to run at least once before reaching the main. |
Well you can wait with a semaphore or similar inside of the driver init, until the initialization is finished. |
Adjusted the PR, with all the changes. |
@VynDragon Does the new version of #88886 fix your problem? |
yes it does. |
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):
zephyr_sdl_native_sim_race.tar.gz
The text was updated successfully, but these errors were encountered: