RFR: 6531: Make the flame chart view render labels on windows
jkang at openjdk.java.net
Wed Jan 22 22:29:57 UTC 2020
On Wed, 22 Jan 2020 21:57:59 GMT, Alex Macdonald <aptmac at openjdk.org> wrote:
> This PR addresses JMC-6531 [](https://bugs.openjdk.java.net/browse/JMC-6531), in which the flame chart view displays nothing in Windows.
> tl;dr: the proposed solution uses a fork of d3-flame-graph [](https://github.com/aptmac/d3-flame-graph) which substitutes the incompatible svg element with one that works with Internet Explorer, and modifies the flameviewColoring script to work with an older ECMA version.
> Screenshot of Windows:
> For reference, here's the same view in Linux:
> When I had originally taken a look into the SWT Browser and compatibility with Windows, it looked as though we'd be able to use Edge as an embedded browser, which would be nice because it already plays nice with the d3-flame-graph library. After quite a bit of trial and error I was first able to get d3 to work (making simple line charts), and then found that d3-flame-graph version <= 2.0.2 will work. With this older version of d3-flame-graph the coloured labels will be drawn, but no text is shown - regardless of the SWT browser property being set to IE or Edge .. which makes it look like Edge can be used for visiting external webpages, but not local ones (internal browser stays IE). This is because the foreignObject element is incompatible with IE, and this has already been raised as an issue and closed as a "wontfix" by the maintainer on the upstream repo [](https://github.com/spiermar/d3-flame-graph/issues/84).
> I made a fork of the d3-flame-graph repo [](https://github.com/aptmac/d3-flame-graph), which accomplishes two things:
> - substitutes `<foreignObject>` for `<text>` [](https://github.com/aptmac/d3-flame-graph/commit/c508e2ab95de2a48f03d655d6e7f306273dcaa12#diff-e866318288d23357a14da878e2435b49L5211)
> - trims the text in the labels because the ellipsis css doesn't work [](https://github.com/aptmac/d3-flame-graph/commit/c508e2ab95de2a48f03d655d6e7f306273dcaa12#diff-e866318288d23357a14da878e2435b49R5238)
> This forked version of d3-flame-graph is downloaded by the maven-download-plugin like the other jslibs, and is used if the Environment type is `WINDOWS` as detected in `FlameGraphView.java` [](https://github.com/aptmac/jmc/commit/b64b4349057a67aeeb6b5ef560261cdb616a9d24#diff-9cb007d54dc422cf345941df647ef24cR102).
> Now that the flame chart view works at this point, I had to edit `flameviewColoring.java` to be compatible with IE. From what I can find, Internet Explorer uses JScript, which in it's latest version supports ECMA 5 [](https://en.wikipedia.org/wiki/JScript#JScript). This means no maps, no named functions, etc.
> Lastly, and not completely related to this issue, I changed the name of `page.template` to `template.html` because my IDE won't provide syntax highlighting unless the file ends with -.html, and it was a big help here. If it's deemed unecessary I can just drop the associated commit.
> Let me know what you think!
>  https://bugs.openjdk.java.net/browse/JMC-6531
>  https://github.com/aptmac/d3-flame-graph
>  https://github.com/spiermar/d3-flame-graph/issues/84
>  https://github.com/aptmac/d3-flame-graph/commit/c508e2ab95de2a48f03d655d6e7f306273dcaa12#diff-e866318288d23357a14da878e2435b49L5211
>  https://github.com/aptmac/d3-flame-graph/commit/c508e2ab95de2a48f03d655d6e7f306273dcaa12#diff-e866318288d23357a14da878e2435b49R5238
>  https://github.com/aptmac/jmc/commit/b64b4349057a67aeeb6b5ef560261cdb616a9d24#diff-9cb007d54dc422cf345941df647ef24cR102
>  https://en.wikipedia.org/wiki/JScript#JScript
The comment in the upstream d3-flame-graph suggests that there is no solution and unless someone comes up with one, nothing will change. Your commits in the fork seem to be a solution. Could that be proposed upstream? Does it introduce issues outside of IE?
More information about the jmc-dev