FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

wx/wxAgg tests on macOS are flaky · Issue #16849 · matplotlib/matplotlib · GitHub

Repository navigation

wx/wxAgg tests on macOS are flaky #16849

Open

Description

It doesn't seem to affect any other platform, but lately, the wxAgg test has been failing quite regularly on macOS. wxPython has not had a new release in several months, so it's not directly the culprit.

The failure is just a timeout, so we could increase it, but this test has a flaky marker on it, so it's not just timing out once, but 3 times over.

Is there anyone on macOS who can try this out?

Activity

  1. dstansby commented on Mar 21, 2020

    Member

    I could try, but I'm getting the following error:

    This program needs access to the screen. Please run with a
    Framework build of python, and only when you are logged in
    on the main display of your Mac.
    

    running

    pythonw -mpytest lib/matplotlib/tests/test_backends_interactive.py::test_interactive_backend[wxagg]
    

    Anyone got any ideas? I thought pythonw was the framework build of python.

  2. QuLogic commented on Mar 22, 2020

    MemberAuthor

    You could try grabbing the code that's actually run in a separate process and run that?

    _test_script = """\
    import importlib
    import importlib.util
    import sys
    from unittest import TestCase
    import matplotlib as mpl
    from matplotlib import pyplot as plt, rcParams
    from matplotlib.backend_bases import FigureCanvasBase
    rcParams.update({
    "webagg.open_in_browser": False,
    "webagg.port_retries": 1,
    })
    backend = plt.rcParams["backend"].lower()
    assert_equal = TestCase().assertEqual
    assert_raises = TestCase().assertRaises
    if backend.endswith("agg") and not backend.startswith(("gtk3", "web")):
    # Force interactive framework setup.
    plt.figure()
    # Check that we cannot switch to a backend using another interactive
    # framework, but can switch to a backend using cairo instead of agg, or a
    # non-interactive backend. In the first case, we use tkagg as the "other"
    # interactive backend as it is (essentially) guaranteed to be present.
    # Moreover, don't test switching away from gtk3 (as Gtk.main_level() is
    # not set up at this point yet) and webagg (which uses no interactive
    # framework).
    if backend != "tkagg":
    with assert_raises(ImportError):
    mpl.use("tkagg", force=True)
    def check_alt_backend(alt_backend):
    mpl.use(alt_backend, force=True)
    fig = plt.figure()
    assert_equal(
    type(fig.canvas).__module__,
    "matplotlib.backends.backend_{}".format(alt_backend))
    if importlib.util.find_spec("cairocffi"):
    check_alt_backend(backend[:-3] + "cairo")
    check_alt_backend("svg")
    mpl.use(backend, force=True)
    fig, ax = plt.subplots()
    assert_equal(
    type(fig.canvas).__module__,
    "matplotlib.backends.backend_{}".format(backend))
    ax.plot([0, 1], [2, 3])
    timer = fig.canvas.new_timer(1)
    timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")
    # Trigger quitting upon draw.
    fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
    plt.show()

  3. timhoffm commented on Mar 22, 2020

    Member

    #16870 xfails this to unbreak CI builds of other PRs. Needs to be reverted once a solution is found.

  4. added this to the v3.2.2 milestone on Mar 23, 2020
  5. changed the title [-]wxAgg test on macOS is flaky[/-] [+]wx/wxAgg tests on macOS are flaky[/+] on Mar 25, 2020
  6. QuLogic commented on Mar 25, 2020

    MemberAuthor

    Seems to affect the wx test too, though less regularly.

  7. modified the milestones: v3.2.2, v3.4.0 on Jun 16, 2020
  8. modified the milestones: v3.4.0, v3.5.0 on Jan 27, 2021
  9. modified the milestones: v3.5.0, v3.6.0 on Sep 25, 2021
  10. modified the milestones: v3.6.0, v3.7.0 on Aug 24, 2022
  11. modified the milestones: v3.7.0, v3.7.1 on Feb 14, 2023
  12. modified the milestones: v3.7.1, v3.7.2 on Mar 4, 2023
  13. modified the milestones: v3.7.2, v3.7.3 on Jul 5, 2023
  14. modified the milestones: v3.7.3, v3.8.0 on Sep 9, 2023
  15. removed this from the v3.8.0 milestone on Sep 15, 2023
  16. dstansby commented on Jan 13, 2024

    Member

    I don't know if I'm going in the right direction here, but there seems to be a circular reference between various Wx objects? Beyond this I'm not really sure where to go...

    import gc
    import random
    import psutil
    
    import objgraph
    
    import matplotlib
    matplotlib.use("WxAgg")
    from matplotlib import pyplot as plt
    
    
    p = psutil.Process()
    
    def make_fig():
        fig = plt.figure()
        plt.close(fig)
        gc.collect()
    
    # Warmup cycle
    for _ in range(2):
        make_fig()
    
    initial_mem = p.memory_info().rss
    
    for i in range(2):
        make_fig()
        growth = p.memory_info().rss - initial_mem
        print(i, growth)
    
    
    objgraph.show_backrefs(
        random.choice(objgraph.by_type('FigureFrameWx')),
        filename='chain_mac.png', max_depth=50, refcounts=True)
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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL