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: 134
Joined: Fri Aug 17, 2012 2:22 am

Using wxWidgets in a Multi-process Architecture

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using wxWidgets in a Multi-process Architecture

Post by ONEEYEMAN »

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

Thank you.
art-ganseforth
Earned some good credits
Earned some good credits
Posts: 147
Joined: Mon Sep 01, 2014 10:14 am

Re: Using wxWidgets in a Multi-process Architecture

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using wxWidgets in a Multi-process Architecture

Post 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
Use the source, Luke!
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Using wxWidgets in a Multi-process Architecture

Post 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.
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Using wxWidgets in a Multi-process Architecture

Post 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
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Using wxWidgets in a Multi-process Architecture

Post 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.
katuday
Earned some good credits
Earned some good credits
Posts: 134
Joined: Fri Aug 17, 2012 2:22 am

Re: Using wxWidgets in a Multi-process Architecture

Post 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.
Last edited by katuday on Fri Feb 01, 2019 10:08 pm, edited 1 time in total.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Using wxWidgets in a Multi-process Architecture

Post by Manolo »

Have you read wx IPC docs?
Post Reply