On Mon, 27 Nov 2023 19:57:30 GMT, Thorsten Fischer <[email protected]> wrote:
>> I have put this in D3DContext.java (as per customer suggestion). Just
>> wondering if I should just reinitialize directly and not wait loop: in
>> testLostStateAndReset in D3DContext.java (D3DERR_DEVICEREMOVED is handled
>> further down)
>> if (hr == D3DERR_DEVICEHUNG) {
>> setLost();
>>
>> long retryMillis = TimeUnit.MINUTES.toMillis(5);
>> long sleepMillis = TimeUnit.SECONDS.toMillis(1);
>> //Is this loop necessary?
>> for (int i = 0; i < retryMillis; i += sleepMillis) {
>> int cooperativeLevel =
>> D3DResourceFactory.nTestCooperativeLevel(pContext);
>> System.err.println("Checking Cooperative Level: " +
>> cooperativeLevel);
>>
>> if (cooperativeLevel == D3D_OK) {
>> break;
>> } else {
>> try {
>> Thread.sleep(sleepMillis);
>> } catch (InterruptedException e) {
>> e.printStackTrace();
>> }
>> }
>> }
>>
>> // Reinitialize after 5 mins anyway, even if result is not OK.
>>
>> // Reinitialize the D3DPipeline. This will dispose and recreate
>> // the resource factory and context for each adapt
>> D3DPipeline.getInstance().reinitialize();
>> LOGGER.warn("Reinit after graphics hang.");
>> }
>
> Hello @mintykat , the loop is not necessary, in fact it is not recommended as
> it makes the whole application (window) unresponsive due to the Thread.sleep.
> It was just an approach to generate some debug output in order to see how the
> system and D3D is responding after the failure happens. Best is to call
> reinitialize directly after the check for the D3DERR_DEVICEHUNG error code.
>
> I'm wondering a little bit, if JavaFX may be somehow responsible for the
> crash or if its just old drivers? This fix is going to keep the application
> running, but those crashes will still happen. You said, that you can
> reproduce this error every couple of hours? If you have the capacity, maybe
> you can track down the root cause? But I guess it is not a trivial task, I
> just [found here that some
> debug.dlls](https://learn.microsoft.com/en-us/windows/win32/direct3d9/troubleshooting#debugging)
> are needed. We had this error 'only' every few days (sometimes weeks), and I
> wasn't quite motivated for such a long winding deep-dive bug hunt :)
As pointed out by @tsx84
[here](https://github.com/openjdk/jfx/pull/1199#issuecomment-1828503142): This
fix is to recover from a device hung situation but does not fix the root cause
as why did the device hung.
But the fix itself seems safe, I have no concerns about it. thanks
@kevinrushforth for waiting on me.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1199#issuecomment-1831297367