gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.51k stars 780 forks source link

Trouble with osgEarthCesium #2493

Closed rebmaso closed 7 months ago

rebmaso commented 7 months ago

Describe the bug Have several problems trying to display tiles from Cesium Ion. I'm running osgearth_viewer cesium_ion.earth -l osgEarthCesium with the following earth files, obtaining bad results. In both cases, I get the message "Unable to load library : osgEarthCesium" Even though libosgEarthCesium.so is installed in usr/local/lib64 alongside libosgEarth.so. I also get the following behavior depending on the earth file.

  1. With the following earth file

    
    <map name="Cesium Ion">
    
    <CesiumIonImage name="bing satellite">
        <asset_id>2</asset_id>
    </CesiumIonImage>
    
    <CesiumIonTerrainMesh name="cesium world terrain">
        <asset_id>1</asset_id>
    </CesiumIonTerrainMesh>

I only see Bing imagery, no terrain. 
Here's the debug info:

osgearth_viewer ../tests/cesium_ion.earth [osgEarth] Hello, world. [osgEarth] [Registry] Note: GDAL_DATA environment variable is not set [osgEarth] [Capabilities] osgEarth Version: 3.5.0 build 151 [osgEarth] [Capabilities] GDAL Version: 3.3.2 [osgEarth] [Capabilities] OSG Version: 3.7.0 [osgEarth] [Capabilities] OSG GL3 Features: yes [osgEarth] [Capabilities] OSG FFP Available: no [osgEarth] [Capabilities] CPU Cores: 6 [osgEarth] [Capabilities] GL_VENDOR: NVIDIA Corporation [osgEarth] [Capabilities] GL_RENDERER: GRID V100S-16Q/PCI/SSE2 [osgEarth] [Capabilities] GL_VERSION: 3.3.0 NVIDIA 525.60.13 [osgEarth] [Capabilities] GL CORE Profile: yes void StateSet::setGlobalDefaults() ShaderPipeline disabled. void StateSet::setGlobalDefaults() ShaderPipeline disabled. [osgEarth] [Map] Map profile is: [srs=WGS84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [osgEarth] [Map] [no cache] [osgEarth] [BingImageLayer] "bing satellite" [srs=Spherical Mercator, min=-20037508.34278925,-20037508.34278925 max=20037508.34278925,20037508.34278925 ar=2:2 vdatum=geodetic] [no cache] [osgEarth] [CesiumIonImageLayer] "bing satellite" [srs=Spherical Mercator, min=-20037508.34278925,-20037508.34278925 max=20037508.34278925,20037508.34278925 ar=2:2 vdatum=geodetic] [no cache] [osgEarth] [CesiumIonImageLayer] "bing satellite" Map/Layer profiles differ; requesting L2 cache [osgEarth] [CesiumIonImageLayer] "bing satellite" L2 cache size = 16 [osgEarth] [engine_rex] Activated! [osgEarth] [TerrainResources] Texture unit 1 reserved for Terrain Color [osgEarth] [TerrainResources] Texture unit 2 reserved for Terrain Elevation [osgEarth] [TerrainResources] Texture unit 3 reserved for Terrain Normals [osgEarth] [TerrainResources] Texture unit 4 reserved for Terrain Parent Color [osgEarth] [TerrainResources] Texture unit 5 reserved for Terrain Land Cover [osgEarth] [RexTerrainEngineNode] Creating 2 root keys. [osgEarth] [MapNodeHelper] Activating logarithmic depth buffer (vertex-only) on main camera [osgEarth] Goodbye.


2. With the following equivalent earth file 
1 2
I get a white globe (neither imagery nor terrain).
Here is the debug info:

osgearth_viewer ../tests/cesium_ion.earth [osgEarth] Hello, world. [osgEarth] [Registry] Note: GDAL_DATA environment variable is not set [osgEarth] [Capabilities] osgEarth Version: 3.5.0 build 151 [osgEarth] [Capabilities] GDAL Version: 3.3.2 [osgEarth] [Capabilities] OSG Version: 3.7.0 [osgEarth] [Capabilities] OSG GL3 Features: yes [osgEarth] [Capabilities] OSG FFP Available: no [osgEarth] [Capabilities] CPU Cores: 6 [osgEarth] [Capabilities] GL_VENDOR: NVIDIA Corporation [osgEarth] [Capabilities] GL_RENDERER: GRID V100S-16Q/PCI/SSE2 [osgEarth] [Capabilities] GLVERSION: 3.3.0 NVIDIA 525.60.13 [osgEarth] [Capabilities] GL CORE Profile: yes void StateSet::setGlobalDefaults() ShaderPipeline disabled. void StateSet::setGlobalDefaults() ShaderPipeline disabled. [osgEarth] [Map] Map profile is: [srs=WGS84, min=-180,-90 max=180,90 ar=2:1 vdatum=geodetic] [osgEarth] [Map] [no cache] [osgEarth] [EarthSerializer2] Failed to find an extension for "cesiumnative3dtiles" [osgEarth] [engine_rex] Activated! [osgEarth] [TerrainResources] Texture unit 1 reserved for Terrain Color [osgEarth] [TerrainResources] Texture unit 2 reserved for Terrain Elevation [osgEarth] [TerrainResources] Texture unit 3 reserved for Terrain Normals [osgEarth] [TerrainResources] Texture unit 4 reserved for Terrain Parent Color [osgEarth] [TerrainResources] Texture unit 5 reserved for Terrain Land Cover [osgEarth] [RexTerrainEngineNode] Creating 2 root keys. [osgEarth] [MapNodeHelper] Activating logarithmic depth buffer (vertex-only) on main camera [osgEarth] Goodbye.



**To Reproduce**
Steps to reproduce the behavior:
1. Build & install main branch cesium-native ( 7faec9f6d47a91cc2697d0d4624d6b7e602b71af ). 
cmake flags: `-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCESIUM_TESTS_ENABLED=OFF`
4. Build & install master branch osgearth ( dfede04de2affce3d1bc1efea4a18f4bf4b20655 ) 
cmake flags: `-DCESIUM_NATIVE_DIR=/usr/local -DOSGEARTH_BUILD_CESIUM_NODEKIT=ON`
5. Set Cesium Ion API key
`export OSGEARTH_CESIUMION_KEY=YOUR_KEY`
6. Launch viewer with earth file above
`osgearth_viewer cesium_ion.earth`

**Expected behavior**
Be able to display cesium Ion tiles on osgearth, in any way.

**Desktop:**
 - OS: Ubuntu LTS 20
 - Version 3.5, latest master branch
jasonbeverage commented 7 months ago

Try adding this to your earth file to see if it lets you load the osgEarthCesium library instead of doing it with -l on the command line and see it does anything different.

<map>
    <libraries>osgEarthCesium</libraries>
</map

You can also try setting the OSG_NOTIFY_LEVEL and OSGEARTH_NOTIFY_LEVEL settings to DEBUG and see if it has any clues as to why osgEarthCesium can't be loaded. See if it actually finds the library on disk and tries to load it in the path you are expecting.

You can also try running ''' ldd /usr/local/lib64/osgEarthCesium.so


and see if it complains about any missing dependencies or other errors.
rebmaso commented 7 months ago

Here's the output of osgearth_viewer, setting the notify level to debug & using <libraries>osgEarthCesium</libraries> My guess is that this way the osgEarthCesium library is loaded, but it looks like some other stuff in osgPlugins is not found, either for cesium image, mesh or 3D tiles layers.

Edit: I also tried ldd /usr/local/lib64/libosgEarthCesium.so and it does not report any issues.

Here's with earth file 1, grepping "cesium". Looks like it does not find the cesium image and mesh libraries.

osgearth_viewer ../tests/cesium_ion.earth | grep cesium
DynamicLibrary::try to load library "osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so"
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib64/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/lib/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/lib64/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib/osgdb_osgearth_cesiumionimage.so ...
FindFileInPath() : trying /usr/local/lib64/osgdb_osgearth_cesiumionimage.so ...
Warning: dynamic library 'osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so' does not exist (or isn't readable):
osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so: cannot open shared object file: No such file or directory
DynamicLibrary::failed loading "osgPlugins-3.7.0/osgdb_osgearth_cesiumionimage.so"
DynamicLibrary::try to load library "osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so"
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib64/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/lib/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/lib64/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib/osgdb_osgearth_cesiumionterrainmesh.so ...
FindFileInPath() : trying /usr/local/lib64/osgdb_osgearth_cesiumionterrainmesh.so ...
Warning: dynamic library 'osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so' does not exist (or isn't readable):
osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so: cannot open shared object file: No such file or directory
DynamicLibrary::failed loading "osgPlugins-3.7.0/osgdb_osgearth_cesiumionterrainmesh.so"
[osgEarth]  Getting endpoint https://api.cesium.com/v1/assets/2/endpoint?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNzVkNzRmYi04OGY0LTRkNTEtYWY1My01YjEwYjY3YTcxNjgiLCJpZCI6MjAzMjc3LCJpYXQiOjE3MTA5MzMyODZ9.wgndkasTSCXwC8PdAwqU6tdN7tuTxxGYAYrA6Hp5SMw

Here's the output with earth file 2, grepping "cesium". Looks like it does not find the 3Dtiles library.

osgearth_viewer ../tests/cesium_ion.earth | grep cesium
DynamicLibrary::try to load library "osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so"
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib64/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib64/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib/osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/lib/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/lib64/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib/osgdb_osgearth_cesiumnative3dtiles.so ...
FindFileInPath() : trying /usr/local/lib64/osgdb_osgearth_cesiumnative3dtiles.so ...
Warning: dynamic library 'osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so' does not exist (or isn't readable):
osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so: cannot open shared object file: No such file or directory
DynamicLibrary::failed loading "osgPlugins-3.7.0/osgdb_osgearth_cesiumnative3dtiles.so"
osgearth_viewer: /usr/local/include/CesiumUtility/ReferenceCounted.h:62: void CesiumUtility::ReferenceCounted<T, isThreadSafe>::addReference() const [with T = CesiumRasterOverlays::RasterOverlay; bool isThreadSafe = false]: Assertion `std::this_thread::get_id() == this->_threadID' failed.
rebmaso commented 7 months ago

@jasonbeverage I apologize for not adding more context to my last comment.

I checked, and those cesium-related osgearth shared libraries like osgdb_osgearth_cesiumnative3dtiles are not built (and thus not installed) ("steps to reproduce" above shows how I compiled). However, libosgEarthCesium.so is indeed built and installed, and no build errors pop up.

How is that possible?

Thanks!

jasonbeverage commented 7 months ago

There is no osgdb_osgearth_cesiumnative3dtiles.so that is built, it is all done in the osgEarthCesium library itself and things get registered with the osg plugin system. Try putting some print out code in the CesiumNative3DTilesLayer::openImplementation() to see if it's actually attempting to load the layer at all. I have a feeling you just have some libraries that are in the wrong location or something and they aren't getting loaded.

rebmaso commented 7 months ago

Got it. I put some print in CesiumNative3DTilesLayer::openImplementation() and it executes.

Looking back at the osgearth_viewer ../tests/cesium_ion.earth | grep cesium output, I can see that the /usr/local/lib64/osgPlugins-3.7.0 is full of osgearth plugins, minus the cesium ones.

Those cesium shared objects like osgdb_osgearth_cesiumnative3dtiles.so are nowhere to be found in my computer.

How is it that osgearth builds fine but does not create those plugins?

Is there anything wrong in my build pipeline? 1) Build & install main branch cesium-native ( 7faec9f6d47a91cc2697d0d4624d6b7e602b71af ). cmake flags: -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCESIUM_TESTS_ENABLED=OFF 2) Build & install master branch osgearth ( https://github.com/gwaldron/osgearth/commit/dfede04de2affce3d1bc1efea4a18f4bf4b20655 ) cmake flags: -DCESIUM_NATIVE_DIR=/usr/local -DOSGEARTH_BUILD_CESIUM_NODEKIT=ON

Thanks.