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

Hangs and eats all memory trying to render a complex diagram. #53

Closed
kindaro opened this issue Oct 7, 2019 · 5 comments
Closed

Hangs and eats all memory trying to render a complex diagram. #53

kindaro opened this issue Oct 7, 2019 · 5 comments

Comments

@kindaro
Copy link

kindaro commented Oct 7, 2019

Unfortunately, I do not have a short example. I am trying stuff with graphs, and one thing I did was to render a graph in some fashion. I discovered that, while I could vectorize it with the SVG back end, if I try to do the same with Rasterific, it eats all memory in an infinite loop. I did some profiling and I found out that the looping function is clipLine.

Here is the commit. You can run it with, for example, cabal run exes -- --output x.png --width 200. It hangs when I try it. If you replace clr489 example graph with, say, cyc3, it will render beautifully.

Here is the profiling log.

Please let me know if it hangs on your machine too, and if I can do anything else to help.

@Twinside
Copy link
Owner

Twinside commented Oct 8, 2019

Can you try to call dumpDrawing somehow a put the result somewhere?

Dump drawing should print-out the scene in nearly haskell, workable for debugging

@kindaro
Copy link
Author

kindaro commented Oct 8, 2019

  1. I have no idea how to get that for you. I asked: Is it possible to get ahold of the Drawing? diagrams/diagrams-rasterific#60.
  2. I found a ticket Crash due to out of memory diagrams/diagrams-rasterific#39 that may be relevant.

@Twinside
Copy link
Owner

Twinside commented Nov 2, 2019

You have Infinity and NaNs n the dumped diagram:

(fill [LinePrim Line (V2 (-Infinity) (-Infinity)) (V2 (-Infinity) (-Infinity)),LinePrim Line (V2 (-Infinity) (-Infinity)) (V2 (-Infinity) (-Infinity)),LinePrim Line (V2 (-Infinity) (-Infinity)) (V2 (-Infinity) (-Infinity)),LinePrim Line (V2 (-Infinity) (-Infinity)) (V2 NaN NaN)] >>=

This is not filtered by Rasterific, and yeah, it makes the rendering go bonker.

@kindaro
Copy link
Author

kindaro commented Nov 3, 2019

@Twinside Thank you for taking time to research this issue.

So what can be done?

I am not sure I can control this. The data I supply to the diagrams API is somewhat shady (like, sin pi shady), but it is legit. The same diagrams render flawlessly with SVG back end.

Can you explain to me what data type you are showing, and maybe post the code you used to obtain it, so that I can examine my various diagrams with it and locate what goes wrong?

@Twinside
Copy link
Owner

Twinside commented Nov 3, 2019

I've tried the SVG, and you have NaN and Infinity written in your SVG (that your browser probably ignore), I wouldn't call that flawless. The code is mostly the copy/past of Diagram.Rasterific with a call changed to dump the generated drawing, I've pushed it here.

I've added safegard to Rasterific for these cases, at least it shouldn't go into an infinite loop anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants