Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SkyboltExamples MinimalApp failure #2

Closed
kit047 opened this issue Jan 20, 2021 · 11 comments
Closed

SkyboltExamples MinimalApp failure #2

kit047 opened this issue Jan 20, 2021 · 11 comments

Comments

@kit047
Copy link

kit047 commented Jan 20, 2021

I am experiencing a segfault when attempting to run the MinimalApp in SkyboltExamples in Ubuntu 20.04. I assume this is due to some configuration issues on my part, but I am not sure. I am fairly new with gl programming so let me know if I can provide any addition information.

The segfault seems to occur when attempting to load tile images. I am running with OpenSceneGraph 3.6.4 and am using a settings file with my mapbox apikey. I have downloaded all 3 asset packages you provided (Core, EarthMed, Seattle). When I run the app, a window is created (it is all black) and a few moments later it segfaults.

I attempted to run the app without loading the PlanetEarth entity to avoid the issue. This does not produce a segfault and the app doesnt die, but the window is just filled black and it doesnt seem to be taking any inputs. Also, I can't close the app via the esc key or the 'x' in the window.

Here is my callstack if it helps:

osgdb_curl.so!osg_curl::EasyCurl::StreamObject::write(char const*, unsigned long) (Unknown Source:0)
osgdb_curl.so!osg_curl::EasyCurl::StreamMemoryCallback(void*, unsigned long, unsigned long, void*) (Unknown Source:0)
libcurl-gnutls.so.4![Unknown/Just-In-Time compiled code] (Unknown Source:0)
libcurl-gnutls.so.4!curl_multi_perform (Unknown Source:0)
libcurl-gnutls.so.4!curl_easy_perform (Unknown Source:0)
osgdb_curl.so!osg_curl::EasyCurl::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, osg_curl::EasyCurl::StreamObject&, osgDB::Options const*) (Unknown Source:0)
osgdb_curl.so!osg_curl::ReaderWriterCURL::readFile(osg_curl::ObjectType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, osgDB::Options const*) const (Unknown Source:0)
osgdb_curl.so!osg_curl::ReaderWriterCURL::readImage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, osgDB::Options const*) const (Unknown Source:0)
libosgDB.so.160!osgDB::Registry::ReadImageFunctor::doRead(osgDB::ReaderWriter&) const (Unknown Source:0)
libosgDB.so.160!osgDB::Registry::read(osgDB::Registry::ReadFunctor const&) (Unknown Source:0)
libosgDB.so.160!osgDB::Registry::readImplementation(osgDB::Registry::ReadFunctor const&, osgDB::Options::CacheHintOptions) (Unknown Source:0)
libosgDB.so.160!osgDB::Registry::readImageImplementation(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, osgDB::Options const*) (Unknown Source:0)
osgDB::Registry::readImage(osgDB::Registry * const this, const std::__cxx11::string & fileName, const osgDB::Options * options) (/usr/include/osgDB/Registry:222)
skybolt::vis::readImageWithoutWarnings(const std::__cxx11::string & filename) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/OsgImageHelpers.cpp:138)
skybolt::vis::XyzTileSource::createImage(skybolt::QuadTreeTileKey const&, std::function<bool ()>) const(const skybolt::vis::XyzTileSource * const this, const skybolt::QuadTreeTileKey & key, std::function<bool()> cancelSupplier) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/TileSource/XyzTileSource.cpp:40)
skybolt::vis::SphericalMercatorToPlateCarreeTileSource::createImage(skybolt::QuadTreeTileKey const&, std::function<bool ()>) const(const skybolt::vis::SphericalMercatorToPlateCarreeTileSource * const this, const skybolt::QuadTreeTileKey & key, std::function<bool()> cancelSupplier) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/TileSource/SphericalMercatorToPlateCarreeTileSource.cpp:97)
skybolt::vis::CachedTileSource::createImage(skybolt::QuadTreeTileKey const&, std::function<bool ()>) const(const skybolt::vis::CachedTileSource * const this, const skybolt::QuadTreeTileKey & key, std::function<bool()> cancelSupplier) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/TileSource/CachedTileSource.cpp:36)
skybolt::vis::TileImageLoader::<lambda(const skybolt::QuadTreeTileKey&)>::operator()(const skybolt::QuadTreeTileKey &) const(const skybolt::vis::TileImageLoader::<lambda(const skybolt::QuadTreeTileKey&)> * const __closure, const skybolt::QuadTreeTileKey & key) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/TileImageLoader.cpp:138)
std::_Function_handler<osg::ref_ptr<osg::Image>(const skybolt::QuadTreeTileKey&), skybolt::vis::TileImageLoader::load(const skybolt::QuadTreeTileKey&, std::function<bool()>) const::<lambda(const skybolt::QuadTreeTileKey&)> >::_M_invoke(const std::_Any_data &, const skybolt::QuadTreeTileKey &)(const std::_Any_data & __functor,  __args#0) (/usr/include/c++/8/bits/std_function.h:283)
std::function<osg::ref_ptr<osg::Image> (skybolt::QuadTreeTileKey const&)>::operator()(skybolt::QuadTreeTileKey const&) const(const std::function<osg::ref_ptr<osg::Image>(const skybolt::QuadTreeTileKey&)> * const this,  __args#0) (/usr/include/c++/8/bits/std_function.h:687)
skybolt::vis::TileImageLoader::getOrCreateImage(skybolt::QuadTreeTileKey const&, skybolt::vis::TileImageLoader::CacheIndex, std::function<osg::ref_ptr<osg::Image> (skybolt::QuadTreeTileKey const&)>) const(const skybolt::vis::TileImageLoader * const this, const skybolt::QuadTreeTileKey & requestedKey, skybolt::vis::TileImageLoader::CacheIndex cacheIndex, skybolt::vis::TileImageLoader::Factory factory) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/TileImageLoader.cpp:202)
skybolt::vis::TileImageLoader::load(skybolt::QuadTreeTileKey const&, std::function<bool ()>) const(const skybolt::vis::TileImageLoader * const this, const skybolt::QuadTreeTileKey & key, std::function<bool()> cancelSupplier) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/TileImageLoader.cpp:137)
skybolt::vis::AsyncTileLoader::<lambda()>::operator()(void) const(const skybolt::vis::AsyncTileLoader::<lambda()> * const __closure) (/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVis/Renderable/Planet/Tile/AsyncTileLoader.cpp:49)
std::_Function_handler<void(), skybolt::vis::AsyncTileLoader::load(const skybolt::QuadTreeTileKey&, skybolt::vis::Box2d, const OsgTilePtrPtr&, const ProgressCallbackPtr&)::<lambda()> >::_M_invoke(const std::_Any_data &)(const std::_Any_data & __functor) (/usr/include/c++/8/bits/std_function.h:297)
std::function<void ()>::operator()() const(const std::function<void()> * const this) (/usr/include/c++/8/bits/std_function.h:687)
px_sched::Scheduler::WorkerThreadMain(px_sched::Scheduler * schd, px_sched::Scheduler::Worker * worker_data) (/home/keaton/Documents/GLRepos/SkyboltDependenciesHeaderOnly-master/px_sched/include/px_sched/px_sched.h:1130)
std::__invoke_impl<void, void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*>(void (*&&)(px_sched::Scheduler *, px_sched::Scheduler::Worker *) __f) (/usr/include/c++/8/bits/invoke.h:60)
std::__invoke<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*>(void (*&&)(px_sched::Scheduler *, px_sched::Scheduler::Worker *) __fn) (/usr/include/c++/8/bits/invoke.h:95)
std::thread::_Invoker<std::tuple<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*> >::_M_invoke<0ul, 1ul, 2ul>(std::thread::_Invoker<std::tuple<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*> > * const this) (/usr/include/c++/8/thread:244)
std::thread::_Invoker<std::tuple<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*> >::operator()(std::thread::_Invoker<std::tuple<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*> > * const this) (/usr/include/c++/8/thread:253)
std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*> > >::_M_run(std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*> > > * const this) (/usr/include/c++/8/thread:196)
libstdc++.so.6![Unknown/Just-In-Time compiled code] (Unknown Source:0)
libpthread.so.0!start_thread(void * arg) (/build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477)
libc.so.6!clone() (/build/glibc-ZN95T4/glibc-2.31/sysdeps/unix/sysv/linux/x86_64/clone.S:95)

Another note (that may or may not be related) is when I run the SkyboltVisTests, I am getting 2 failures. Here is the output for that:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SkyboltVisTests is a Catch v2.9.2 host application.
Run with -? for options

-------------------------------------------------------------------------------
Precomputed BruentonAtmosphere matches Bruenton's reference implementation
-------------------------------------------------------------------------------
/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVisTests/BrunetonAtmosphereGeneratorTests.cpp:117
...............................................................................

/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVisTests/BrunetonAtmosphereGeneratorTests.cpp:117: FAILED:
due to unexpected exception with message:
  Could not open file: Shaders/ThirdParty/BrunetonAtmosphere/definitions.glsl

No protocol specified
-------------------------------------------------------------------------------
CompositingPipeline renders expected images
-------------------------------------------------------------------------------
/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVisTests/CompositingPipelineFactoryTests.cpp:170
...............................................................................

/home/keaton/Documents/GLRepos/Skybolt-master/src/Skybolt/SkyboltVisTests/CompositingPipelineFactoryTests.cpp:170: FAILED:
due to unexpected exception with message:
  Could not create offscreen OpenGL graphics context

===============================================================================
test cases: 13 | 11 passed | 2 failed
assertions: 34 | 32 passed | 2 failed

@matthew-reid
Copy link
Contributor

What version of OSG are you using? There was a long standing threading bug in the osgdb_curl plugin which caused a crash when loading images from multiple threads. It looks like that might be the source of your problem. The bug was fixed in OpenSceneGraph commit ccf6554d2d145017a277312e3848e6f8af859f21 which is in the master branch, but I don't think it has made it into any released versions yet. I would recommend using the master version of OSG until the next OSG release.

As a workaround you can force the application to be single threaded by setting coreCount=1 in EngineRoot.cpp:71. It should avoid the crash, but tile streaming performance will suffer greatly.

The unit tests are failing for 2 reasons:

  1. The unit tests must be run from the root project working directory so that it can access the Shaders folder
  2. It can't create an off-screen OpenGL context on your system. It looks like you're running on Linux which might currently have some graphics compatibility issues due to lack of testing on my part (I develop on Windows).

@kit047
Copy link
Author

kit047 commented Jan 23, 2021

That workaround did work, and updating to the current master of osg also worked. I'll try and keep up with osg updates from here.

Now the MinimalApp doesn't crash and I do get the planet model being displayed. I still have no input, however. I plan to look into my version of ois next when I get a chance since I don't know what my issue is.

Those were the reasons the unit tests were failing. I didn't look too far into not being able to create an off-screen OpenGL context, so I'm not sure of the solution to that one.

I may try and run this on Windows so I can see what your output is like as well.

Thanks for your response!

@kit047
Copy link
Author

kit047 commented Jan 27, 2021

Ok, there is still no input ability in the app (mouse drag, scroll, keyboard, etc). Am I missing something else? I've checked/changed ois versions and I am getting the same results. Should I even have input here? Or am I terribly mistaken with how this should be working? Here is an image of what I see when I run. I get no errors, running with 8 CPU cores (7 background threads)

Skybolt-App

Also, If this is not the place to be having a conversation about my specific issues please point in the correct direction. And aside from the source code, is there any documentation I could be looking through? I appreciate the responses.

@matthew-reid
Copy link
Contributor

The app should respond to these inputs:

  • Mouse move orbits the camera around the planet
  • Mouse scroll wheel zooms in and out
  • Escape key exits application

I suspect OIS is having an internal error of some kind which you'll need to debug to get more information. Look at InputPlatformOis.cpp and put breakpoints in to check whether the OIS objects initialize correctly, and that events are fired. If you can't see anything wrong at that level, you might need to go inside the OIS library code itself.

Your screenshot is sort of correct, except that you're not getting any terrain tiles, which I think is why there's a hole in the earth. You need to put a mapbox key into the settings file (should be a path to the file printed at the start of the application log output). You can find info about getting a mapbox key at the bottom of the README file https://github.com/Piraxus/Skybolt/blob/master/README.md

The only documentation so far is in that README file and the source code. I plan to create a wiki soon where users can add additional documentation and how-to's.

@kit047
Copy link
Author

kit047 commented Jan 28, 2021

When running in Linux, I can follow the debugger through setting up the InputPlatform, though I never hit input events after that (mouseMoved, keyPressed, etc.) On the other hand, I DID get it running in windows and I believe I am seeing proper behavior. The app is responsive to mouse movements and exits with esc. I still see the hole when at a certain zoom level, I will have to double check my mapbox key. EDIT: it was the key, tile streaming is good to go.

There are differences between the apps in windows and linux. In linux, I get a window with a title bar with Minimize, Maximize, and Close buttons (they do nothing). In Windows, there is no title bar, just the window. Some difference in that I think is causing the input issue.

@matthew-reid
Copy link
Contributor

I fixed a bug where the incorrect window handle was passed into the input system on linux. The fix is now on master. See if that helps your input issues.

@matthew-reid
Copy link
Contributor

Keyboard input should be working now, but mouse input is still broken. I've isolated the problem, it's caused by OSG consuming the X11 mouse events before OIS has a chance to handle them. I'm going to rework the InputManager and I'll report back once I've got a fix.

@matthew-reid
Copy link
Contributor

I pushed a fix to the master branch which uses OSG's mouse/keyboard input system instead of OIS for the MinimalApp. As a result, input should now work with linux, and OIS is no longer required as a SkyboltEngine dependency. I have successfully tested it running ubuntu on windows through wsl2. Let me know if it works, and I'll close the issue if there are no other problems.

OIS is still required for building Sprocket because the Sprocket window is provided by Qt instead of OSG hence there's no OSG input available. I have not had a chance to test Sprocket on linux yet, but if there's a similar problem with Qt and OIS competing for mouse input, I could use Qt as the input source to fix this case.

@kit047
Copy link
Author

kit047 commented Apr 16, 2021

I pulled your updates and mouse and keyboard inputs are now working in the Minimal App. The app performance/responsiveness is definitely lesser than when I run it on windows, though that is likely something I can look into in my particular setup.

@matthew-reid
Copy link
Contributor

Glad it's working. Can I close this issue now?

@kit047
Copy link
Author

kit047 commented Apr 19, 2021

Yes I think that fixes this issue. If I experience something else I will create a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants