Remove this ad

Lead

Dec 1 13 12:45 AM

Tags : :

I did not understand the reason, but aMule crash on start on Mac OS if built against wxWidgets 3.0 (COCOA).

The crash is in amuleDlg.cpp, method DoNetworkRearrange: it seems that aMule crashes if we remove all pages from wxNotebook "networks_notebook".

Currently the only solution that I was able to find is in the attached patch (at least if I will be able to attatch it to this post ).

My only concern is about the commented wxWindowUpdaterLocker: using it as it is in currewnt SVN causes problems in refresh of window if we change in Preferences netowk settings (such as enable/disable kad and/or ed2k).

Any suggestions?

NOTICE:
I must say "Thank you Stu, you showed me the light" because this attempt-of-patch is in the truth a patch of his patch
--------------------
Click here to view the attachment
Quote    Reply   
Remove this ad
Remove this ad

#3 [url]

Dec 1 13 12:34 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Good to have a Mac developer again.
I'm pretty sure this patch doesn't work correctly, at least not with both networks enabled.
I have gone through the code, rearranged it and cleaned it up a bit.
Also I have disabled the Notebook now before clearing it (maybe that is what Cocoa doesn't like) and added your disable-freezer. Please try it, if it still fails we'll work our way from there.

Quote    Reply   

#4 [url]

Dec 1 13 3:34 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Stu,
SVN rev10821 still does not work: same crash when the second page is removed in
[code]
while (networks_notebook->GetPageCount() > 0) {
networks_notebook->RemovePage(networks_notebook->GetPageCount() - 1);
}
[/code]

Anyway, my fault, probably this night I was too tired to notice, but I sent the wrong patch!

The correct patch against 10816 is pretty much similar to the previously posted BUT has NOT COMMENTED the code to remove the KAD page
[code]

#if !wxCHECK_VERSION(3,0,0) || !defined(__WXOSX_COCOA__)
while (networks_notebook->GetPageCount() > 0) {
networks_notebook->RemovePage(networks_notebook->GetPageCount() - 1);
}
#else
// wxWidgets >= 3.0 crashes if we remove all pages from networks_notebook
// So remove just the KAD panel (and then re-add it - and only it - later if needed)
int kad_page = networks_notebook->FindPage(m_networkpages[1].page);
if (kad_page != wxNOT_FOUND) networks_notebook->RemovePage(kad_page);
#endif
[/code]

instead of

[code]

#if !wxCHECK_VERSION(3,0,0) || !defined(__WXOSX_COCOA__)
while (networks_notebook->GetPageCount() > 0) {
networks_notebook->RemovePage(networks_notebook->GetPageCount() - 1);
}
#else
// wxWidgets >= 3.0 crashes if we remove all pages from networks_notebook
// So remove just the KAD panel (and then re-add it - and only it - later if needed)
// int kad_page = networks_notebook->FindPage(m_networkpages[1].page);
// if (kad_page != wxNOT_FOUND) networks_notebook->RemovePage(kad_page);
#endif
[/code]

(the commented lines causes to have the KAD page doubled).

I tried again the patch with following steps:
1) start amule with both network enabled: amule starts correctly
2) click on "Networks": both network pages are correctly displayed, currently selected is ED2K
3) click on Kad page: everything is OK
4) click again on ED2K: everything is OK
5) in preferences disable Kad Network: "Networks" button become "ed2k network", there are no more "the titles" of pages (labels of wxNotebook) and only ED2K panel is displayed
6) enable again Kad Network: "ed2k network" come back "Networks", and the original wxNotebook appears as at the beginning
7) disable ed2k in Preferences, "Networks" button becomes "Kad network", no more wxNotebook labels and the Kad panel is displayed correctly
8) re-enabled ed2k: amule warns me to restart because I changed ed2k settings, I have again "Networks" button and the wxNotebook as at the beginning

I also tried starting amule with just one network (tried with kad only and with ed2k only) enabled and everything seems to work.

BUT: amule is built without optimizations and with debug enabled... I still have to try with optimizations and without debug (I have always doubts about wxWindowUpdateLocker), and I used it just to make this silly and short tests!

If you think that is would be better, I can also build a "mix" of rev10821 and this patch just to avoid to remove all the pages from wxNotebook.

My curiosity/doubt is:
- bug in aMule?
- OR wanted but changed behavior in wxWidgets 3.0/COCOA?
- OR bug in wxWidgets 3.0/COCOA?

Another thing: I'm not a Mac developer, just a guy that plays with code and I don't know a millionth of one percent about Mac (words stolen from Thomas A. Edison )

Bye,
Mr Hyde

Quote    Reply   

#6 [url]

Dec 1 13 10:18 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

mr_hyde wrote:
Another thing: I'm not a Mac developer, just a guy that plays with code and I don't know a millionth of one percent about Mac (words stolen from Thomas A. Edison )

Well, then you know more about Mac than anybody on the dev team, and you have one to try things out. And you can write code and submit patches. That makes you the current Mac dev, like it or not.

I've tried your patch, and it works on Windows too (without the ifdefs of course, otherwise it would just be the same). The problem is, it makes no sense. If you just leave both pages in the notebook as it should work, then the notebook is garbled when it gets displayed - KAD and ED2K page overlaid. (After one click on the Kad tab it is fine.) Setting the Kad Tab as first current page doesn't help either. Why leaving one page in the notebook but not the other makes things work is unexplained.

I want a solution that works on all platforms, and that works understandably. I'll give it some more thought. Meanwhile, keep using what works for you.

Quote    Reply   

#7 [url]

Dec 2 13 8:19 AM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

I fully agree with you!
the things I thought:
- DoNetworkRearrange is called at the end of class constructor: this sometimes causes problems (especially in case of structures of derived class and with virtual methods) but probably this is not our case; I tried to call the first time DoNetworkRearrange from timer but I noticed issues (I will repeat the test)
- removing/adding at least one page each time triggers something (message/event?) and that something "fixes" the layout. The point is: what exactly is this something?

In the free time I will continue to investigate.

Anyway tell me if you want that I make available the binaries built with this fix... well, I guess that the correct term is not "fix" but "workaround"!

Another issue: this is present since Lion (if I remember correctly) and amule 2.3.1 (maybe also other previous versions of aMule?), and we have it "randomly".
When MacOS firewall is active, SOMETIMES (I hate the SOMETIMES word when looking for a problem) amule does not release/close the listening UDP socket (default on 4672) when shutting down.
aMule seems to die correctly, but in netstat the port is shown as in LISTEN, so if I restart aMule, aMule fails to open again the socket (because port is already used).
Obviously when this happens, usually I have no active logs related to UDP/networking, sgrunt
And, probably due to my inexistent knowledge of Mac, the only things to do are:
- change UDP port value in amule Preferences
- OR reboot the Mac!
- OR (but never tried till now) call The Exorcist

Bye,
Mr Hyde

Quote    Reply   

#8 [url]

Dec 2 13 9:14 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

- DoNetworkRearrange: I have an idea how to rearrange things so it will work and hopefully look not much more cumbersome than it does now.

- Binaries: Does the rest work now? If yes - yeah make some binaries please. With the workaround of course.

- UDP port: I really don't want to discuss this in depth in this thread - please make a new one. Only so far: if a process dies it releases all its resources (at least in a half decent OS). The problem may be that the FIREWALL is actually listening on the port and doesn't realize the app it is forwarding the data to has exited.

Quote    Reply   

#9 [url]

Dec 2 13 10:07 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

- DoNetworkRearrange: ok, waiting for new ideas/tests to execute.
Another workaround: skip removal of both pages and force a couple of ChangeSelection to force the correct redraw as follows
[code]
// Set the main window.
// If we have both networks active, activate a notebook to select between them.
// If only one is active, show the window directly without a surrounding one tab notebook.
wxNotebook* networks_notebook = CastChild(ID_NETNOTEBOOK, wxNotebook);
// The pages have to be removed from the notebook to be reassigned to the window correctly.
// (Otherwise they could stay in the notebook all the time.)
networks_notebook->Show(false);

// Mr Hyde NOT IN OSX COCOA - BEGIN
#if !defined(__WXOSX_COCOA__)
while (networks_notebook->GetPageCount() > 0) {
networks_notebook->RemovePage(networks_notebook->GetPageCount() - 1);
}
#endif
// Mr Hyde NOT IN OSX COCOA - END

m_networkpages[0].page->Show(thePrefs::GetNetworkED2K());
m_networkpages[1].page->Show(thePrefs::GetNetworkKademlia());

wxWindow* replacement = NULL;

m_networknotebooksizer->Clear();

if (thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia()) {
toolbarTool->SetLabel(_("Networks"));
m_networkpages[0].page->Reparent(networks_notebook);
m_networkpages[1].page->Reparent(networks_notebook);

// Mr Hyde ONLY IN OSX COCOA - BEGIN
#if !defined(__WXOSX_COCOA__)
networks_notebook->AddPage(m_networkpages[0].page, m_networkpages[0].name);
networks_notebook->AddPage(m_networkpages[1].page, m_networkpages[1].name);
#else
// To force correct redraw of both pages
// change selection to KAD page then come back to ED2K
networks_notebook->ChangeSelection(1);
networks_notebook->ChangeSelection(0);
#endif
// Mr Hyde NOT IN OSX COCOA - END
networks_notebook->Show(true);
[/code]

I discovered also that the problem of the "overlapped" layouts seems related to the lines

m_networkpages[0].page->Show(thePrefs::GetNetworkED2K());
m_networkpages[1].page->Show(thePrefs::GetNetworkKademlia());

if I skip these the pages are correctly displayed, but in this way the behavior is not correct when I start with just one network and also in another case that now I don't remember

- UDP port: if the problems comes out again I will open a new thread (the previous post was just a... "spoiler" )

- Binaries: I will use this version for a while (with patch) just to test it before make it "public"

Bye,
Mr Hyde

Quote    Reply   

#10 [url]

Dec 2 13 10:42 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

mr_hyde wrote:
I discovered also that the problem of the "overlapped" layouts seems related to the lines

m_networkpages[0].page->Show(thePrefs::GetNetworkED2K());
m_networkpages[1].page->Show(thePrefs::GetNetworkKademlia());

Now this was the hint that hopefully brought me on track. Please try out if 10824 fixes the thing at last.

Quote    Reply   
Remove this ad

#11 [url]

Dec 3 13 7:29 AM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Stu, please don't hate me...

Just tried rev10824: pages of wxNotebook seems to work correctly BUT statuses of networks in lower right corner are not updated correctly (at least in built without debug and with optimizations, this evening I will rebuild with debug).

To try:
- start with both network enabled
- disable kad
- look at the lower-right connect: kad status is still there
- if I change the selected network statuses are correctly updated

Same thing if you start with just one network enabled and then add the the one: in the corner is displayed just the first network.

Bye,
Mr Hyde

Quote    Reply   

#12 [url]

Dec 3 13 5:28 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

I hate you.

I tried an older version and it fails just the same.
The bigger problem: you have both networks enabled. Now disable Kad (it gets disconnected). Then reenable Kad. It stays disconnected. But the connect button stays in "disconnect" state. So to connect Kad, you first have to hit "disconnect" (disconnect ED2K), then "connect" (connect both).

But since people don't activate/deactivate networks on a daily basis I'll leave well enough alone. I've fixed the status line though (never looked there I admit).

Quote    Reply   

#13 [url]

Dec 3 13 10:30 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Instead I love you

Rev10825 has DoNetworkRearrange working (at least it seems working to me!)

Thanks again!

I will continue to use it to test it for a while.

Bye,
Mr Hyde

Quote    Reply   

#14 [url]

Dec 14 13 8:07 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Ehm... Not sure but probably we broke something in Linux!

I tried to build latest SVN also in Linux (Slackware 64 bit, KDE) with wxWidgets 3.0 and I noticed that, even if I have both network enabled, only ED2K panel is visible (also the "tab" named Kad is missing).

I don't know with Windows (not tried yet to build it).

Quote    Reply   

#15 [url]

Dec 15 13 8:58 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Sigh.
I'll fire up my bluescreening Virtual Box again and check it out.
I can assure you it works in Windows.

Quote    Reply   

#16 [url]

Dec 20 13 5:03 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Current SVN fails miserably in GTK (with wx 2.8 too).
Yay for "cross platform development with wxwidgets". >

Quote    Reply   

#17 [url]

Dec 22 13 6:22 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Rearranged things again (10827), now it works on Win and GTK. Please test Cocoa.
At least Virtual Box doesn't bluescreen any more (crosses fingers).

Quote    Reply   

#19 [url]

Dec 23 13 10:56 PM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Ok, tried, but...

1) with wx2.8.x/Carbon work as it is
2) with wx3.0/OSXCocoa the problem is always the locker (but "I see the light at the end of the tunnel"...).
I was able to use the locker also in wx3.0 by "re-ordering" the code to limit the scope of the locker (see attached patch - well, attempt of path ).

The patch seems to work also in Linux (Slackware 64/KDE) with wx3.0.
Not tried (yet) with MacOS wx2.8/Carbon.

Oh, I was forgetting the most important thing: MERRY CHRISTMAS!!!

Bye,
Mr Hyde
--------------------
Click here to view the attachment

Quote    Reply   

#20 [url]

Dec 24 13 12:04 AM

Re: MacOS, wx 3.0/COCOA, crash in DoNetworkRearrange

Yay, merry Christmas to you as well, and to all you other guys!

[quote]
1) with wx2.8.x/Carbon work as it is
Not tried (yet) with MacOS wx2.8/Carbon.
You are confusing me.

What happens if you leave the code as it is and just remove the freezer as we had before ?
[code]#if !defined(__WXOSX_COCOA__)
// in Mac OS with wxWidgets >= 3.0 and COCOA the following seems to cause problems
// (window is not refreshed after changes in network settings)
wxWindowUpdateLocker freezer(this);
#endif
[/code]

Quote    Reply   
Remove this ad
Add Reply

Quick Reply

bbcode help