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

webbrowser.py triggers unwanted XQuartz startup #87277

Closed
hans-meine mannequin opened this issue Feb 3, 2021 · 9 comments
Closed

webbrowser.py triggers unwanted XQuartz startup #87277

hans-meine mannequin opened this issue Feb 3, 2021 · 9 comments
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes OS-mac performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@hans-meine
Copy link
Mannequin

hans-meine mannequin commented Feb 3, 2021

BPO 43111
Nosy @terryjreedy, @ronaldoussoren, @ned-deily
PRs
  • gh-87277: Don't look for X11 browsers on macOS (webbrowser) #24480
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-02-03.09:21:34.337>
    labels = ['OS-mac', '3.8', '3.9', '3.10', 'performance', 'library']
    title = 'webbrowser.py triggers unwanted XQuartz startup'
    updated_at = <Date 2021-02-08.09:04:26.632>
    user = 'https://bugs.python.org/hans-meine'

    bugs.python.org fields:

    activity = <Date 2021-02-08.09:04:26.632>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'macOS']
    creation = <Date 2021-02-03.09:21:34.337>
    creator = 'hans-meine'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43111
    keywords = ['patch']
    message_count = 6.0
    messages = ['386182', '386553', '386555', '386557', '386623', '386625']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'ronaldoussoren', 'ned.deily', 'hans-meine']
    pr_nums = ['24480']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue43111'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @hans-meine
    Copy link
    Mannequin Author

    hans-meine mannequin commented Feb 3, 2021

    For a long time, I wondered why opening Jupyter notebooks through nbopen always led to XQuartz starting. Now, I found the reason: nbopen uses webbrowser.py to open a web page, and webbrowser.py sees the DISPLAY variable being set and calls xdg-settings (which I installed via the xdg-utils port / MacPorts).

    Apparently, in order to be able to fire up XQuartz on demand and to allow people starting X11 applications, DISPLAY is set to a string like /private/tmp/com.apple.launchd.<somecode>/org.xquartz:0.

    I am using Safari and find this starting of XQuartz undesirable (causes a delay, uses system resources, leads to a new running program in the Dock / task switcher). On the other hand I can totally understand that the code makes sense.

    As a workaround, I can unset DISPLAY, or uninstall xdg-utils (although it is useful, and may be a dependency of other ports), but I thought I should also bring it up here for discussion.

    @hans-meine hans-meine mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir OS-mac performance Performance or resource usage labels Feb 3, 2021
    @terryjreedy
    Copy link
    Member

    3.7 is a few years old and only gets security fixes. Can you either test on current releases or whether code is still same?

    @ronaldoussoren
    Copy link
    Contributor

    The same code is present in trunk.

    I'm in favour of disabling usage of X11 browsers of macOS, that's almost certainly not what users want.

    I no longer have XQuartz installed on my machine, but when I did I only used it for running X11 GUIs on remote Linux systems.

    What I'm not entirely sure about: is this something we should back port or just apply to the trunk (3.10)? This is a behaviour change and as such I'd be inclined to only apply to trunk.

    @ronaldoussoren ronaldoussoren added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes and removed 3.7 (EOL) end of life labels Feb 6, 2021
    @hans-meine
    Copy link
    Mannequin Author

    hans-meine mannequin commented Feb 6, 2021

    I was trying to be very honest, because I am still running 3.7 for production. However, I have carefully checked and the webbrowser.py has only seen (clearly) unrelated changes.

    @ronaldoussoren
    Copy link
    Contributor

    I've created a PR for this.

    Open question: Is this a bug fix (with back ports to 3.9 and 3.8) or a feature (no back ports)?

    @terryjreedy
    Copy link
    Member

    webbrowser is 'generous' at to what browsers it will open, some of which are not what hardly anyone would want. So I would call this an 'enhancement' (really 'disenchantment', like all removals;-) unless there were a technical reason other than those given for the exclusion.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added 3.11 only security fixes 3.12 bugs and security fixes and removed 3.9 only security fixes 3.8 only security fixes labels Sep 9, 2022
    @iritkatriel
    Copy link
    Member

    I've updated the version labels. The code change has not been applied to main yet (but I don't know whether it is still needed).

    @ronaldoussoren
    Copy link
    Contributor

    I'm reviving the PR and will treat this as a new feature, that is I won't perform a back port of the PR. Primary reason for that is that using XQuartz in first place is a niche use case.

    ronaldoussoren added a commit that referenced this issue Dec 21, 2023
    The installation of XQuartz on macOS will unconditionally
    set the $DISPLAY variable. The X11 server will be launched
    when a program tries to access the display.  This results
    in launching the X11 server when using the webbrowser module,
    even though X11 browsers won't be used in practice.
    @ronaldoussoren
    Copy link
    Contributor

    I've merged a fix for this in the main branch.

    I'm not backporting this because X11 usage on macOS should be extremely niche these days, but am willing to reconsider.

    ryan-duve pushed a commit to ryan-duve/cpython that referenced this issue Dec 26, 2023
    …ython#24480)
    
    
    The installation of XQuartz on macOS will unconditionally
    set the $DISPLAY variable. The X11 server will be launched
    when a program tries to access the display.  This results
    in launching the X11 server when using the webbrowser module,
    even though X11 browsers won't be used in practice.
    kulikjak pushed a commit to kulikjak/cpython that referenced this issue Jan 22, 2024
    …ython#24480)
    
    
    The installation of XQuartz on macOS will unconditionally
    set the $DISPLAY variable. The X11 server will be launched
    when a program tries to access the display.  This results
    in launching the X11 server when using the webbrowser module,
    even though X11 browsers won't be used in practice.
    aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
    …ython#24480)
    
    
    The installation of XQuartz on macOS will unconditionally
    set the $DISPLAY variable. The X11 server will be launched
    when a program tries to access the display.  This results
    in launching the X11 server when using the webbrowser module,
    even though X11 browsers won't be used in practice.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes OS-mac performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants