Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide regl-based traces in the strict bundle #6083

Merged
merged 56 commits into from Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3b4bbc3
automated codegen
yujin-wu Jan 13, 2022
c5624ee
uncommitted generated traces
yujin-wu Jan 14, 2022
e958fe8
added strict version of parcoords, scattergl and splom traces, and in…
yujin-wu Jan 14, 2022
c9bcfb2
undo changes to dist
yujin-wu Jan 19, 2022
ac4f861
added draftlogs entry
yujin-wu Jan 19, 2022
aec12ef
removed unused code in codegen tooling, and made it auto exit when co…
yujin-wu Jan 19, 2022
2c8f7c4
handle updated regl cache mechanism
yujin-wu Jan 26, 2022
ebd90d5
referenced regl from github PR
yujin-wu Jan 27, 2022
8fbcf15
updated CONTRIBUTING with instructions for npm run regl-codegen
yujin-wu Jan 27, 2022
6748211
added link to codegen location in CONTRIBUTING.md
yujin-wu Jan 27, 2022
8ef4309
clarified some workding in CONTRIBUTING.md
yujin-wu Jan 27, 2022
2ab5976
fixed package lock
yujin-wu Jan 27, 2022
b137e09
.
yujin-wu Jan 28, 2022
ddf40e1
try with regl that has bumped gl to 4.9.2
yujin-wu Jan 29, 2022
4fcf623
used hash of custom regl instead of branch name
yujin-wu Feb 7, 2022
4c03bb8
Revert "used hash of custom regl instead of branch name"
yujin-wu Feb 8, 2022
bb6bdac
used hash of custom regl instead of branch name
yujin-wu Feb 8, 2022
45be643
try node 12 npm 6 and restored reg (oops)
yujin-wu Feb 10, 2022
b1b2866
try installing python2.7 first
yujin-wu Feb 10, 2022
7589382
.
yujin-wu Feb 10, 2022
9be5d47
[temporary] try without npm ls
yujin-wu Feb 10, 2022
1ce2919
switched main dev node version from 16 to 12
yujin-wu Feb 10, 2022
eb6835b
"
yujin-wu Feb 10, 2022
99bfd0f
updated to regl commit with updated dist
yujin-wu Feb 10, 2022
2022609
changed tests to nodev12, fixed package-lock sha
yujin-wu Feb 10, 2022
eaf95a6
corrected package lock and package
yujin-wu Feb 10, 2022
d3cf937
convert remaining CI tasks to node 12 for dev
yujin-wu Feb 11, 2022
d05deab
try with scoped published package - and restore 'npm ls --prod --all'…
yujin-wu Mar 8, 2022
300a2c0
adjusted package.lock versioning to work with npm 16
yujin-wu Mar 8, 2022
43031cf
fix syntax lint problems
yujin-wu Mar 8, 2022
e3bfbde
further lint fixes, and restored try { behavior in prepareRegl
yujin-wu Mar 8, 2022
b468c2f
converted devtools/ to es5 syntax
yujin-wu Mar 8, 2022
1b9fef3
try a higher timeout for jasmine tests in _select functio
yujin-wu Mar 8, 2022
e73b99f
exclude strict build from no-new-func check
yujin-wu Mar 8, 2022
f8548e1
revert usage of node12
yujin-wu Mar 8, 2022
80f6f9e
Merge branch 'master' into regl-build-setup
yujin-wu Mar 8, 2022
5ab56d0
restored custom regl package in package-lock
yujin-wu Mar 8, 2022
0f63027
fixed stability issue in regl, bumped regl, and re-generated regl code
yujin-wu Mar 9, 2022
1b114c4
restored erronously omitted node12 circleci test, removed duplicated …
yujin-wu Mar 11, 2022
666871e
Merge branch 'master' into regl-build-setup
yujin-wu Mar 11, 2022
abe7664
scatterpolargl-strict trace
yujin-wu Mar 11, 2022
a49b892
Update .circleci/config.yml
yujin-wu Mar 11, 2022
b719179
bring back space in circleci config
archmoj Mar 11, 2022
374b086
move strict index files into regl traces
archmoj Mar 11, 2022
ec82c09
start with base_index without plot to add strict plot fns
archmoj Mar 11, 2022
862ff3e
lint src/traces/scatterpolargl/plot.js
archmoj Mar 11, 2022
98d49be
revert tasks/partial_bundle.js
archmoj Mar 11, 2022
867c98b
cleanup tasks/util/constants.js
archmoj Mar 11, 2022
f94aa45
strict no longer a partial bundle - generate at build step
archmoj Mar 11, 2022
3cecf47
fixup index-strict - cleanup confusing strict traces
archmoj Mar 11, 2022
2ec0545
fixup package-lock
archmoj Mar 11, 2022
501e0a8
fixup trace names in strict bundle
archmoj Mar 11, 2022
fd8a303
update draftlogs for next minor
archmoj Mar 11, 2022
3ba7dab
Update tasks/stats.js
archmoj Mar 11, 2022
98702c8
update tasks/stats.js
archmoj Mar 11, 2022
e34df29
skip strict in the partial bundle script
archmoj Mar 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -162,6 +162,23 @@ npm run schema

**IMPORTANT:** please do not change and commit any files in the "dist" folder

#### Step 9: REGL - Review & commit potential changes to precompiled regl shaders

If you are implementing a new feature that involves regl shaders, or if you are
making changes that affect the usage of regl shaders, you would need to run

```bash
npm run regl-codegen
```

to regenerate the regl code. This opens a browser window, runs through all
traces with 'regl' in the tags, and stores the captured code into
[src/generated/regl-codegen](https://github.com/plotly/plotly.js/blob/master/src/generated/regl-codegen). If no updates are necessary, it would be a no-op, but
if there are changes, you would need to commit them.

This is needed because regl performs codegen in runtime which breaks CSP
compliance, and so for strict builds we pre-generate regl shader code here.

#### Other npm scripts that may be of interest in development

- `npm run preprocess`: pre-processes the css and svg source file in js. This
Expand Down
154 changes: 154 additions & 0 deletions devtools/regl_codegen/devtools.js
@@ -0,0 +1,154 @@
'use strict';

/* global Plotly:false */

var mocks = require('../../build/test_dashboard_mocks.json');
var reglTraces = require('../../build/regl_traces.json');
var Lib = require('@src/lib');
const { fillGroupStyle } = require('../../src/components/drawing');

// Our gracious testing object
var Tabs = {

// Return the specified plot container (or default one)
getGraph: function(id) {
id = id || 'graph';
return document.getElementById(id);
},

// Create a new plot container
fresh: function(id) {
id = id || 'graph';

var graphDiv = Tabs.getGraph(id);

if(graphDiv) {
graphDiv.parentNode.removeChild(graphDiv);
}

graphDiv = document.createElement('div');
graphDiv.className = 'dashboard-plot';
graphDiv.id = id;

var plotArea = document.getElementById('plots');
plotArea.appendChild(graphDiv);

return graphDiv;
},

// Plot a mock by name (without .json) to the default or specified container
plotMock: function(mockName, id) {
return new Promise(function (res, rej) {

var mockURL = '/test/image/mocks/' + mockName + '.json';

console.warn('Plotting:', mockURL);

var request = new XMLHttpRequest();
request.open('GET', mockURL, true);
request.responseType = '';
request.send();

request.onreadystatechange = function() {
if(this.readyState === 4) {
if(this.status === 200) {
var fig = JSON.parse(this.responseText);
var graphDiv = Tabs.fresh(id);

Plotly.newPlot(graphDiv, fig);

graphDiv.on('plotly_afterplot', function() {
res(graphDiv);
});

} else {
console.error(this.statusText);
}
}
};
})
},
};


// Bind things to the window
window.Tabs = Tabs;
window.Lib = Lib;
window.onload = handleOnLoad;
setInterval(function() {
window.gd = Tabs.getGraph() || Tabs.fresh();
window.fullLayout = window.gd._fullLayout;
window.fullData = window.gd._fullData;
}, 1000);

var mocksList = document.getElementById('mocks-list');

async function handleOnLoad() {
var mocksByReglTrace = {};

for (var trace of reglTraces) {
mocksByReglTrace[trace] = [];
for (var mock of mocks) {
if (mock.keywords.indexOf(trace) !== -1) {
mocksByReglTrace[trace].push(mock);
}
}
}

for (var trace of Object.keys(mocksByReglTrace)) {
var thisMocks = mocksByReglTrace[trace];
var div = document.createElement('div');
div.className = 'mock-group';
div.innerHTML = '<h3>' + trace + '</h3>';
mocksList.appendChild(div);
for (var mock of thisMocks) {
var a = document.createElement('a');
a.className = 'mock-link';
a.innerHTML = mock.name;
a.href = '#' + mock.name;
a.onclick = function() {
Tabs.plotMock(this.innerHTML)
};
div.appendChild(a);
div.appendChild(document.createElement('br'));
}
}

// visit the mocks one by one.
for (var trace of Object.keys(mocksByReglTrace)) {
var thisMocks = mocksByReglTrace[trace];
var generated = {}
for (var mock of thisMocks) {
var gd = await Tabs.plotMock(mock.name);
var fullLayout = gd._fullLayout;
fullLayout._glcanvas.each(function (d) {
if (d.regl) {
console.log("found regl", d.regl);
var cachedCode = d.regl.getCachedCode();
Object.entries(cachedCode).forEach(([hash, code]) => {
generated[hash] = code.toString();
});
console.log("merging entries", Object.keys(cachedCode));
}
})
}

console.log(window.__regl_codegen_cache);
var body = JSON.stringify({
generated,
trace: trace
});
window.__regl_codegen_cache = {};
await fetch("/api/submit-code", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body
});
}

// close
await fetch("/api/codegen-done");
window.close();
}
19 changes: 19 additions & 0 deletions devtools/regl_codegen/index.html
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>REGL Codegen</title>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT"/>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
<section id="mocks-list"></section>
<div id="plots">
<div id="graph"></div>
</div>
<div id="snapshot"></div>

<script src="../../node_modules/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script charset="utf-8" id="source" type="module">import "../../build/plotly.js"</script>
<script charset="utf-8" src="../../build/regl_codegen-bundle.js"></script>
</body>
</html>