Skip to content

Fix qt backend on mac big sur - #19334

Merged
tacaswell merged 3 commits into
matplotlib:masterfrom
ericpre:fix_mac_big_sur_qt
Jan 29, 2021
Merged

tacaswell merged 3 commits into
matplotlib:masterfrom
ericpre:fix_mac_big_sur_qt

Conversation

@ericpre

@ericpre ericpre commented Jan 21, 2021

Copy link
Copy Markdown
Member

PR Summary

The qt backend is not working on mac big sur as reported in #18954.
It is fixed in qt 5.15.2 (https://codereview.qt-project.org/c/qt/qtbase/+/322228) and in the coming 5.12.11 (https://codereview.qt-project.org/c/qt/qtbase/+/322507) but setting this environment variable is necessary for qt <5.15.2.

Even if in a ideal word matplotlib shouldn't be setting this variable environment, this is pragmatic and very convenient fix!

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@jklymak

jklymak commented Jan 21, 2021

Copy link
Copy Markdown
Member

Seems reasonable. @dstansby you mentioned having Big Sur? (ahem, I suppose I should upgrade one of my machines one of these days, but...)

@jklymak jklymak added this to the v3.4.0 milestone Jan 21, 2021
Comment thread lib/matplotlib/backends/qt_compat.py Resolved
@tacaswell

Copy link
Copy Markdown
Member

On one hand, this seem to have only moderate down side, but if it is fixed in newer versions of (py?)Qt it seems to be a moot point?

@dstansby

Copy link
Copy Markdown
Member

I'm struggling to reproduce the original bug - I think it's worth discussing at #18954 (comment) before going further with this.

@dstansby

Copy link
Copy Markdown
Member

I can reproduce the original issue, and confirm that setting this environment variable fixes it.

Comment thread lib/matplotlib/backends/qt_compat.py Resolved
@dstansby

Copy link
Copy Markdown
Member

I was wondering if this would break older versions of OSX/macos, but #18134 says QT5 requires > 10.13, and https://bugreports.qt.io/browse/QTBUG-87014 seems to say that setting this should be fine going back to 10.13, so this looks good to me.

@dstansby

Copy link
Copy Markdown
Member

Does anyone have thoughts on backporting this to 3.3.x? Seems reasonable to me.

@ericpre

ericpre commented Jan 24, 2021

Copy link
Copy Markdown
Member Author

I was wondering if this would break older versions of OSX/macos, but #18134 says QT5 requires > 10.13, and https://bugreports.qt.io/browse/QTBUG-87014 seems to say that setting this should be fine going back to 10.13, so this looks good to me.

76e8260 adds an additional condition LooseVersion(platform.mac_ver()[0]) >= LooseVersion("10.16"), so this should be fine in any case!

# Fixes issues with Big Sur
# https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2
if (sys.platform == 'darwin' and
LooseVersion(platform.mac_ver()[0]) >= LooseVersion("10.16") and

@ericpre ericpre Jan 24, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this should be a >= or == and I don't know if we can even know how is it going to be with the next MacOS release...

@tacaswell

Copy link
Copy Markdown
Member

The choices are:

  • strict equality it may break on the next verssion of OSX if this ends up being a required flag and we have to go through this again.
  • = and it breaks on the next version of OSX because Qt / OSX change to make this a harmful env

Qt/pyqt is generally pretty good about back-compatibility / not breaking users so if we are going to do this, the version filtering seems right.

My main hang up about this is still that libraries should probably not be setting envs (as that is users / application concerns).

@ericpre

ericpre commented Jan 28, 2021

Copy link
Copy Markdown
Member Author

My main hang up about this is still that libraries should probably not be setting envs (as that is users / application concerns).

I agree that we shouldn't be doing this but in practise this is the best and less intrusive solution I know or I can think of. If the QT_MAC_WANTS_LAYER environment variable is already set, it will not be changed.
Another alternative would be to simply document it and let users find it on their own. I think that there are a non negligible numbers of users who don't know how to set variable environment (and are most likely not interested to figure it out) and they shouldn't have to do that, because there is no point in wasting time on this.

@tacaswell
tacaswell merged commit 3515d25 into matplotlib:master Jan 29, 2021
@tacaswell

Copy link
Copy Markdown
Member

This is compelling argument. Thanks @ericpre !

The UI is a bit unclear, but it looks like this is your first PR to Matplotlib 🎉 . Congratulations and hopefully we hear from you again!

@ericpre

ericpre commented Jan 31, 2021

Copy link
Copy Markdown
Member Author

Thanks everyone for the review!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants