Open-Systems-Pharmacology / OSPSuite-R

R package for the OSPSuite
https://www.open-systems-pharmacology.org/OSPSuite-R/
Other
28 stars 12 forks source link

Linux: cannot load simulations which contain chart templates #461

Open Yuri05 opened 3 years ago

Yuri05 commented 3 years ago

If a pkml simulation file contains Chart Templates: loadSimulation fails under Linux with the error

Error in rClr::clrCall(simulationPersister, "LoadSimulation", expandPath(filePath)) :
  Type:    System.DllNotFoundException
Message: libc
Method:
Stack trace:
  at (wrapper managed-to-native) System.Drawing.GDIPlus.uname(intptr)
  at System.Drawing.GDIPlus..cctor () [0x0006e] in <746ccc8f8fd647a0a4a15eb9e9de7f54>:0

Example: S1_CT2.zip

Removing chart templates from a simulation makes it loadabale again. Happens under CentOS7, Ubuntu18.04 and Ubuntu20.04 (as reported by user here)

In order to be able to load the simulation either all chart templates must be deleted first or e.g. a workaround provided by user could be applied.

While in general it seems to be a bug in MONO which cannot be fixed until we upgrade rClr (and enable either working with latest MONO versions or .NET Core) I still wonder why reading Chart Templates require additional dependencies.

With MONO Debugging ON (export MONO_LOG_LEVEL=info) I can see that Deserializing Chart Templates Requires System.Drawing which finally seems to produce this error on Linux:

> loadSimulation("S1_CT2.pkml")
Mono: DllImport attempting to load: 'libc'.
Mono: DllImport error loading library '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc': '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc.so': '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/local/lib64/R/bin/lib/libc': '/usr/local/lib64/R/bin/lib/libc: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/local/lib64/R/bin/lib/libc.so': '/usr/local/lib64/R/bin/lib/libc.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libc': 'libc: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libc.so': '/lib64/libc.so: invalid ELF header'.
Mono: DllImport error loading library 'libc': 'libc: cannot open shared object file: No such file or directory'.
Mono: DllImport unable to load library 'libc: cannot open shared object file: No such file or directory'.
Mono: DllImport attempting to load: 'gdiplus'.
Mono: DllImport error loading library '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libgdiplus': '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libgdiplus: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libgdiplus.so': '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libgdiplus.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/local/lib64/R/bin/lib/libgdiplus': '/usr/local/lib64/R/bin/lib/libgdiplus: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/local/lib64/R/bin/lib/libgdiplus.so': '/usr/local/lib64/R/bin/lib/libgdiplus.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libgdiplus': 'libgdiplus: cannot open shared object file: No such file or directory'.
Mono: DllImport loaded library 'libgdiplus.so'.
Mono: DllImport searching in: 'gdiplus' ('libgdiplus.so').
Mono: Searching for 'GdiplusStartup'.
Mono: Probing 'GdiplusStartup'.
Mono: Found as 'GdiplusStartup'.
Mono: DllImport attempting to load: 'libc'.
Mono: DllImport error loading library '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc': '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc.so': '/usr/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/libc.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/local/lib64/R/bin/lib/libc': '/usr/local/lib64/R/bin/lib/libc: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/usr/local/lib64/R/bin/lib/libc.so': '/usr/local/lib64/R/bin/lib/libc.so: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libc': 'libc: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library 'libc.so': '/lib64/libc.so: invalid ELF header'.
Mono: DllImport error loading library 'libc': 'libc: cannot open shared object file: No such file or directory'.
Mono: DllImport unable to load library 'libc: cannot open shared object file: No such file or directory'.
Error in rClr::clrCall(simulationPersister, "LoadSimulation", expandPath(filePath)) :
  Type:    System.DllNotFoundException
Message: libc
Method:
Stack trace:
  at (wrapper managed-to-native) System.Drawing.GDIPlus.uname(intptr)
  at System.Drawing.GDIPlus..cctor () [0x0006e] in <746ccc8f8fd647a0a4a15eb9e9de7f54>:0

Thus I wonder why System.Drawing is required during the loading of a simulation and how we can avoid this. @msevestre Any thoughts on this?

msevestre commented 3 years ago

@Yuri05 This is probably due to colors being used. (system.drawing is used to get colors) /This should be compatible with .NET standard so this is definitely a bug in Mono. A way around this is to do sthg else to get a color back. We can investigate

msevestre commented 3 years ago

@Yuri05 This is it https://github.com/Open-Systems-Pharmacology/OSPSuite.Core/blob/develop/src/OSPSuite.Core/Chart/ChartSettings.cs#L1

The only way I can think about fixing this is to move to string. This will be a bit of work and I am not sure if this is worth it We would then have to create an extension method whenever we use color to convert that string to color etc..

Let me know your thoughts