Contrary to issue description, the problem was not because we referenced a 
texture after it was freed, but we referenced an RTT that we just tried to 
allocate and failed to do so because of lack of space in Prism's vram pool. In 
case of attached `WebViewAnimationTest.java` test app, the problem exists 
because WebView tries to allocate a new RTT for newly opened WebView scene and 
the Prism pool does not have 16MB needed while previous WebView is still being 
displayed. Only after the old WebView is disposed of, then the RTT allocation 
can proceed and WebView can continue as normal.

I looked around and did not find other solution than adding the null-checks to 
silence the NPE being thrown. NPE was originally in `RTImage.java`, however 
after adding a null check there triggered another NPE in 
`WCGraphicsPrismContext.java`, so I also added another null check there. Upper 
layers of web module seem to handle those just fine, the NPEs disappeared after 
that and the test still works properly once the pool gets enough room to 
display.

All of our tests run fine with this change (I do not expect any major 
regressions, as this happens only with a very limited memory pool scenario - it 
was extremely hard and time consuming to trigger this bug on the test app with 
default 512MB pool limit). For the test app, it might take a couple frames 
until the old WebView is disposed of and there is enough room for new WebView's 
RTT in the pool, after that the scene renders properly.

-------------

Commit messages:
 - Add null checks to RTImage and WCGraphicsPrismContext

Changes: https://git.openjdk.org/jfx/pull/1590/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1590&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8333374
  Stats: 9 lines in 2 files changed: 9 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jfx/pull/1590.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1590/head:pull/1590

PR: https://git.openjdk.org/jfx/pull/1590

Reply via email to