Closed lebigot closed 9 years ago
what version of mpl?
cc @mdehoon
That's for version 1.4.0.
The string CGContextClosePath
only shows up two places in the code, in _draw_path
and in quadmesh drawing. From your comment I am assuming the problem is in the first (https://github.com/matplotlib/matplotlib/blob/master/src/_macosx.m#L265). The cr
object looks to be one of these things (https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGContext/index.html). I suspect that there needs to be some sanity checking on cr
prior to the call ot CGClosePath
.
I don't have a mac to test any of these theories on....
This looks relevant: http://www.finetunedmac.com/forums/ubbthreads.php?ubb=showflat&Number=26496
@lebigot Can you check the sequence of codes in _draw_path ? I am wondering if the sequence of codes is incorrect (then the bug is upstream), or the sequence of codes is correct, but _draw_path misinterprets them.
Two points:
This points to the quadmesh code being the culprit.
@mdehoon I am not sure how to perform the check you mentioned: it would take someone more versed into Matplolib's internals. :) I am currently failing to reproduce the problem, but I am not sure under which exact conditions I had it…
Are you able to replicate the bug?
I tried, but failed to replicate the bug. It happened while running on data that I don't have at hand anymore.
That said, I have seen it many times before in other projects of mine, so next time I'll try to post something more specific if it happens again.
I just found a simple way of replicating the error, that might have been the original way that triggered it:
>>> pyplot.bar([0, 1], [1, float("nan")])
Dec 31 15:55:42 weinberg.local Python[12859] <Error>: CGContextClosePath: no current point.
Granted, it is strange to use nan
here, but a more instructive warning would be great.
OK I get the same error message with your example. Can you change line 265 in src/_macosx.m from
CGContextClosePath(cr);
to
if (n > 0) CGContextClosePath(cr);
and make sure the error message doesn't appear? It would be great if you could run the test suite to make sure this doesn't introduce new bugs.
I never compiled Matplotlib (MacPorts!) and I will unfortunately not be able to do this right now…
PS: It's great that you have some idea for the fix. :)
@mdehoon Can you put in a PR with that patch?
Closed by #4006
With the Mac OS X backend, under certain conditions, I guess tons of error messages like:
Oct 17 15:47:38 weinberg.local Python[877] <Error>: CGContextClosePath: no current point.
when I move the mouse inside a slider and when the figure is first drawn (it contains many plots). The TkAgg backend does not report any problem.
This slows down considerably the interaction with the slider.
The code is currently complex, so sharing it here is not obvious: are there tests, changes, etc. that I could run so as to try to nail down the problem?