JDK-8215702 : SVG gradients are not rendered
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8u191,openjfx11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-12-19
  • Updated: 2020-01-31
  • Resolved: 2019-01-17
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 8 Other
8u211Fixed openjfx11.0.3Fixed
Description
ADDITIONAL SYSTEM INFORMATION :
The problem is reproduced in 1.8.0_192 version too.
This was working in 1.8.0_111 version.
Apparently, OS is not relevant, it was tested in Windows 7 - 64 with the same behaviour.


A DESCRIPTION OF THE PROBLEM :
SVG gradients are not rendered, a solid color is drawn instead the gradient.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to render any SVG gradient inside the WebView

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A gradient is rendered
ACTUAL -
A solid color is rendered

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Region;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;



public class GradientSVGTest extends Application {
    private Scene scene;
    @Override public void start(Stage stage) {
        scene = new Scene(new WebSVG());
        stage.setScene(scene);
        stage.show();
    }
 
    public static void main(String[] args){
        launch(args);
    }
}

class WebSVG extends Region {
 
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
     
    public WebSVG() {
        webEngine.loadContent(
        		"<!DOCTYPE html>                                                                           " +
        		"<html>                                                                                    " +
        		"<body>                                                                                    " +
                "                                                                                          " +
        		"<svg height='150' width='400'>                                                            " +
        		"  <defs>                                                                                  " +
        		"    <linearGradient id='grad1' x1='0%' y1='0%' x2='0%' y2='100%'>                         " +
        		"      <stop offset='0%' style='stop-color:red' />                                         " +
        		"      <stop offset='100%' style='stop-color:yellow' />                                    " +
        		"    </linearGradient>                                                                     " +
        		"  </defs>                                                                                 " +
        		"  <ellipse cx='200' cy='70' rx='85' ry='55' fill='url(#grad1)' />                         " +
        		"  Sorry, your browser does not support inline SVG.                                        " +
        		"</svg>                                                                                    " +
                "                                                                                          " +
        		"</body>                                                                                   " +
        		"</html>                                                                                   " 
        		);
        getChildren().add(browser);
 
    }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Changeset: 51364187b4e1 Author: arajkumar Date: 2019-01-17 11:56 +0530 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/51364187b4e1 8215702: SVG gradients are not rendered Reviewed-by: mbilla, kcr
17-01-2019

[~kcr] [~mbilla] Please review the following PR, https://github.com/javafxports/openjdk-jfx/pull/347
16-01-2019

Root cause: Gradient points are not mapped to the current transformation matrix. The fix was there before 606.1 upgrade, however during the merge it got missedout while incorporating the Gradient class related refactoring changes.
08-01-2019