Page 1 of 1

Using wxWidgets in a Multi-process Architecture

Posted: Wed Jan 30, 2019 8:07 pm
by katuday
Windows 10 and Visual Studio 2017.
I would like to build a wxWidgets app as a proof of concept in a Multi-process Architecture similar to modern browsers like Chrome, Edge and Firefox.
No, I am not interested in building a browser, for that I can simply to use the available wrappers like wxWebViewChromium for example.
I want to know how, in general, you go about solving a problem of having windows in each tab that are connected to separate processes. How do these windows communicate with the respective processes? I have looked into wxWidgets IPC examples but I am thinking browsers must be passing around complex data structures than simple strings.
Looking for ideas on where to begin.

Re: Using wxWidgets in a Multi-process Architecture

Posted: Wed Jan 30, 2019 9:45 pm
by ONEEYEMAN
Hi,
Are you looking for "multi-processing" or "multi-threading"?

Thank you.

Re: Using wxWidgets in a Multi-process Architecture

Posted: Wed Jan 30, 2019 10:28 pm
by art-ganseforth
As far as i understand you, i would think i had the same question some weeks ago. I found two possible solutions:

You may use wxThread to program some explizit multithreading (seem quiet complicated without some multithreading-experience, so i did not try it).

Alternatively there is OpenMP, which seems to be quiet simple (i tried a bit, but no sophisticated things). It mainly can be used to split loops and functions into threads, which is (more or less automatically) done by the compiler and controlled by just using "#pragma omp ..." preprocessor-directives. Also, OpenMP should be part of your c-compiler and has not to be downloaded, but it is no full multithreading of that kind, that your whole application is splitted into threads.

Re: Using wxWidgets in a Multi-process Architecture

Posted: Wed Jan 30, 2019 11:33 pm
by doublemax
katuday is actually talking about multi-process like Chrome uses it:
https://www.chromium.org/developers/des ... chitecture

It looks quite complicated and i think you need very good reasons to even consider an architecture like this.

I have no experience with this and don't even have a general idea how i'd approach this, but for IPC i would probably look into shared memory:
https://www.boost.org/doc/libs/1_69_0/d ... esses.html

Re: Using wxWidgets in a Multi-process Architecture

Posted: Wed Jan 30, 2019 11:41 pm
by katuday
ONEEYEMAN wrote:Hi,
Are you looking for "multi-processing" or "multi-threading"?

Thank you.
I want "multi-processing" NOT "multi-threading".
I want independent processes so that in case once process crashes does not bring down the entire app.

Re: Using wxWidgets in a Multi-process Architecture

Posted: Wed Jan 30, 2019 11:53 pm
by katuday
art-ganseforth wrote:As far as i understand you, i would think i had the same question some weeks ago. I found two possible solutions:

You may use wxThread to program some explizit multithreading (seem quiet complicated without some multithreading-experience, so i did not try it).

Alternatively there is OpenMP, which seems to be quiet simple (i tried a bit, but no sophisticated things). It mainly can be used to split loops and functions into threads, which is (more or less automatically) done by the compiler and controlled by just using "#pragma omp ..." preprocessor-directives. Also, OpenMP should be part of your c-compiler and has not to be downloaded, but it is no full multithreading of that kind, that your whole application is splitted into threads.
I have looked into MPI too.
Specifically boost::mpi https://www.boost.org/doc/libs/1_64_0/doc/html/mpi.html.
What scared me is it may be necessary to deal with complicated marshalling of objects that are not PODs which mpi does not handle natively

Re: Using wxWidgets in a Multi-process Architecture

Posted: Thu Jan 31, 2019 4:21 pm
by Manolo
wxWidgets has wxProcess

You can show your windows in tabs or whatever, created all of them in the main thread, which is the GUI for your app.

The task to do in a particular window (e.g. reacting to some user action) can be done in a separate process. This process can be created by wxProcess or is a [likekly no-GUI] executable on your own.
This process is launched by wxExecute().

Once you have the process executing, you can do IPC between the app (server) and that process (client). Or use a temp file updated frequently, one process write, the other reads. This is only true if the process is launched asynchronously, otherwise the server waits (see wxExecute docs).

If the execution of the process is synchronous, a return code from wxExecute different of {0, -1} means that the launched process crashed. For asynchronous, I can't tell.

Re: Using wxWidgets in a Multi-process Architecture

Posted: Fri Feb 01, 2019 12:25 am
by katuday
Manolo wrote:wxWidgets has wxProcess

Once you have the process executing, you can do IPC between the app (server) and that process (client). Or use a temp file updated frequently, one process write, the other reads. This is only true if the process is launched asynchronously, otherwise the server waits (see wxExecute docs).
This sounds practical and it seems browsers like Chrome use some variation of IPC. What type of IPC would you recommend that would work well with wxProcess? I want to be able to pass around class objects between server and client so probably I will need some kind of serialization

One more thing. Is it possible to pass a message from server to a client process that is already started and running?
I can't think of any means to do this.

Re: Using wxWidgets in a Multi-process Architecture

Posted: Fri Feb 01, 2019 1:31 am
by Manolo
Have you read wx IPC docs?