RFR: JDK-8283401: ArrayIndexOutOfBoundsException when disconnecting screen(s)
Kevin Rushforth
kcr at openjdk.org
Fri Aug 11 21:08:29 UTC 2023
On Sat, 5 Aug 2023 13:00:36 GMT, Marius Hanl <mhanl at openjdk.org> wrote:
> When the `D3DPipeline` is reinitialized, the adapter ordinal of all the `Screen`s are outdated.
> As a consequence, when a `D3DResourceFactory` is created for a `Screen` (adapter ordinal), the code may fail with an `ArrayIndexOutOfBoundsException` as the ordinal is higher than what we would expect it to be.
>
> Example:
> We have 3 screens. Adapter ordinal 0, 1, 2.
> If we now disconnect 2 screens, we only have one screen left.
> The `D3DPipeline` is reinitialized as a [D3DERR_DEVICEREMOVED](https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3derr) is reported from Direct3d9.
> Now the remaining screen may have the adapter ordinal 1 (from before). But since we only have 1 screen left, it should have the adapter ordinal 0.
>
> Direct3d9 will also return 0 as adapter ordinal if you call it. And that is what we do to update the `Screen` and fix this problem.
>
> See also the ticket for information how to reproduce this problem (Windows only).
The code change looks good.
I am not able to provoke the bug, but I did test it enough to validate the logic, by simulating device lost and verifying that the adapter ordinals are all reinitialized correctly.
-------------
Marked as reviewed by kcr (Lead).
PR Review: https://git.openjdk.org/jfx/pull/1200#pullrequestreview-1574361625
More information about the openjfx-dev
mailing list