0

I have written a JavaFx Application(JDK 8), which parses a private format XML (XML contains all of the Shape attributes such as coordinate, size, fill, stroke and so on) to construct a scene graph with about 4000-5000 Nodes layout according to their coordinate in the SubScene.

Every time I open a new private XML, the new SubScene needs 2-3 second lagged to show in my screen.

I tried "-Djavafx.pulseLogger=true" in VM argument,and show the logger below, but I do not know how to optimize the show time. I tried to force the node parent Group with no layout pass, but the time till very big. I also read the articles abort how to optimise the performance abort Javafx, but I still cannot fixed the lag performance correct.

PULSE: 637 [570ms:1701ms]
T37 (-570 +570ms): Layout Pass
T37 (0 +484ms): CSS Pass
T37 (484 +9ms): Layout Pass
T37 (493 +4ms): Update bounds
T37 (498 +0ms): Waiting for previous rendering
T37 (498 +16ms): Copy state to render graph
T30 (515 +0ms): Dirty Opts Computed
T30 : 2 different dirty regions to render
T30 : Dirty Region 0: RectBounds { minX:406.0, minY:23.0, maxX:440.0, maxY:38.0} (w:34.0, h:15.0)
T30 : Render Root Path 0: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5812bf43, com.sun.javafx.sg.prism.NGRegion@78dbaadd, com.sun.javafx.sg.prism.NGRegion@4a9171aa, com.sun.javafx.sg.prism.NGRegion@1bb83d84, com.sun.javafx.sg.prism.NGRegion@1486dde6]
T30 : Dirty Region 1: RectBounds { minX:0.0, minY:69.0, maxX:1904.0, maxY:1006.0} (w:1904.0, h:937.0)
T30 : Render Root Path 1: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@1cdbe0a1]
T30 (515 +0ms): Render Roots Discovered
T30 : Slow background path for null
T30 (515 +0ms): Painting
T30 : Slow shape path for null
T30 (515 +1185ms): Painting
T30 (1700 +0ms): Presenting
Counters:
    CacheFilter rebuilding: 1
    Cached region shape image used: 3
    NGRegion renderBackgroundShape slow path: 1
    NGRegion renderBackgrounds slow path: 1
    Nodes rendered: 5384
    Nodes visited during render: 7917
    Rendering region shape image to cache: 1


PULSE: 638 [1499ms:241ms]
T37 (0 +0ms): CSS Pass
T37 (0 +5ms): Layout Pass
T37 (6 +1ms): Update bounds
T37 (7 +195ms): Waiting for previous rendering
T37 (202 +0ms): Copy state to render graph
T30 (202 +0ms): Dirty Opts Computed
T30 : 4 different dirty regions to render
T30 : Dirty Region 0: RectBounds { minX:6.0, minY:1010.0, maxX:142.0, maxY:1037.0} (w:136.0, h:27.0)
T30 : Render Root Path 0: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5aeb10ed, com.sun.javafx.sg.prism.NGRegion@1e40ff4a]
T30 : Dirty Region 1: RectBounds { minX:294.0, minY:1012.0, maxX:444.0, maxY:1035.0} (w:150.0, h:23.0)
T30 : Render Root Path 1: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5aeb10ed, com.sun.javafx.sg.prism.NGRegion@1e40ff4a]
T30 : Dirty Region 2: RectBounds { minX:470.0, minY:1012.0, maxX:534.0, maxY:1035.0} (w:64.0, h:23.0)
T30 : Render Root Path 2: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5aeb10ed, com.sun.javafx.sg.prism.NGRegion@1e40ff4a]
T30 : Dirty Region 3: RectBounds { minX:6.0, minY:70.0, maxX:128.0, maxY:95.0} (w:122.0, h:25.0)
T30 : Render Root Path 3: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@1cdbe0a1, com.sun.javafx.sg.prism.NGRegion@479f54bb, com.sun.javafx.sg.prism.NGRegion@107cfd69]
T30 (203 +0ms): Render Roots Discovered
T30 : Slow background path for null
T30 : Slow background path for null
T30 (203 +15ms): Painting
T30 (218 +0ms): Painting
T30 (218 +0ms): Painting
T30 (218 +1ms): Painting
T30 (219 +22ms): Presenting
Counters:
    Cached region shape image used: 3
    NGRegion renderBackgrounds slow path: 2
    Nodes rendered: 42
    Nodes visited during render: 94
Picture MMI Requset Time Register=  local 275  Tue Jun 12 11:46:49 CST 2018


PULSE: 639 [909ms:159ms]
T37 (0 +0ms): CSS Pass
T37 (0 +0ms): Layout Pass
T37 (1 +1ms): Update bounds
T37 (2 +0ms): Waiting for previous rendering
T37 (2 +0ms): Copy state to render graph
T30 (2 +0ms): Dirty Opts Computed
T30 : 4 different dirty regions to render
T30 : Dirty Region 0: RectBounds { minX:6.0, minY:1010.0, maxX:142.0, maxY:1037.0} (w:136.0, h:27.0)
T30 : Render Root Path 0: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5aeb10ed, com.sun.javafx.sg.prism.NGRegion@1e40ff4a]
T30 : Dirty Region 1: RectBounds { minX:294.0, minY:1012.0, maxX:444.0, maxY:1035.0} (w:150.0, h:23.0)
T30 : Render Root Path 1: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5aeb10ed, com.sun.javafx.sg.prism.NGRegion@1e40ff4a]
T30 : Dirty Region 2: RectBounds { minX:470.0, minY:1012.0, maxX:534.0, maxY:1035.0} (w:64.0, h:23.0)
T30 : Render Root Path 2: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@5aeb10ed, com.sun.javafx.sg.prism.NGRegion@1e40ff4a]
T30 : Dirty Region 3: RectBounds { minX:1.0, minY:96.0, maxX:1903.0, maxY:1005.0} (w:1902.0, h:909.0)
T30 : Render Root Path 3: [com.sun.javafx.sg.prism.NGGroup@2734b5a6, com.sun.javafx.sg.prism.NGRegion@2c4e529a, com.sun.javafx.sg.prism.NGRegion@1cdbe0a1, com.sun.javafx.sg.prism.NGRegion@4c1f5ed1, com.sun.javafx.sg.prism.NGRegion@48f39e62]
T30 (2 +0ms): Render Roots Discovered
T30 : Slow background path for null
T30 : Slow background path for null
T30 (2 +0ms): Painting
T30 (3 +0ms): Painting
T30 (3 +0ms): Painting
T30 (3 +155ms): Painting
T30 (158 +0ms): Presenting
Counters:
    CacheFilter rebuilding: 1
    NGRegion renderBackgrounds slow path: 2
    Nodes rendered: 5419
    Nodes visited during render: 7994
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
KaLa
  • 21
  • 5
  • You could try using the [Marlin renderer](https://github.com/bourgesl/marlin-fx) and see if it helps - supposedly it can increase performance quite a bit in some cases. I believe in newer versions of JavaFX (10 or 11 IIRC) it is included by default. – Itai Jun 12 '18 at 10:55
  • Are you loading the xml on the application thread? IO usually can be considered a long-running operation. If this is done on the application thread it may not be the rendering that takes that long but your xml loading blocking the application thread preventing it from doing the layout. Try reading the xml in a `Task` and attach your results to the scene on success... – fabian Jun 12 '18 at 12:43
  • @fabian You are right,I had loading the xml in FXThread.I put it in a Task.And it seems a little better. – KaLa Jun 12 '18 at 13:20

1 Answers1

0

I had loading the xml in FXThread.I put it in a Task.And it seems a little better,But till a little lag when I open a new XML in Task.Below is the pulse logger.

PULSE: 1620 [16ms:676ms]
T16 (-15 +16ms): Layout Pass
T16 (0 +308ms): CSS Pass
T16 (308 +6ms): Layout Pass
T16 (315 +4ms): Update bounds
T16 (320 +0ms): Waiting for previous rendering
T16 (320 +23ms): Copy state to render graph
T13 (343 +0ms): Dirty Opts Computed
T13 : 2 different dirty regions to render
T13 : Dirty Region 0: RectBounds { minX:406.0, minY:22.0, maxX:440.0, maxY:38.0} (w:34.0, h:16.0)
T13 : Render Root Path 0: [com.sun.javafx.sg.prism.NGGroup@4f54e04e, com.sun.javafx.sg.prism.NGRegion@4b1b2a7e, com.sun.javafx.sg.prism.NGRegion@a8df84, com.sun.javafx.sg.prism.NGRegion@4f89e98d, com.sun.javafx.sg.prism.NGRegion@1192367, com.sun.javafx.sg.prism.NGRegion@17791b79, com.sun.javafx.sg.prism.NGRegion@51ebb2ed]
T13 : Dirty Region 1: RectBounds { minX:0.0, minY:64.0, maxX:1267.0, maxY:650.0} (w:1267.0, h:586.0)
T13 : Render Root Path 1: [com.sun.javafx.sg.prism.NGGroup@4f54e04e]
T13 (344 +0ms): Render Roots Discovered
T13 : Slow background path for null
T13 (344 +0ms): Painting
T13 : Slow background path for null
T13 (344 +331ms): Painting
T13 (676 +0ms): Presenting
Counters:
    CacheFilter rebuilding: 1
    NGRegion renderBackgrounds slow path: 2
    Nodes rendered: 4523
    Nodes visited during render: 6733


PULSE: 1621 [352ms:351ms]
T16 (0 +0ms): CSS Pass
T16 (0 +0ms): Layout Pass
T16 (0 +1ms): Update bounds
T16 (2 +322ms): Waiting for previous rendering
T16 (324 +0ms): Copy state to render graph
T13 (324 +0ms): Dirty Opts Computed
T13 : 1 different dirty regions to render
T13 : Dirty Region 0: RectBounds { minX:5.0, minY:69.0, maxX:130.0, maxY:95.0} (w:125.0, h:26.0)
T13 : Render Root Path 0: [com.sun.javafx.sg.prism.NGGroup@4f54e04e, com.sun.javafx.sg.prism.NGRegion@4b1b2a7e, com.sun.javafx.sg.prism.NGRegion@1bb5992b, com.sun.javafx.sg.prism.NGRegion@76a3f03, com.sun.javafx.sg.prism.NGRegion@42e2bd5f]
T13 (324 +0ms): Render Roots Discovered
T13 : Slow background path for null
T13 : Slow shape path for null
T13 : Slow shape path for null
T13 (325 +4ms): Painting
T13 (329 +22ms): Presenting
Counters:
    NGRegion renderBackgroundShape slow path: 2
    NGRegion renderBackgrounds slow path: 1
    Nodes rendered: 12
    Nodes visited during render: 13

[1622 335ms:16ms][1623 15ms:0ms][1624 0ms:0ms]
KaLa
  • 21
  • 5