JDK-8156982 : NPE in PrismImage.toDataURL when browsing web pages with images
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-05-14
  • Updated: 2016-05-19
  • Resolved: 2016-05-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Description
To reproduce this:

1. Run a simple WebBrowser app (e.g., WebLauncher) that does not otherwise reference javafx.scene.image.Image in the app.

2. Load: www.yahoo.com

3. Scroll around or click on a few links

4. BUG: you will eventually get the following exception:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
	at com.sun.javafx.webkit.prism.PrismImage.toDataURL(PrismImage.java:68)
	at com.sun.webkit.Timer.twkFireTimerEvent(Native Method)
	at com.sun.webkit.Timer.fireTimerEvent(Timer.java:83)
	at com.sun.webkit.Timer.notifyTick(Timer.java:64)
	at javafx.scene.web.WebEngine$PulseTimer.lambda$static$0(WebEngine.java:1201)
	at com.sun.javafx.tk.Toolkit.lambda$runPulse$3(Toolkit.java:365)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:364)
	at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:391)
	at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
	at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
	at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:319)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$8(GtkApplication.java:191)
	at java.lang.Thread.run(Thread.java:804)

Comments
Changeset: 7e06a98ddd7a Author: Chien Yang <chien.yang@oracle.com> Date: 2016-05-18 21:32 -0700 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/7e06a98ddd7a
19-05-2016

+1
18-05-2016

This simple change of force init of Image class in the init static block in the top of Toolkit class creates a circular dependency. The proper and safer fix is to remove the null assignment in the accessor declaration and move the init static block below it: http://cr.openjdk.java.net/~ckyang/JDK-8156982/webrev.02/index.html
18-05-2016

Most image-related tests fail with the .01 version of the fix.
18-05-2016

Sorry, it is likely I have fixed mine and forgot to regenerate the old webrev. I will redo a full test run before I commit if it passes your test.
17-05-2016

Code looks good, but has trailing whitespace. Testing it now.
17-05-2016

@Kevin, I misread your comment. Here is the proposed fix: http://cr.openjdk.java.net/~ckyang/JDK-8156982/webrev.01/
17-05-2016

Since init() is an abstract method in Toolkit I decided to put the foceInit() call in getToolKit() and before toolkit initialization. Please review the proposed fix: http://cr.openjdk.java.net/~ckyang/JDK-8156982/webrev.00/
16-05-2016

This was caused (or more accurately, exposed) by the fix for JDK-8155757. The Toolkit class provides a getImageAccessor method, but does not ensure that the Image class, which sets the accessor, has been loaded. The fix should be as simple as calling Utils.forceInit(.Image.class) from the static init block of Toolkit.
14-05-2016