Rasbats / SailawayNMEA_pi

For connecting OpenCPN to the Sailaway SimGame
Apache License 2.0
0 stars 1 forks source link

Mac plugin failing to load #1

Open wright opened 2 years ago

wright commented 2 years ago

Hello,

I am getting this error in the OpenCPN 5.6.0 log after running SailawayNMEA-Plugin_0.2.pkg:

14:31:00.922 MESSAGE pluginmanager.cpp:1132 Checking plugin candidate: /Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib
14:31:00.922 MESSAGE pluginmanager.cpp:2178 Plugin is compatible: true
14:31:00.922 MESSAGE pluginmanager.cpp:2267 PlugInManager: Loading PlugIn: /Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib
14:31:00.924   ERROR dlunix.cpp:120 Failed to load shared library '/Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib': dlopen(/Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib, 2): Symbol not found: __ZN8wxWindow15DragAcceptFilesEb
  Referenced from: /Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib
  Expected in: flat namespace
 in /Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib
14:31:00.924 MESSAGE pluginmanager.cpp:2331    PlugInManager: Cannot load library: /Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib
14:31:00.924 MESSAGE pluginmanager.cpp:2335 Jailing: /Applications/OpenCPN.app/Contents/Plugins/SailawayNMEA_pi/libSailawayNMEA_pi.dylib

Is there a known cause for this? Thanks.

Rasbats commented 2 years ago

Is there a known cause for this?

Yes ... OpenCPN 5.6 on the Mac uses wxWidgets-3.1.5. Have you used this plugin successfully in the past? If so I will make a release version and put it in the catalog.

wright commented 2 years ago

No, this is the first time I have tried both OpenCPN and this plugin. So, SailawayNMEA-Plugin_0.2 is compatible with an older version of OpenCPN? (e.g., 5.2.4?)

wright commented 2 years ago

I just checked, and SailawayNMEA-Plugin_0.2 is compatible with OpenCPN 5.2.4. Maybe it would be a good idea to make a new version for the newer OpenCPN. It does not show up in the catalog in OpenCPN 5.6.0.

Rasbats commented 2 years ago

Is it worth it?

wright commented 2 years ago

I don't know. I have just started trying to use it.

wright commented 2 years ago

I am still trying to get SailawayNMEA-Plugin_0.2 working with OpenCPN 5.2.4. The plugin shows up, is enabled, and can bring up the SailawayNMEA configuration. I have the UDP port 57343 connection set up in OpenCPN. However, when I click on "Load Boats" in the SailawayNMEA configuration dialog, nothing happens. I have tried both my Sailaway email and nickname in the SailawayNMEA "User name" dialog box. Any suggestions?

Rasbats commented 2 years ago

No NMEA feed myself tonight. I will look at this tomorrow.

Rasbats commented 2 years ago

No luck here. But the app that this plugin is based on does work and allows a connection:

You may want to try using this program: https://github.com/expilu/sailaway-api-to-nmea

I will try to find out where the issue is with the plugin.

Rasbats commented 2 years ago

Ted ... Thanks for raising this one. I have updated the code. Now making some Cloudsmith repos. When I have a tarball that works on the Mac I will advise the URL for a download.

wright commented 2 years ago

I tried sailaway-api-to-nmea, and it works with my Sailaway nickname. However, I don't normally have a Windows computer around to run it, so I like the idea of this OpenCPN plugin that runs on Macs.

If you are building a new version, please consider updating to OpenCPN 5.6.0 compatibility. Most of the other OpenCPN plugins are only available for the newer version.

Rasbats commented 2 years ago

A Mac tarball for OpenCPN 5.6.0 is here: https://cloudsmith.io/~mike-rossiter/repos/sailawaynmea-alpha/packages/detail/raw/SailawayNMEA-0.4-darwin-wx315-10.13.6-tarball/0.4.0+268.0f897ba/ Working on my Mac Mini (Catalan). Could you give it a test?

wright commented 2 years ago

I tried this with a fresh installation of OpenCPN 5.6.0. I assume that I am supposed to "Import plugin" and select the tarball (at least that makes some progress):

Importing the plugin, I see this in the log:

07:55:33.732 MESSAGE PluginHandler.cpp:159 Plugin: setting up, name:  SailawayNMEA 
07:55:33.747 MESSAGE pluginmanager.cpp:5387 Copied /Users/wright/Downloads/SailawayNMEA-0.4.0+268.0f897ba_darwin-wx315-10.13.6-x86_64.tar.gz to local cache
07:55:33.766 MESSAGE PluginHandler.cpp:159 Plugin: setting up, name: SailawayNMEA

Clicking on the imported plugin to install it, I see this in the log:

07:58:29.451 MESSAGE PluginHandler.cpp:693 Installing SailawayNMEA-0.4-darwin-wx315-10.13.6/OpenCPN.app/Contents/PlugIns/ into /Users/wright/Library/Application Support/OpenCPN/Contents/PlugIns/

Clicking on the SailawayNMEA icon to open it, I see this in the log:

08:00:47.947   ERROR ffile.cpp:57 can't open file '/Applications/OpenCPN.app/Contents/SharedSupport/plugins/SailawayNMEA_pi/data/blank.ico' (error 2: No such file or directory)
08:00:47.947   ERROR image.cpp:2688 Failed to load image from file "/Applications/OpenCPN.app/Contents/SharedSupport/plugins/SailawayNMEA_pi/data/blank.ico".

Note: this file does exists at: /Users/wright/Library/Application Support/OpenCPN/Contents/SharedSupport/plugins/SailawayNMEA_pi/data/blank.ico

After this, the SailawayNMEA dialog opens and no further log messages appear. I enter my user name, and the "Load Boats" button works; the boat field is populated. I click start server: A dialog box pops up with the OpenCPN logo that says " Message Error" and an OK button. I press OK and a dialog box opens with the OpenCPN logo that says " Message Starting NMEA feed" and an OK button. I press OK and OpenCPN crashes

Rasbats commented 2 years ago

@wright :Thanks. I will take a look. We don't need blank.ico.

Rasbats commented 2 years ago

Build 278(Mac) is now in Cloudsmith. https://cloudsmith.io/~mike-rossiter/repos/sailawaynmea-alpha/packages/detail/raw/SailawayNMEA-0.4-darwin-wx315-10.13.6-tarball/0.4.0+278.bad2c2b/

Rasbats commented 2 years ago

Suggest uninstalling the previous build. You may also need to remove the libSailawayNMEA_pi.dylib plugin file if uninstalling has not removed it..

wright commented 2 years ago

I uninstalled, and installed the new version.

I did not see any errors in the log, but runtime behavior was the same. "Load Boats" worked, but "Start Server" pops up the two dialog boxes and OpenCPN crashes without writing anything to the log.

Rasbats commented 2 years ago

Is this with the two connections set up/ticked in OpenCPN: TCP port 10110 and UDP port 57343?

Rasbats commented 2 years ago

You may also need to remove the libSailawayNMEA_pi.dylib plugin file

Had to do this to stop crashes at one point.

wright commented 2 years ago

I was missing the TCP port, but have the same behavior after adding it. libSailawayNMEA_pi.dylib was removed when I did the uninstall. I just deleted everything (both the OpenCPN.app and the directory in Application Support) and reinstalled from scratch, and it is still crashing.

Rasbats commented 2 years ago

Thanks for sticking with it. Not sure where to take this. I had a number of crashes. Deleted the plugin totally and then opened and closed OpenCPN a couple of times to get rid of the warning about a crash "Do you want to run in safe mode?". Why it retained that warning I don't know but after a new install it worked on the Mac here. I will do some more digging.

Rasbats commented 2 years ago

Icon making was experimental. Reverted to known method used in working plugins. Installs fine on Windows and MacOS. I have cleaned up the builds and Cloudsmith so that only MSVC and MacOS builds are made. Sailaway app only runs on these two OS.

wright commented 2 years ago

I am still getting the blank Error dialog and crash with build 292 on MacOS.

I have not tried it yet, but OpenCPN runs on Android tablets, and it might be useful to run that along side Sailaway (I assume a Network Address would need to be changed in the OpenCPN connections dialog?). I think there is a use case for more builds.

Rasbats commented 2 years ago

And this is with all the previous dylib and SailawayNMEA plugin stuff removed?

I think there is a use case for more builds

But Sailaway only runs on MacOS and MSVC?

wright commented 2 years ago

Yes, I deleted OpenCPN and its Application Support directory, and reinstalled from scratch with build 292.

OpenCPN (and this plugin) can run on a different device/display and get data from Sailaway. Doesn't the Sailaway data actually come from the Sailaway web server? So OpenCPN and SailawayNMEA should work even when Sailaway is not running locally (for instance, when there is an "offline" boat in Sailaway and the server is updating its position).

Rasbats commented 2 years ago

should work even when Sailaway is not running locally

You are correct. But I need to get this running on the Mac first! Compiled my own tarball locally and again no problems for me. What version of MacOS are you running?

wright commented 2 years ago

I'm running 10.14.6. I agree that restricting the number of builds until it is working is a good idea.

wright commented 2 years ago

I'm seeing this in the OSX crash report:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000048
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [7691]

VM Regions Near 0x48:
--> 
    __TEXT                 000000010fc0f000-000000011054b000 [ 9456K] r-x/r-x SM=COW  /Applications/OpenCPN.app/Contents/MacOS/OpenCPN

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libwx_baseu_net-3.1.5.0.0.dylib 0x0000000110c5dc68 wxSocketBase::LastError() const + 8
1   libSailawayNMEA_pi.dylib        0x000000011870235b Dlg::Init_Datagram_Socket() + 475
2   libSailawayNMEA_pi.dylib        0x00000001187020d0 Dlg::OnStartServer(wxCommandEvent&) + 64
3   libwx_baseu-3.1.5.0.0.dylib     0x000000011159a67e wxEvtHandler::SearchDynamicEventTable(wxEvent&) + 222
...
Rasbats commented 2 years ago

Thanks. That was useful. https://developer.apple.com/documentation/network/ipv4address I have changed the deployment target to 10.14 (Mojave). Also Sailaway has asked for a slow download of data (10 minute interval) to avoid overloading the webserver. New builds have been made. MacOS is now #293.

wright commented 2 years ago

I'm still getting the crash with version 293.

wright commented 2 years ago

I think the empty Error dialog just before the crash is coming from line 792 of src/SailawayNMEAgui_impl.cpp. If so, it is due to wxGetFullHostName() failing. I'm not sure why that would fail (or why the host name is necessary).

Rasbats commented 2 years ago

MacOS #294 has a lot of stuff removed around wxGetFullHostName(). On Windows I get an intermittent feed from Sailaway but that can be sorted later, if there is no crash on the Mac.

Rasbats commented 2 years ago

No ... crashes on Catalan.

wright commented 2 years ago

I'm still getting the same crash, with the same traceback, but without the empty Error dialog.

Are you sure these two lines are necessary:

    m_LocalAddress.Hostname(wxGetFullHostName() );
   // if(!success) wxMessageBox(wxT("Error"));
    wxString ipAddress = m_LocalAddress.IPAddress();

They seem redundant with:

    m_LocalAddress.AnyAddress();
Rasbats commented 2 years ago

295 works on Catalan. Same intermittent feed as Windows.

ipAddress does not seem to be used. I will try removing it.

wright commented 2 years ago

296 still crashes for me. Will you please try commenting out:

m_LocalAddress.Hostname(wxGetFullHostName() );
wright commented 2 years ago

297 crashed for me.

Rasbats commented 2 years ago

And me. Added m_LocalAddress.Hostname(wxGetFullHostName() ) again. This function relies on the include wx/utils.h which was not included in the code. It is now. Another build on the way.

wright commented 2 years ago

298 crashed for me, in the same manner.

wright commented 2 years ago

I might be confused because I am not set up to actually try to compile this code, but doesn't SailawayNMEA only send on the UDP socket? If so, I don't think it needs to know the local IP address, and the network code could be simpler. Maybe something like this:

// setup socket
wxIPV4address m_LocalAddress;
m_LocalAddress.AnyAddress(); // 0.0.0.0
wxDatagramSocket socketOut = new wxDatagramSocket(m_LocalAddress, wxSOCKET_BROADCAST | wxSOCKET_NOBIND);
wxIPV4address ipBroadcastAddress;
ipBroadcastAddress.BroadcastAddress(); // 255.255.255.255
ipBroadcastAddress.Service(PORT);

// then to send:
socketOut->SendTo(ipBroadcastAddress, message.data(), strlen(message.data()));
Rasbats commented 2 years ago

Thanks. Now only using send on the UDP.

299 is working for me but .....?

wright commented 2 years ago

299 crashed for me in the same manner.

I think you need 2 different wxIPV4address structures. One for the local address used in wxDatagramSocket to create the socket, and one for the broadcast address used in SendTo. It looks like you are using the same structure in both calls.

Rasbats commented 2 years ago

I think you need 2 different wxIPV4address structures

Done. #300

On the Mac, if you have a compiler and bash you can make a tarball using the script: ./ci/circleci-build-macos.h First stage builds into the os-x directory. From there "make tarball"

wright commented 2 years ago

300 is a winner! It all seems to be working for me now. Thanks!

Rasbats commented 2 years ago

@wright :+1: Thanks for your help.

wright commented 2 years ago

You are welcome. Let me know if there is anything else you would like me to test on a Mac.

wright commented 2 years ago

I hate to mention it, but I am seeing a problem with the dead reckoning position. The new calculated position looks as if it is based on a speed about 5 times too high.

The speed as read from Sailaway is correct (although you should probably use groundSpeed instead of waterSpeed for getting the new position). I'm not sure what this line is trying to do:

double spd = (drBoat.waterSpeed)/60/6; // to change later to allow for download interval

The spd variable is passed in destLoxodrome as a distance. Maybe it is assuming an inaccurate update rate? I will run some more tests.

Rasbats commented 2 years ago

:( Having another look!

Rasbats commented 2 years ago

Original DR interval was 10 secs. I found the boat lost position and reduced the interval to 1 sec. Now back at 10 sec and using groundSpeed. Strictly DR is waterSpeed but I agree that groundSpeed will better position the boat for the next upload from Sailaway.

306 is in Cloudsmith alpha.

wright commented 2 years ago

I installed #306, and gave it a very brief test. It looks to me like the DR updates are actually happening about every 1.9 seconds on my computer.

It might be more accurate to calculate the distance based on groundSpeed times time since the last real data retrieval, and offset that distance from the last position at the last data retrieval. That should accumulate fewer errors if the data update timing is not exactly right.

Rasbats commented 2 years ago

Speed now seems to match Sailaway. I am only updating from Sailaway every 10 minutes as discussed before. Stopping the server and starting again provides a quick check of speeds.