-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Suppressing warning messages #2258
Comments
What is the motivation for suppressing the warnings? Is there a performance impact? |
Well not exactly performance impact, but showing all these warnings in the console is a pain in the ***. |
That makes sense, but disabling the warnings comes at a cost: When a dev creates an edge and its not visible because of the positions of the connected nodes, it would be confusing to not have the warning. Maybe the warnings could be collated somehow. |
I guess the warning could be suppressed automatically if the connecting nodes both have the default (0, 0) position. Collation could more generally be done within a time threshold, but I'd be wary of edgecases. |
Yes, that would be a great solution I think! I'm not that well into the codebase of Cytoscape to submit a Pull Request, but I could try with some pointers maybe? |
There is some information here: https://github.com/cytoscape/cytoscape.js/blob/unstable/CONTRIBUTING.md The warning code is here: cytoscape.js/src/extensions/renderer/base/coord-ele-math/edge-control-points.js Lines 127 to 138 in d0d70c2
|
I'm not sure if checking the "default" (0, 0) position is good enough. Bumping into this same problem:
I can see edge I did a dump at line 132 in the
How would one surpress this warning? Maybe during animation, don't warn, but if animation has finished and it's still not visible? |
Yep, checking for animation suppresses the warning properly, at least for this use case. PR coming. |
Whether the edge is animated still isn't enough information to suppress the warning properly. The warning is there because there are several cases for edges, with different property value combinations, that make the edge impossible to draw. It can be confusing to a consumer without the warning: Did I as the consumer do something wrong or is the library broken? So then: (1) The warning must still be shown for all cases except those that are obviously not caused by user error. (2) The warning suppression logic must not impact performance significantly. By suppressing the warning for animated elements, (1) is violated. The consumer can animate elements by |
Thanks @maxkfranz. To satisfy both (1) and (2), perhaps the warning can be printed just once - for the first edge that was not drawn, so as not to fill the console with similar information, thus becomes noise? |
For layout that makes sense, for other cases it could be confusing to see a missing edge but have no warning for it. I think the simplest option is to have some init option to suppress all warnings |
Warnings are useful. I wouldn't opt out completely - someone may add it, commit the code, and forget about it. Instead I suggest that the warnings be printed once per cytoscape instance, instead of per edge/node. That still satisfies 1 & 2, and it doesn't have the need to be configured. |
If it's per-cy rather than per-ele, then (1) is no longer generally true: For example, you could have one edge that is obviously wrong cause the warning, and then later another non-obvious edge doesn't get any warning.
To me, that's an argument against hard-coding your options --- rather than an argument against the existence of an option itself. If you're worried about that case, you should use an environment variable at build time, e.g. |
I agree that is one safeguard option against hard-coded options. What I am advocating is making it impossible to make that set-and-forget mistake, and not having that configurable option. If I may offer a compromise: make |
The only way I could see debouncing working generally on Imagine this sequence, at around the same time: A, A, B, C I would expect this output: A, B, C For this particular warning, we already have this behaviour by limiting this warning per element. Debouncing could work to reduce the overall count of warnings if --- rather than debouncing |
Yes, that's exactly what I was thinking. |
Is there a list of warning classes somewhere? |
No, there is just a set of calls to |
I gave this a try for an hour and ran out of time. Just wanted to document my findings so far.
That said, I am currently not using animations in our production code, and only displaying the graph after layout animation has finished, and it is not noisy anymore... so I will sit on this one for now. |
For (3), a separate collection could be used to store the list of edges. The debouncing could be independent of ticks, but this raises another point: The debounce time can't be specified to be very long, or the utility of the warning is decreased: Knowing when the edge is invalid is useful information, especially if you're dragging it around. |
To me While moving nodes it happens a lot that "source node and the target node overlap" and is no problem. In my experience 100% of these warnings are "false alarm" and clutter the dev console. It hinders recognizing the real warnings issued by my app. I think @maxkfranz already suggested a perfect simple yet flexible solution:
A big thumb up for this! |
I checked the control point code, and there's a condition to check for node overlap. That state could be stored for the warning: If the nodes overlap, we don't need to print the warning. That case should -- I hope -- be fairly obvious to a developer. The main purpose of the warning is to let the dev know when he specified style properties that sometimes make the edge impossible to draw: He should update his stylesheet to work more generally with his data. So if we can automatically eliminate all the node overlap cases to reduce noise, this might be an acceptable compromise. I still think the option to turn them all off is a good idea, especially for when a dev makes a prod build of his app. |
Thank you for detailed response!
+1 |
I should be able to whip up a PR today to add an option to turn them all off. |
The refactoring for the following issue makes it so the invalid edge warning is not shown when the nodes overlap: Clean up control point calculation a bit #2300 |
The The benefits of this approach are:
I initially thought that it would be simpler to use an init option like |
@maxkfranz Congratulations for 3.5.0! The new |
We upgraded Cytoscape in our app recently and now it always spews thousands of warnings to the console, making the console useless for seeing actually important warnings. Your solution is to allow the option of disabling all warnings across Cytoscape -- this seems a much worse tradeoff than just not warning about overlapping nodes. What if Cytoscape needs to warn be about something else? |
The edge warning is the most important warning that the library emits, for reasons already described in this thread. The library doesn't print warnings for overlapping nodes anymore --- as mentioned. If you have that warning, especially that many times, then that's a good indication that you have problem in your stylesheet. If you don't notice the issue right away by eye, then that makes a good case for the existence of the warning. How else are you supposed to notice something missing in large graphs? |
Issue type
Core Library & Cose Layout.
Bug report
Environment info
Current (buggy) behaviour
I think this has to do with both the 'cose' layout as well as the core library. The main concern is adding nodes dynamically (using
elements.forEach(function (element) { cy.add(element) })
) or adding directly to the graph (using{ (..), "elements": elements, (..) }
). When adding directly to the graph, the core library has no problems with adding the nodes using the 'cose' layout, but when adding dynamically, a warning is shown in the console that nodes probably overlap and therefore edges are impossible to draw.I can imagine edges are impossible to draw when at first they overlap, but in the end, the layout determines the position of the nodes and then they don't overlap anymore. Even when using something like
cy.batch(function () {})
to add all nodes (dynamically) at once and then run the layout, the warnings are still shown.This does not happen for 'breadthfirst' or 'random' layouts and (as far as I have tested) only for 'bezier' and 'straight' edge styles.
Desired behaviour
Some way to suppress these warnings when adding nodes dynamically, while the layout is responsible for the position of nodes.
NOTE: I did find a workaround: a (random) position when adding nodes solves the warning.
Minimum steps to reproduce
https://jsbin.com/manukazata/1/edit?js,console,output
The text was updated successfully, but these errors were encountered: