JDK-8223298 : SVG patterns are drawn wrong
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8,openjfx11
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • Submitted: 2019-05-02
  • Updated: 2020-04-21
  • Resolved: 2020-04-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
8u261Fixed openjfx15Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
The bug is reproduced only if the retina display is in use. So if you close the retina display and you use an external monitor, the pattern is correctly drawn.

A DESCRIPTION OF THE PROBLEM :
SVG patterns are drawn with half the expected size and with a gap between each repetition, if we are using a MacBook with a retina display and the retina display is active.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Draw an SVG object with the fill attribute assigned to a pattern, in a Mac computer with Retina display (any MacBook Pro after 2013).
The retina display must be active.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The object is drawn with a repetitive pattern with no gaps between the pattern. 

Example, if we have "O" as a pattern: 
OOOO
OOOO
OOOO

I can send for better explanation a file with a correct and a wrong plot.
ACTUAL -
The object is drawn with a repetitive pattern with half the expected size, and a gap between each pattern. 

Example, if we have "O" as a patter: 
o o o o
o o o o
o o o o

I can send for better explanation a file with a correct and a wrong plot.

---------- 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 PatternSVGTest extends Application {
    private Scene scene;
    @Override public void start(Stage stage) {
        scene = new Scene(new PatternWebSVG());
        stage.setScene(scene);
        stage.show();
    }
 
    public static void main(String[] args){
        launch(args);
    }
    
    private class PatternWebSVG extends Region {
    	 
        final WebView browser = new WebView();
        final WebEngine webEngine = browser.getEngine();
         
        public PatternWebSVG() {
            webEngine.loadContent(
            		"<!DOCTYPE html>                                                                                           " +       
            		"<html>                                                                                                    " +       
            		"<body>                                                                                                    " +       
            		"<svg height='150' width='400'>                                                                            " +       
                    "                                                                                                          " +       
            		"	<rect width='100%' height='476' x='0' y='2' fill='url(#pattern_id)'></rect>         " +       
            		"	<pattern id='pattern_id' x='0' y='0' width='30' height='30' patternUnits='userSpaceOnUse'>             " +       
            		"		<rect width='30' height='30' fill='green'></rect>                                                  " +       
            		"		<circle cx='15' cy='15' r='15' stroke='black' stroke-width='1' fill='red' />                       " +       
            		"	</pattern>                                                                                             " +       
            		"</svg>                                                                                                    " +       
            		"</body>                                                                                                   " +       
            		"</html>        		                                                                                   "
            		);
            getChildren().add(browser);
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use an external monitor instead the retina display.

FREQUENCY : always



Comments
Changeset: ec8608f3 Author: Arun Joseph <ajoseph@openjdk.org> Date: 2020-04-17 15:18:29 +0000 URL: https://git.openjdk.java.net/jfx/commit/ec8608f3
17-04-2020

Issue: Assuming the pixelScale is 2, the tile image size is doubled at the native side which is propagated to the java side as well. But, as transform initialization takes place after scaling, the scaling is removed. Fix: Override scale() method in WCBufferedContext class to call init().
08-04-2020

The bug can be reproduced in any display with pixelScale > 1.
08-04-2020