open url in specific running profile instance

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
50addons

open url in specific running profile instance

Unread post by 50addons » 2018-06-09, 22:22

set-up: multiple Palemoon processes are running using different profiles.

objective: open a url in a specific process from the command-line.

problem: depending on the command-line options, the url is either opened in the wrong process or the attempt fails with an error message.


Steps to Reproduce:
create two profiles p1 and p2

Test 1

launch two instances using different profiles:

Code: Select all

palemoon -P p1 -new-instance
palemoon -P p2 -new-instance
open second url in both profile instances:

Code: Select all

palemoon -P p1 -new-tab <url>
palemoon -P p2 -new-tab <url>
Result:
Two processes are launched by the first set of commands (correct behaviour).
Further urls are always opened in the process which was launched first (in this case p1). The profile parameter is ignored.

Test 2

launch one instance using a specific profile:

Code: Select all

palemoon -P p1 -no-remote
open second url in profile instance:

Code: Select all

palemoon -P p1 -new-tab <url>
palemoon -P p1 -remote "openurl(<url>,new-tab)"
Result:
Connecting to a process previously launched with -no-remote always fails:
  • Opening the second url using -new-tab produces error: "Pale Moon is already running, but is not responding. To open a new window, you must first close the existing Pale Moon process, or restart your system."
  • Opening the second url using -remote produces error: "Error: No running window found"


Test 3

launch one instance using a specific profile:

Code: Select all

palemoon -P p1 -new-instance
open second url in profile instance:

Code: Select all

palemoon -P p1 -remote "openurl(<url>,new-tab)"
Result:
Opening the second url using -remote always produces this error regardless with which parameters the process was originally launched: "Error: No running window found"

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35474
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: open url in specific running profile instance

Unread post by Moonchild » 2018-06-10, 00:36

This is not a bug.

The situation is this:
  • You can only open URLs in a running browser if it has remote capabilities enabled.
  • You can only have multiple concurrent profiles open if you disable remote capabilities.
  • You cannot have multiple instances open with remote capabilities because they would conflict in their system type handlers (same application+same type).
So either you have 1 browser instance with remote capabilities enabled, in which case launched URLs will -always- open in that instance, or you have all browsers launched without remote capabilities in which case it will throw an error because no active application is available to handle the request.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

50addons

Re: open url in specific running profile instance

Unread post by 50addons » 2018-06-10, 08:59

If this is not a bug, then my post is a feature request.

I don't know which Firefox version Palemoon was forked from but the remote capability for concurrent browser profiles has been a Firefox feature since before version 0.9.
In the old days remote url launch was via

Code: Select all

-P <profile> -remote "openurl($url,new-tab)"
Later Firefox introduced the -new-instance parameter, which creates a new Linux process for a profile, which is remote enabled. You can have only one process per profile. An attempt to open a second instance for that profile results in error "Firefox is already running, but is not responding. ...".
Remote acccess to open a second tab or window is via

Code: Select all

-P <profile> -new-tab <url>
Firefox 45 ESR implies remote capability when launching a new profile instance. Further tabs from outside the browser have to be opened via -new-tab or -new-window.

This Firefox feature was broken for a while from v.0.9 onwards when they introduced -a application-id for process identification (ditched later). At that point the behaviour and error messages were the same as Palemoon's current functionality, hence I thought this was a Palemoon bug (see bugzilla 427206, bugzilla 716110 and bugzilla 393645).

Usage: I use this hundreds of times a day to open links in a specific profile from my email and rss clients or in Firefox to open a link or tab url in a different profile using the OpenWith add-on.
Last edited by 50addons on 2018-06-10, 09:11, edited 1 time in total.

User avatar
therube
Board Warrior
Board Warrior
Posts: 1650
Joined: 2018-06-08, 17:02

Re: open url in specific running profile instance

Unread post by therube » 2018-06-12, 05:16

(i'll just babble...)

pretty sure Windows / Linux are different regarding this
at some point the meaning of -no-remote changed & or -new-instance created, intertwined, split apart
i've only ever used -no-remote
(i'm on Windows)

(using FF 60, because it was close by...)
i can:
firefox -profile p1 -new-instance
firefox -profile p2 -new-instance
it successfully creates/opens/loads p1 & p2
& that implies, at least in Windows, that -new-instance also is invoking -no-remote

after that, i was not successful in using anything like:
firefox -profile p1 -new-tab <url>
firefox -profile p2 -new-tab <url>
instead each time <url> opened in my non-no-remote (i.e. remoted) instance of FF
firefox -profile p1 -remote "openurl(<url>,new-tab)"
also failed, not sure just where that might have gone, but i suspect a place like /dev/nul

50addons

Re: open url in specific running profile instance

Unread post by 50addons » 2018-06-13, 23:16

@therube:

I have been using Firefox since 2006 on Linux, no experience with Windows versions. In that time I have only upgraded five times (versions 2.0, 3.0, 3.5, 24.0, 45ESR).
In every version I had the concurrent remotable profile functionality, which I find essential, so much so that I downloaded and patched the source whenever the feature was broken in Firefox' version history, typically when commandline parameters were introduced or modified.

The original implementation of the feature was via the -remote parameter:

Code: Select all

firefox -P <profile> -no-remote // first instance
firefox -P <profile> -remote "openurl (<url>,new-tab)" // further instances
The functionality was broken from version 2.0 through to 3.5, probably due to introduction of -new-instance. According to Wikipedia, the first PaleMoon version was based on Firefox 3.5.2, so would have been without concurrent remotable profile functionality.

By Firefox 24.0, the bug had been fixed, but -no-remote semantics changed and its former functionality replaced by -new-instance:

Code: Select all

firefox -P <profile> -new-instance // first instance
firefox -P <profile> -remote "openurl (<url>,new-tab)" // further instances
If PaleMoon 24.0 was a full port of Firefox 24.0, this functionality would have been present.

The -remote option was removed in Firefox 36.0, reintroduced in 36.0.1 and retired from Firefox 39.0; After that the functionality continued to be available via this simplified commandline syntax:

Code: Select all

firefox -P <profile> -new-instance // first instance
firefox -P <profile> -new-tab<url>" // further instances
This worked at least until version 45ESR.

I have no idea what the state of play was in Firefox 38.0, which, according to Wikipedia, PaleMoon 27 is based on.
At least in Firefox, whenever remotable profiles weren't working, it was a bug, not by design.

Locked