Using wxWidgets in a Multi-process Architecture

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
katuday
Earned some good credits
Earned some good credits
Posts: 115
Joined: Fri Aug 17, 2012 2:22 am

Using wxWidgets in a Multi-process Architecture

Post by katuday » Wed Jan 30, 2019 8:07 pm

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.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3159
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using wxWidgets in a Multi-process Architecture

Post by ONEEYEMAN » Wed Jan 30, 2019 9:45 pm

Hi,
Are you looking for "multi-processing" or "multi-threading"?

Thank you.

art-ganseforth
Earned some good credits
Earned some good credits
Posts: 114
Joined: Mon Sep 01, 2014 10:14 am

Re: Using wxWidgets in a Multi-process Architecture

Post by art-ganseforth » Wed Jan 30, 2019 10:28 pm

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.

User avatar
doublemax
Moderator
Moderator
Posts: 13297
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using wxWidgets in a Multi-process Architecture

Post by doublemax » Wed Jan 30, 2019 11:33 pm

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
Use the source, Luke!

katuday
Earned some good credits
Earned some good credits
Posts: 115
Joined: Fri Aug 17, 2012 2:22 am

Re: Using wxWidgets in a Multi-process Architecture

Post by katuday » Wed Jan 30, 2019 11:41 pm

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.

katuday
Earned some good credits
Earned some good credits
Posts: 115
Joined: Fri Aug 17, 2012 2:22 am

Re: Using wxWidgets in a Multi-process Architecture

Post by katuday » Wed Jan 30, 2019 11:53 pm

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

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 664
Joined: Mon Apr 30, 2012 11:07 pm

Re: Using wxWidgets in a Multi-process Architecture

Post by Manolo » Thu Jan 31, 2019 4:21 pm

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.

katuday
Earned some good credits
Earned some good credits
Posts: 115
Joined: Fri Aug 17, 2012 2:22 am

Re: Using wxWidgets in a Multi-process Architecture

Post by katuday » Fri Feb 01, 2019 12:25 am

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.
Last edited by katuday on Fri Feb 01, 2019 10:08 pm, edited 1 time in total.

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 664
Joined: Mon Apr 30, 2012 11:07 pm

Re: Using wxWidgets in a Multi-process Architecture

Post by Manolo » Fri Feb 01, 2019 1:31 am

Have you read wx IPC docs?

Post Reply