dbuenzli / webbrowser

Open and reload URIs in browsers from OCaml
http://erratique.ch/software/webbrowser
ISC License
7 stars 2 forks source link

browse failing on MacOS X 10.13.2 #4

Closed pmetzger closed 6 years ago

pmetzger commented 6 years ago

The following command fails at the shell on MacOS X 10.3.2

$ browse http://www.panix.com/
1934:1971: execution error: Error on line 55: Error: Invalid index. (-1719)
browse: run ['osascript' '-l' 'JavaScript' '-' 'false' 'false' 'com.google.chrome'
     'http://www.panix.com/']: exited with 1
browser reload: run ['osascript' '-l' 'JavaScript' '-' 'false' 'false' 'com.google.chrome'
     'http://www.panix.com/']: exited with 1

As a side note: using osascript to launch a browser is probably a much more complicated way to open a URL from the command line than using the OS X open utility at the command line.

dbuenzli commented 6 years ago

The reason is that JavaScript automation is used and as noted here this is only supported from macOS 10.10 on. Since current opam doesn't allow to constrain this and that support for 10.3 ended from apple in 2005 I'm simply going to close this. Sorry.

As a side note: using osascript to launch a browser is probably a much more complicated way to open a URL from the command line than using the OS X open utility at the command line.

This doesn't allow to implement the browser tab reload strategy which is needed for when you are working on the API docs of your projects.

dbuenzli commented 6 years ago

Ah but now I see that in the odig report you were talking about 10.13 which is another thing...

dbuenzli commented 6 years ago

I'm sorry but unless you want to give a hand to debug the script you will have to wait that I upgrade to 10.13 for me to sort this out (it works before).

pmetzger commented 6 years ago

I'm happy to help debug it. Just tell me what to do.

pmetzger commented 6 years ago

(And apologies for the typo.)

dbuenzli commented 6 years ago

I'm happy to help debug it. Just tell me what to do.

You could try to run:

'osascript' '-l' 'JavaScript' '-' 'false' 'false' 'com.google.chrome' 'http://www.panix.com/' < script

with script being this and try to understand what fails.

pmetzger commented 6 years ago

I get:

$ 'osascript' '-l' 'JavaScript' '-' 'false' 'false' 'com.google.chrome' 'http://www.panix.com/' < foo.js 
1929:1966: execution error: Error on line 50: Error: Invalid index. (-1719)

The problem seems to be:

          tab = win.tabs[t];

As I don't know what this code is supposed to do, it is hard for me to debug it, but if you can explain what the script is intended to do for a living, I can try my hand at it.

dbuenzli commented 6 years ago

It implements the reload strategy mentioned at the end here.

The error seems a bit odd since the loop definition should prevent invalid access I suspect there's a problem with either the win or tabs value here. One of the value may be undefined.

pmetzger commented 6 years ago

It's mysterious to me, too. Is there any sort of debugging code you would like me to try running inside the script? I'm happy to run whatever you like.

BTW, as an aside, I have a lot of open browser windows. I don't know if this is an issue.

dbuenzli commented 6 years ago

I have now upgraded to 10.13.4 and I can't reproduce this.

dbuenzli commented 6 years ago

Are you using the latest version of chrome ?

pmetzger commented 6 years ago

Yes, I'm running the latest version of Chrome. I'll try it again right now.

pmetzger commented 6 years ago

Okay, now if I type browse http://www.panix.com, my chrome windows all pop forward, concealing my shell window (not just the frontmost one) and none of them seem to be displaying the page. Oh, and the command hangs.

dbuenzli commented 6 years ago

It's a bit difficult to be of any help. What shell are you using ? Do you have firefox installed, if that is the case what is the result of:

browse --browser firefox http://www.panix.com/
pmetzger commented 6 years ago

If I do it with firefox it works 100% perfectly.

pmetzger commented 6 years ago

Actually, not quite: running it multiple times opens multiple instances, and I was under the impression the point was to open only one and pop it up. But it does seem to work in general. No hangs, and the page loads.

dbuenzli commented 6 years ago

Actually, not quite: running it multiple times opens multiple instances, and I was under the impression the point was to open only one and pop it up.

Yes that's a known issue see https://github.com/dbuenzli/webbrowser/issues/1, the only browser that provides the full support is chrome and safari on macos. It's pretty funny how a simple task like referesh a tab that has a given address can be tricky in practice.

So I don't know what's the problem with your chrome. Are you using Terminal.app ?

pmetzger commented 6 years ago

I am indeed using Terminal.app, and I'm happy to run any and all tests you suggest and give you the results.

dbuenzli commented 6 years ago

Well I'm sorry but I ran out of ideas and you seem to be the only one hitting this problem. It would be nice if you can investigate yourself why the command actually hangs with your browser. Did you try to restart your browser ?

pmetzger commented 6 years ago

Restarted chrome just to be sure. browse hangs, and the browser starts behaving horribly (including hanging) until I kill the process.

Is there any way to maybe get browse to just run open if I configure it that way?

dbuenzli commented 6 years ago

So I can't reproduce and you are not able to provide more details about what's happening. So I'm closing this. Feel free to reopen if you can investigate and get more details.

pmetzger commented 6 years ago

Can we re-open this? I don't have time right now to try to do an in-depth investigation, but I will in a few weeks, and I won't forget about it.

dbuenzli commented 6 years ago

More than two month later, still no new material for investigation, so I'm closing this until more details are provided --- add them as a comment to this issue once you have them and I'll reopen it if needed.

Having recently dealt with browsers it seems their behaviour can become quite glitchy whenever extensions are installed. So one direction for investigation could be a bad interaction if you have any extension installed. If that is the case try to open chrome without any extension and see if the problem persist.

pmetzger commented 6 years ago

You could have just pinged me about the fact that it was still open. In spite of my efforts I did forget about it.

dbuenzli commented 6 years ago

Ping you have. Please provide investigation information rather than complaining. I already have lost quite some time trying to guide you here, I'm not a support hotline.

pmetzger commented 6 years ago

Given that this isn't stable and that there's documentation browsing code that depends on it, might it be possible to just use "open" instead of doing something clever on Mac OS X? It seems pretty clear that this isn't stable.

dbuenzli commented 6 years ago

might it be possible to just use "open" instead of doing something clever on Mac OS X?

No. So far you are the only one who complained.

pmetzger commented 6 years ago

Perhaps the other people who have had trouble gave up rather than figuring out how to complain. Could we get the use of "open" as a configuration option? I can't currently use odig because the browser stuff doesn't work and it's irritating.

dbuenzli commented 6 years ago

Perhaps the other people who have had trouble gave up rather than figuring out how to complain.

And perhaps not.

Look either you want to help me diagnose your problem or not. I suggested further directions to try to find out the problem and you didn't report about them. I lost enough time with you now so I'm not willing to help you further. The current mode of operation is highly needed if you spend a mininum amount of time working on library docsets and more generally for usability reasons if you repeatedly ask for the same documentation page.

If you want this issue to be solved either try to diagnose it on your side or find other people with the same problem and let them post about it on this issue so that maybe in contrast to you they might actually help me to figure out what's going on in an efficient manner.

More generally I would like to suggest you to stop posting your contentless and "me too" messages that bring nothing to discussions except noise which you became highly correlated with all over the places where I'm interacting with other people to try to get work done.

pmetzger commented 6 years ago

I lost enough time with you now so I'm not willing to help you further.

Thank you so much for your assistance. I'll try forking your library instead so I can get work done.

More generally I would like to suggest you to stop posting your contentless and "me too" messages that bring nothing to discussions except noise which you became highly correlated with all over the places where I'm interacting with other people to try to get work done.

Your suggestion is noted.