-
Notifications
You must be signed in to change notification settings - Fork 53
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
PTV-1620 - fix browser freeze and crash when rendering large heatmaps #3116
Conversation
The code analysis failure is due to the invocation of a kbwidget using "new" -- the widget itself is not stored, so the "bug" is constructing an object without using it. Just the weirdness of kbwidget freaking out code analysis. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #3116 +/- ##
========================================
Coverage 73.37% 73.37%
========================================
Files 36 36
Lines 3917 3917
========================================
Hits 2874 2874
Misses 1043 1043 Continue to review full report at Codecov.
|
I'll have a closer look at the failing test ... it works locally. |
Added ticket https://kbase-jira.atlassian.net/browse/PTV-1844 because I wanted to have screenshots of each of the widget states. It may be reviewed directly by building off this PR or the branch and viewing a FeatureClusters object, e.g. as output from "Cluster Expression Data - K-Means" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor test file tweaks, but looks great. Thanks for doing this!
test/unit/spec/util/asyncTools.js
Outdated
* @param {int} duration | ||
* @returns {Promise<void>} | ||
*/ | ||
function waitFor(duration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is effectively a duplicate of https://github.com/kbase/narrative/blob/develop/test/unit/testUtil.js#L63 and should just use that one.
The tryFor
function could probably live in testUtil
as well. At the least, this file should be moved out of the test/spec/util
directory and up into the should be test
directory, as it's not a test spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this was done a long time ago in the original PR, and I was trying to make as few changes from that as possible. E.g. there was nothing else in the util directory then, just mwsTool.js!
Knowing me, I also wanted the tests to be low-dependency, and it seemed like there as a lot going on in testUtils...
Anyway, I'm happy to move the code out and into testUtils (I had moved the non-spec files out myself during testing so I could isolate tests w/o the util specs.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, have the changes locally, will update the PR a bit later this afternoon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the changes are up. There were changes to a dozen or so files to enable this, and I included some commented-out test config features that I've found useful for focusing tests and reducing test output clutter.
The mswUtils was moved into a unit/utils directory to clarify purpose and ease inclusion of test utilities (e.g. don't need to individually add that file, don't need to individually map it for requires). asyncUtils was removed and the non-duplicate function (tryFor) moved into testUtils.
// Theoretically this ensures that the link and url are not needed any more. | ||
// I don't know of documentation for this behavior, but it does seem to work. | ||
// Note that there is nothing really to "download", as the heatmap content is | ||
// already loaded in the browser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// I don't know of documentation for this behavior, but it does seem to work. | ||
// Note that there is nothing really to "download", as the heatmap content is | ||
// already loaded in the browser. | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the setTimeout
wrapper bit necessary? Is that something to do with the Blob lifecycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added this to the comment:
I didn't find documentation for this, but I figure that the click is
not handled until the next turn of the wheel in the JS event loop. So the
timeout just lets the event loop handle the click, and timers are executed
after any pending events, so this should ensure that the link being clicked
is not removed until the link 'click' is handled.
… usage of waitFor/wait, add some commented-out useful test settings, and adjust affected tests [PTV-1620]
SonarCloud Quality Gate failed. 1 Bug No Coverage information |
Thanks for the changes. This works for me. |
PTV-1620 fix usage of $('<tag>') in PR #3116
Just adding a comment to note that this implements a sub ticket of PTV-1620: PTV-1844 |
Description of PR purpose/changes
This change fixes PTV-1620, which reflects a public ticket that cited two issues when viewing a FeatureCluster object
The data-tables error was due to a missing field which was not supplied with a default value; data-tables does not like undefined values. This issue was fixed separately.
The changes in this PR fix the browser freezing and crashing issue. That problem is due to the creation of a heatmap when the number of features is greater than about 200. The heatmap is grows by N², where N is the number of features. The processing of the data for the heatmap beyond 200 features will begin to consume several seconds, and at a certain point may cause the browser to crash or report an unresponsive tab.
It is notable that the affected widget, kbaseExpressionPairwiseCorrelation, already restricted the display of a heatmap with over 50 features. With over 50 features in a cluster, it provides a link for downloading the heatmap, which is hidden.
However, it placed no limits on the creation of the heatmap. It is the creation of the heatmap that consumes a great deal of cpu and memory, leading to unresponsiveness and crashing.
This set of changes focuses on addressing this issue, but also:
There are several UI and code issues that will be addressed by a subsequent PR, affecting quite a few additional files.
Jira Ticket / Issue
Jira Ticket https://kbase-jira.atlassian.net/browse/PTV-1620
Added the Jira Ticket to the title of the PR (e.g.
DATAUP-69 Adds a PR template
)Testing Instructions
Unit tests have been added.
Dev Checklist:
Updating Version and Release Notes (if applicable)