[PATCH] wined3d: Avoid crash in swapchain_gl_present() if context could not be acquired.
gofmanp at gmail.com
Wed Nov 13 12:16:54 CST 2019
On 11/13/19 19:30, Henri Verbeet wrote:
> On Wed, 13 Nov 2019 at 19:38, Paul Gofman <gofmanp at gmail.com> wrote:
>> On 11/13/19 19:03, Henri Verbeet wrote:
>>> There are certainly cases where creating a valid OpenGL context could
>>> legitimately fail, but for those cases I'd either expect it to fail
>>> earlier during swapchain creation, or to fallback to creating a
>>> "backup window" context.
>> I managed to get some more details on that. The NULL goes from
>> wined3d_context_gl_acquire(), "Rendering onscreen" case.
>> wined3d_context_gl_init() fails with 'Failed to set pixel format 27...'.
>> This most likely happens because window is already destroyed. This
>> window and device is likely not going to be used anymore, it only needs
>> to survive the destruction without crashing the application.
> If the window is already destroyed, I'd expect the earlier GetDCEx()
> call to fail, in which case wined3d_context_gl_init() would try to
> create a backup context. We could potentially handle
> wined3d_context_gl_set_pixel_format() failures in the same way, but it
> would be good to know why that's happening first.
Yes, the window handle is actually valid, as well as dc. Yet
wined3d_context_gl_set_pixel_format() called from
wined3d_context_gl_init() fails. The failure comes from winex11.drv,
create_gl_drawable() fails through create_client_window(), which in turn
gets NULL get_win_data() and refuses to create the data here. This is
some (WS_POPUP | WS_SYSMENU) window created with 1x1 size which never
changes, and looks like it never get shown. It does not look like the
application is serious about trying to display something with it, as
nothing seems to be missing on the display, yet it create d3d11 device
there (while the game is mostly d3d9), draws a few frames and gives up.
Do you think that wined3d should try to work around any possible reason
when display driver fails to create opengl visual or can't set pixel
format for some other reason? If the context is not supposed to be NULL
in swapchain present under normal circumnstances, maybe we put ERR()
there for the time being?
More information about the wine-devel