Skip to content

Mac OS X backend: <Error>: CGContextClosePath: no current point  #3654

Closed

Description

@lebigot

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?

Activity

  1. modified the milestones: , v1.4.x on Oct 17, 2014
  2. tacaswell commented on Oct 17, 2014

    @tacaswell
    Member

    what version of mpl?

    cc @mdehoon

  3. lebigot commented on Oct 17, 2014

    @lebigot
    ContributorAuthor

    That's for version 1.4.0.

  4. tacaswell commented on Oct 17, 2014

    @tacaswell
    Member

    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

  5. mdehoon commented on Oct 22, 2014

    @mdehoon
    Contributor

    @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.

  6. lebigot commented on Nov 1, 2014

    @lebigot
    ContributorAuthor

    Two points:

    • I remember that that the error message was actually printed before I touched the slider: it was printed after displaying a few graphs.
    • I do have a quadmesh in my code (pcolormesh).

    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…

  7. mdehoon commented on Nov 19, 2014

    @mdehoon
    Contributor

    Are you able to replicate the bug?

  8. lebigot commented on Nov 19, 2014

    @lebigot
    ContributorAuthor

    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.

  9. lebigot commented on Dec 31, 2014

    @lebigot
    ContributorAuthor

    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.

  10. mdehoon commented on Jan 5, 2015

    @mdehoon
    Contributor

    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.

  11. lebigot commented on Jan 5, 2015

    @lebigot
    ContributorAuthor

    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. :)

  12. modified the milestones: , v1.4.x on Feb 7, 2015
  13. tacaswell commented on Feb 7, 2015

    @tacaswell
    Member

    @mdehoon Can you put in a PR with that patch?

  14. tacaswell commented on Feb 9, 2015

    @tacaswell
    Member

    Closed by #4006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions