Open the webgl viewer at localhost rather than the machine's hostname - #734
Open
marklescroart wants to merge 1 commit into
Open
Open the webgl viewer at localhost rather than the machine's hostname#734marklescroart wants to merge 1 commit into
marklescroart wants to merge 1 commit into
Conversation
show() built the viewer URL from socket.gethostname(), then handed it to
webbrowser.open(). That browser runs on the same machine as the server, so
the hostname buys nothing there, and on macOS it actively gets in the way:
with scutil HostName unset, gethostname() returns the mDNS name
("mymac.local"), which resolves to a long list of addresses -- two
link-local ones with no usable scope among them -- and reaches the server
only if the application firewall lets the python process accept
connections on a non-loopback interface. The auto-opened tab then fails
for reasons that look nothing like a pycortex problem.
The webgl.domain_name config option cannot help, since it is appended to
the hostname rather than replacing it.
Build both URLs instead. localhost is what gets opened and what is printed
first, matching what headless.py already does; the hostname URL is still
printed (and still shown in the IPython link) for handing to someone on
another machine, so remote setups relying on domain_name keep working. The
port line now comes with a full URL, which is what you need anyway when
the browser does not open on its own.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mark did this with Claude to resolve an annoyance that only came up on my Mac laptop (see below). FWIW, I am still not comfortable letting Claude push; I am still trying to understand as completely as I can what, exactly, I am allowing the Borg to take over.
Here's what Claude has to say about the fix:
show() built the viewer URL from socket.gethostname(), then handed it to webbrowser.open(). That browser runs on the same machine as the server, so the hostname buys nothing there, and on macOS it actively gets in the way: with scutil HostName unset, gethostname() returns the mDNS name ("mymac.local"), which resolves to a long list of addresses -- two link-local ones with no usable scope among them -- and reaches the server only if the application firewall lets the python process accept connections on a non-loopback interface. The auto-opened tab then fails for reasons that look nothing like a pycortex problem.
The webgl.domain_name config option cannot help, since it is appended to the hostname rather than replacing it.
Build both URLs instead. localhost is what gets opened and what is printed first, matching what headless.py already does; the hostname URL is still printed (and still shown in the IPython link) for handing to someone on another machine, so remote setups relying on domain_name keep working. The port line now comes with a full URL, which is what you need anyway when the browser does not open on its own.
... AFAICT this is all reasonable.