brave / browser-laptop

[DEPRECATED] Please see https://github.com/brave/brave-browser for the current version of Brave
https://www.brave.com
Other
7.94k stars 974 forks source link

opening URL from external application (Thunderbird/LibreOffice) does not work any more #9193

Closed crysman closed 7 years ago

crysman commented 7 years ago

Xubuntu 16.10 Brave 0.15.310 rev 6b5e4e2 os.platform linux os.release 4.8.0-53-generic os.arch x64

imolein commented 7 years ago

Same probleme here at Xubuntu 16.04 with a fresh installed brave browser (0.15.314 rev 75ffa36)

imolein commented 7 years ago

Opening brave over the console, while a other instance of brave is running, the brave window is focused and the console is throwing hbs@hbs-work:~$ brave [31406:31430:0606/180000.720364:ERROR:connection.cc(1954)] Web sqlite error 5, errno 0: database is locked, sql: PRAGMA auto_vacuum [31406:31430:0606/180000.720467:ERROR:connection.cc(1954)] Web sqlite error 5, errno 0: database is locked, sql: PRAGMA journal_mode = TRUNCATE

crysman commented 7 years ago

It's still not resolved in Brave 0.16.12 rev 72624a2

:/

What about you others? You don't have issues?

frk2 commented 7 years ago

I have the same issue with the latest on Ubuntu 17.04

bsclifton commented 7 years ago

@crysman do you know if this used to work previously? What window manager are you using?

imolein commented 7 years ago

Brave 0.16.13 rev 7869803

Tested it on the following distributions and window managers:

Xubuntu 16.04 - XFCE - Problem exists Debian Testing - XFCE - Problem exists Ubuntu 16.04 - Mate - Problem exists Kubuntu 16.04 - KDE - Problem exists

call-cc commented 7 years ago

Same problem here. Brave gets the focus, but no link is opened.

Ubuntu 16.04 with Gnome-shell. Brave 0.16.13 rev 7869803

I'm having this problem since the last 4 or 5 updates from the Brave Xenial repository, probably since version 0.14.something or 0.15.something.

crysman commented 7 years ago

cca 2 months ago it had been working, it's some 5 brave updates since...

call-cc commented 7 years ago

Is it possible to open a new tab in Brave via the command line? e.g. "brave http://brave.com" ? So we could test whether that works.

bsclifton commented 7 years ago

@call-cc yes- you should be able to do something like: brave -- "https://brave.com"

That should be the format that executables are calling Brave with. With Windows, some registry hacks were needed to make it work. I'm curious how Linux is calling it?

crysman commented 7 years ago

@call-cc > nope, it is not working :( in case brave is already running. see below:

myself@machine ~ 11:42:23
❱ brave http://brave.com
[21171:21192:0623/235838.112647:ERROR:connection.cc(1954)] Web sqlite error 5, errno 0: database is locked, sql: PRAGMA auto_vacuum
[21171:21192:0623/235838.113052:ERROR:connection.cc(1954)] Web sqlite error 5, errno 0: database is locked, sql: PRAGMA journal_mode = TRUNCATE

this is what happens when brave is not running (it works):

myself@machine ~ 11:58:38
❱ ps aux | grep -i brave | grep -v grep
1 myself@machine ~ 11:59:27
❱ echo "(brave not running now)"
(brave not running now)
myself@machine ~ 11:59:43
❱ brave http://brave.com
Crash reporting enabled
[21386:21386:0623/235953.983585:ERROR:CONSOLE(33239)] "(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.", source: chrome://brave/usr/share/brave/resources/app.asar/app/extensions/brave/gen/app.entry.js (33239)
[21386:21386:0623/235953.988483:ERROR:CONSOLE(33239)] "(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.", source: chrome://brave/usr/share/brave/resources/app.asar/app/extensions/brave/gen/app.entry.js (33239)
[21386:21411:0624/000024.039978:ERROR:service_manager.cc(158)] Connection InterfaceProviderSpec prevented service: content_browser from binding interface: content::mojom::Child exposed by: content_renderer
[21386:21411:0624/000024.040038:ERROR:service_manager.cc(158)] Connection InterfaceProviderSpec prevented service: content_browser from binding interface: IPC::mojom::ChannelBootstrap exposed by: content_renderer
[21386:21411:0624/000024.040145:ERROR:service_manager.cc(158)] Connection InterfaceProviderSpec prevented service: content_browser from binding interface: content::mojom::Child exposed by: content_renderer
[21386:21411:0624/000024.040191:ERROR:service_manager.cc(158)] Connection InterfaceProviderSpec prevented service: content_browser from binding interface: IPC::mojom::ChannelBootstrap exposed by: content_renderer

Name Version Brave 0.16.12 rev 72624a2

call-cc commented 7 years ago

(I can confirm that

brave -- http://y99k.com/

works.)

I did some strace-ing and it seems that the problem is how gnome-terminal (or any other application) calls Brave:

10404 08:24:40.454225 execve("/usr/bin/brave", ["brave", "http://y99k.com/"...], [/* 74 vars */] <unfinished ...>

So, the first argument to Brave is the URL and not '--'. As I understand @bsclifton, Brave expects its first argument to be '--'.

This was working fine before, so I guess there was a change made to Brave.

crysman commented 7 years ago

Yes it had been working just fine before. It is a real pain now, I am even considering letting Brave go :(

Even using ubuntu-bug tool is impossible with this bug, since it does not open any window in a browser to fill-in the bug details...

luixxiul commented 7 years ago

maybe due to muon/cr59 change?

putting a milestone in case.

ghost commented 7 years ago

I can confirm this on Kubuntu 14.04. Diverging from the standard browser https://url.here will definitely hurt adoption of brave. I had to switch back to another browser because brave doesn't work as a default browser.

srirambv commented 7 years ago

+1 from community https://community.brave.com/t/brave-doesnt-open-links-from-other-sources/4926

eljuno commented 7 years ago

+1 from community

UplandsDynamic commented 7 years ago

Same problem, running on Fedora 26, default Gnome 3 shell.

DivineOmega commented 7 years ago

I have been fixing this issue myself with each new release by modifying the file at /usr/share/applications/brave.desktop.

The Exec line must be changed from Exec=brave %U to Exec=brave -- %U.

Could a temporary solution be as simple as shipping a modified brave.desktop file?

bsclifton commented 7 years ago

@DivineOmega yes, it could definitely be that easy πŸ˜„ Does Gnome consider that file when opening from Thunderbird, etc? If so, I think we have our fix πŸ˜„

DivineOmega commented 7 years ago

@bsclifton I've not specifically tested Thunderbird, but it certainly works for all other external applications.

DivineOmega commented 7 years ago

This issue seems very related to https://github.com/brave/browser-laptop/issues/7090.

bsclifton commented 7 years ago

@DivineOmega did you want to take a stab at this? I think if you submitted a PR, you'd knock out both issues πŸ˜„ If not, maybe you can share your fix here and I can submit on your behalf?

DivineOmega commented 7 years ago

@bsclifton I can submit a PR, but I'm struggling to find where the brave.desktop file is located/generated. It doesn't seem to be part of the main browser-laptop repo.

I imagine it is part of the release process which generates the .deb file. Could you point me in the right direction?

bsclifton commented 7 years ago

@DivineOmega ah, yeah this appears to be a little more involved

A quick grep shows the files here:

./node_modules/electron-builder/templates/linux/desktop.tpl
./node_modules/electron-installer-debian/resources/desktop.ejs
./node_modules/electron-installer-redhat/resources/desktop.ejs

Which means we may have to upstream the change OR fork the repo and make the change there

Based on what you contributed to our wiki, I think that we would edit the file like this: before: <% } %><% if (name) { %>Exec=<%= name %> %U after: <% } %><% if (name) { %>Exec=<%= name %> -- %U

bsclifton commented 7 years ago

@crysman @Aninstance @LoveIsGrief can you please try adding -- to the part before the %U in your desktop file? I believe this great suggestion by @DivineOmega will resolve the issue. If this works, I'd be more than happy to make the change πŸ˜„

UplandsDynamic commented 7 years ago

@bsclifton I can confirm @DivineOmega solution fixes the issue for me. The external application in my case is the Buku bookmark manager. After adding the double hyphen as a command line option in the .desktop file, it works as expected.

I understand that some distros do not accept a double hyphen as a command line option in the .desktop file. Perhaps this config might be considered instead, which caters for that scenario (I confirm this also works for me on Fedora 26, Gnome 3 shell):

Exec=sh -c "brave -- %U"

bsclifton commented 7 years ago

@Aninstance this syntax worked great! πŸ˜„ I'll wrap up a fix tomorrow and get a demo package up for everyone to try. We should be able to fix this next release

crysman commented 7 years ago

changing to Exec=brave -- %U does not help in my case :/ using Xubuntu 16.10 and Brave 0.17.19 rev 4e46480

It opens a new brave window only when brave has not been running already. Moreover, it opens a new window, not a new tab (The first window contains tabs left when I closed brave last time).

When brave is running already, the window manager focuses the existing brave window, but no new tab is opened :/

bsclifton commented 7 years ago

@crysman can you please try with this syntax? I'm hoping this works for you πŸ˜„ Exec=sh -c "brave -- %U"

bsclifton commented 7 years ago

@crysman @DivineOmega @Aninstance @LoveIsGrief here is a packaged build which has the fix if you'd like to preview it here and confirm: https://github.com/brave/browser-laptop/releases/tag/v0.18.15dev

During the install, the desktop file should get modified appropriately πŸ˜„

crysman commented 7 years ago

I've not tried the patched build, but the "sh -c" version does not work either :/ I believe I've got it right:

❱ cat /usr/share/applications/brave.desktop 
[Desktop Entry]
Name=Brave
Comment=Brave laptop and desktop browser
GenericName=Web Browser
Exec=sh -c "brave -- %U"
Icon=brave
Type=Application
StartupNotify=true
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;image/webp;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
bsclifton commented 7 years ago

@crysman this does look correct ☹️ I'm curious why this wouldn't be used? Is the .desktop entry cached? (ex: would you need to logout/login or restart X11?)

ghost commented 7 years ago

@crysman You could try logging what's actually being sent to brave with a bash script e.g

# Create the script
echo "#!/bin/bash
echo $@ | tee -a /tmp/brave_calls
brave $@ |& tee -a /tmp/brave_logs" > /tmp/brave

#Make it executable
chmod +x /tmp/brave

# Update the desktop file to use the new command
# Also backs it up
sudo sed -i=.bak -re "s@Exec=.*@Exec=/tmp/brave -- %U@" /usr/share/applications/brave.desktop

Then try and do whatever it is you were trying to do and check _/tmp/bravecalls ad well as _/tmp/bravelogs

aliddell commented 7 years ago

Thanks to the comments above I've been able to get this working with 0.18.16 as my default browser on Kubuntu -- maybe this will be helpful?

I set my default web browser and http handler with xdg-settings like so:

$ xdg-settings set default-web-browser brave.desktop
$ xdg-settings set default-url-scheme-handler http brave.desktop

And I set the default browser in the Default Applications module of the KDE system settings to brave -- %U. (I think when Brave tries to set it itself it just sets it to brave.)

Maybe you can find a similar dialogue in XFCE. xdg-settings should be present and perform as expected on Xubuntu.

screen shot 2017-08-08 at 9 11 09 am

luixxiul commented 7 years ago

Should we reopen this issue, if https://github.com/brave/browser-laptop/pull/10215 did not solve the issue completely?

bsclifton commented 7 years ago

Yes, let's re-open until we can figure out the rest

After talking with @darkdh, maybe we should go with the solution proposed by @LoveIsGrief https://github.com/brave/browser-laptop/pull/9890

It sounds like Chromium args should always be in the form --paramName=value and never in the form --paramName value. If that is true, we're safe to accept the PR πŸ˜„

bsclifton commented 7 years ago

@LoveIsGrief your original PR couldn't be re-opened (since the branch was deleted)... Would you be able to create a new branch, cherry-pick in https://github.com/brave/browser-laptop/pull/9890/commits/c1d43aad017f2d1593d30df42622c3ce40e6b93a, and then submit a new PR? πŸ˜„

ghost commented 7 years ago

@bsclifton I still have the branch locally. Maybe a rebase onto the new master will do.

mrkskwsnck commented 7 years ago

I am new to the Brave browser and have ran into exactly the same issue: Can’t open external Links (from Evolution, Telegram etc.) if the Brave browser is already running. - Very annoying :-1:

My System:

I was doing some research and I think I found an solution especially for XFCE desktop. The main problem seemed to me that Brave didn't come up in the Favorite Applications settings for setting it as the default browser. However, I was able to choose another installed browsers but not Brave itself.

So I compared the application starter files provided by Brave, Vivaldi and Google Chrome inside both /usr/share/applications/ and ~/.local/share/xfce4/helpers/ folders. The XFCE compatible starter files contained four additional lines.

Type=X-XFCE-Helper
X-XFCE-Category=WebBrowser
X-XFCE-Commands=</path/to/binary>
X-XFCE-CommandsWithParameter=<command_to_execute_with_params>

My idea was to supplement these four lines to the original application starter file. But because I didn't want to edit the original file I copied the brave starter file to the user space.

cp /usr/share/applications/brave.desktop ~/.local/share/xfce4/helpers/brave.desktop

Then I adapted the latter two lines to conform to the installed Brave browser. Now the Exec and X-XFCE-CommandsWithParameter entries look very similar.

Type=X-XFCE-Helper
X-XFCE-Category=WebBrowser
X-XFCE-Commands=/usr/bin/brave
X-XFCE-CommandsWithParameter=sh -c "brave -- %s"

After all these steps the Brave browser now comes up in the Favorite Applications settings. So finally I am able to set Brave as default browser AND external links successfully do open in an already running Brave insance :+1:

bildschirmfoto_2017-08-10_17-53-26

My complete Brave starter file looks like below

[Desktop Entry]
Name=Brave
Comment=Brave laptop and desktop browser
GenericName=Web Browser
Exec=sh -c "brave -- %U"
Icon=brave
Type=Application
StartupNotify=true
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;image/webp;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
Type=X-XFCE-Helper
X-XFCE-Category=WebBrowser
X-XFCE-Commands=/usr/bin/brave
X-XFCE-CommandsWithParameter=sh -c "brave -- %s"

Hopefully someone will find this helpful...

NejcZdovc commented 7 years ago

cc @bsclifton @posix4e for this last comment

crysman commented 7 years ago

after invoking xdg-settings set default-web-browser brave.desktop I am opening links from Thunderbird successfully (using the same brave.desktop as here https://github.com/brave/browser-laptop/issues/9193#issuecomment-320704098)

bsclifton commented 7 years ago

Re-opening after reverting https://github.com/brave/browser-laptop/pull/10375 with https://github.com/bsclifton/browser-laptop/commit/027589c3053e4e0581a3c5508b75c6fd600659f4

Myself, @darkdh, and @bridiver noticed issues where launching in dev mode would always open file://usr/local/brave/browser-laptop-bootstrap/src/browser-laptop

The previous fix is still in place (the desktop file). This is a confirmed fix for multiple folks. It would be great to understand the remaining fix. It might be as easy as adding this to the desktop file:

Type=X-XFCE-Helper
X-XFCE-Category=WebBrowser
X-XFCE-Commands=/usr/bin/brave
X-XFCE-CommandsWithParameter=sh -c "brave -- %s"

Repos that would need updating: https://github.com/brave/electron-installer-debian https://github.com/brave/electron-installer-redhat

bsclifton commented 7 years ago

Closing this issue as the largest use-cases are resolved

For XFCE, I created the following issue: https://github.com/brave/browser-laptop/issues/10897 cc: @crysman, @MrksKwsnck, @imolein

It sounds like we may need to create a similar issue for KDE (per comment by @aliddell)

Hedronmx commented 7 years ago

I'm having this problem on Elementary OS as well... I tried the latest beta and I still can't open links when the browser is already opened

stefonarch commented 6 years ago

Stumbled on this thread, still same issue on arch with generic binary, opens window but no tab no link. schermata-19-22-28-49

EDIT: my workaround is calling a script instead of brave....

#!/bin/bash
brave -- $1
smetj commented 5 years ago

This problem still persists and tbh it's a bit hard to imagine it doesn't float to high priority bugs.

A simplified example. When I have this link displayed in my terminal: https://www.google.com/search?q=brave%20error

and I click on it, then brave opens following URL: https://www.google.com/search?q=brave

Firefox and Chrome handle these just fine.

The problem occurs also when opening links from Slack where this becomes annoying very quickly.

jonathansampson commented 5 years ago

@smetj Have you tried this while one of our new brave-core builds set as your default browser? I suspect the issue is resolved there. We'll be upgrading users from the older Muon build in the near future.

smetj commented 5 years ago

@jonathansampson thanks for the quick reply. Indeed ... I have now switched to the brave dev version and ... the problem is gone.

MarshCastle commented 5 years ago

I agree with the above - this is damaging to uptake - I can't get people to use Brave if they can't open a link from an external source :/ I'm running this on Stretch, and none of the above work for me - I can't even find a way to open a link from the command line without quoting the URL, and can't use a script to open as in @stephonarch approach.

I'd rather use a repo than build / install a brave-core builed (not even sure what that is!).

Sorry to be down - but would really like a solution that I can pass on to people to get Brave adopted.