| Summary: | Resize handling is not thread-safe in SDL 2 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Vladimir <libsdl-bugzilla> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED ABANDONED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Windows 7 | ||
|
Description
Vladimir
2013-03-09 05:46:05 UTC
You should pump events on the same thread that initialized video. That may fix the issue here. (In reply to comment #1) > You should pump events on the same thread that initialized video. That may > fix the issue here. I tried moving renderer initialization to the event thread. The result: With the Direct3D renderer, I'm now getting an SDL error after a resize: An SDL_RenderCopy call fails with the error "Reset(): INVALIDCALL" With the OpenGL renderer, the program immediately crashes (Access Violation) at the first renderer call in the rendering thread. I should note that I've tried doing this (initializing video in the event thread) in SDL 1.2, but ran into problems with OpenGL due to the rendering context not being associated with the right thread. Interesting, I was of the understanding that window events come in on the thread that created the window. Did you do something to make that work? What happens if you do everything on a single thread? Does it significantly affect how your application behaves with SDL 2.0? (In reply to comment #3) > Interesting, I was of the understanding that window events come in on the > thread that created the window. Did you do something to make that work? Well, the window is created in the main (event) thread. I call SDL_CreateWindow in the event thread, then SDL_CreateRenderer in the rendering thread. > What happens if you do everything on a single thread? Does it significantly > affect how your application behaves with SDL 2.0? Well, I imagine I wouldn't have any threading problems if I don't use threads, however then I'd have to give up the ability to handle events at a granularity finer than 16ms (assuming 60Hz refresh rate), which would be a step backwards from SDL 1.2. Well, so what you probably want to do is make a patch for SDL_render.c that disables the event handling, and select behavior based on a hint. If you do this you'll need to manage resetting the viewport if you need that functionality. OK, thanks! I'll get back to this when we're further in the dev process (unless someone beats me to it). FYI, another option is to make use of the event timestamp which currently records when the event is enqueued, but could be changed to record when the event was delivered by the OS. This has been a long term TODO item, but nobody has needed sub-30ms precision on the input events enough to implement it. Hello, and sorry if you're getting dozens of copies of this message by email. We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc. Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report. So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues. (please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!) Thanks, --ryan. |