openframeworks / openframeworks/openFrameworks

multiwindow App using ofVbo crash when doing some window operation

Open
#5,032 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

I see a crash in glDrawArrays() with multiwindows App using ofVbo when doing some window operation(e.g. ofToggleFullscreen() , glfwHideWindow() , glfwShowWindow() ).

I tried the following code in branch 0.9.4. Crash at: (https://github.com/openframeworks/openFrameworks/blob/0.9.4/libs/openFrameworks/gl/ofGLRenderer.cpp#L374)

Code

In ofApp.h

  ofVbo vbo;
  ofVideoGrabber videoGrabber;

In ofApp.cpp

//--------------------------------------------------------------
void ofApp::setup() {
  int w = 480;
  int h = 360;

  videoGrabber.setDeviceID(0);
  videoGrabber.setup(w, h);

  ofVec2f *verts = new ofVec2f[w * h];

  verts = new ofVec2f[4];
  verts[0].set(0, 0);
  verts[1].set(w, 0);
  verts[2].set(w, h);
  verts[3].set(0, h);
  vbo.setVertexData(verts, 4, GL_DYNAMIC_DRAW);
  vbo.setTexCoordData(verts, 4, GL_STATIC_DRAW);
  delete[] verts;
}

//--------------------------------------------------------------
void ofApp::update() { videoGrabber.update(); }

//--------------------------------------------------------------
void ofApp::draw() {
  videoGrabber.getTexture().bind();
  vbo.draw(GL_QUADS, 0, 4);
  videoGrabber.getTexture().unbind();
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key) {
  if (key == 'f') {
    ofToggleFullscreen();
  }
}

In main.cpp

int main() {
  ofGLFWWindowSettings settings;
  settings.width = 480;
  settings.height = 360;
  settings.resizable = true;
  shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);

  settings.width = 100;
  settings.height = 100;
  settings.setPosition(ofVec2f(400, 20));
  settings.resizable = true;
  settings.visible = true;
  shared_ptr<ofAppBaseWindow> subWindow = ofCreateWindow(settings);

  shared_ptr<ofApp> mainApp(new ofApp);
  shared_ptr<subWindowClass> subWindowApp(new subWindowClass);

  ofRunApp(subWindow, subWindowApp);
  ofRunApp(mainWindow, mainApp);
  ofRunMainLoop();
}

Stack back traces:

* thread #1: tid = 0x118856, 0x00007fff9516c7c8 GLEngine`gleRunVertexSubmitImmediate + 5080, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff9516c7c8 GLEngine`gleRunVertexSubmitImmediate + 5080
    frame #1: 0x00007fff9503c128 GLEngine`glDrawArrays_Exec + 645
  * frame #2: 0x0000000100430e29 multiWindowTest`ofGLRenderer::draw(this=<unavailable>, vbo=0x000000010230c0d8, drawMode=7, first=0, total=4) const + 57 at ofGLRenderer.cpp:374
    frame #3: 0x0000000100454c10 multiWindowTest`ofVbo::draw(this=<unavailable>, drawMode=<unavailable>, first=<unavailable>, total=<unavailable>) const + 64 at ofVbo.cpp:905
    frame #4: 0x00000001000032cb multiWindowTest`ofApp::draw(this=<unavailable>) + 59 at ofApp.cpp:29
    frame #5: 0x00000001004073e5 multiWindowTest`std::__1::__function::__func<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&), std::__1::allocator<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)>, bool (void const*, ofEventArgs&)>::operator()(void const*&&, ofEventArgs&) [inlined] std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)::operator()(void const*, ofEventArgs&) const + 37 at ofEvent.h:237
    frame #6: 0x00000001004073c3 multiWindowTest`std::__1::__function::__func<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&), std::__1::allocator<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)>, bool (void const*, ofEventArgs&)>::operator()(void const*&&, ofEventArgs&) [inlined] decltype(std::__1::forward<ofBaseApp>(fp)(std::__1::forward<void const*, ofEventArgs&>(fp0))) std::__1::__invoke<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)&, void const*, ofEventArgs&>(ofBaseApp&&, void const*&&, ofEventArgs&&&) at __functional_base:416
    frame #7: 0x00000001004073c3 multiWindowTest`std::__1::__function::__func<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&), std::__1::allocator<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)>, bool (void const*, ofEventArgs&)>::operator()(void const*&&, ofEventArgs&) [inlined] bool std::__1::__invoke_void_return_wrapper<bool>::__call<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)&, void const*, ofEventArgs&>(std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)&&&, void const*&&, ofEventArgs&&&) at __functional_base:437
    frame #8: 0x00000001004073c3 multiWindowTest`std::__1::__function::__func<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&), std::__1::allocator<std::__1::shared_ptr<of::priv::Function<ofEventArgs, std::__1::recursive_mutex> > ofEvent<ofEventArgs, std::__1::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofEventArgs&), int)::'lambda'(void const*, ofEventArgs&)>, bool (void const*, ofEventArgs&)>::operator(this=<unavailable>, __arg=<unavailable>, __arg=<unavailable>)(void const*&&, ofEventArgs&) + 3 at functional:1437
    frame #9: 0x00000001003e06d1 multiWindowTest`ofEvent<ofEventArgs, std::__1::recursive_mutex>::notify(void const*, ofEventArgs&) [inlined] std::__1::function<bool (void const*, ofEventArgs&)>::operator(__arg=0x0000000000000000)(void const*, ofEventArgs&) const + 21 at functional:1817
    frame #10: 0x00000001003e06bc multiWindowTest`ofEvent<ofEventArgs, std::__1::recursive_mutex>::notify(void const*, ofEventArgs&) [inlined] of::priv::Function<ofEventArgs, std::__1::recursive_mutex>::notify(this=<unavailable>) + 105 at ofEvent.h:136
    frame #11: 0x00000001003e0653 multiWindowTest`ofEvent<ofEventArgs, std::__1::recursive_mutex>::notify(this=<unavailable>, sender=0x0000000000000000, param=0x00000001008d3518) + 131 at ofEvent.h:303
    frame #12: 0x00000001003dee85 multiWindowTest`ofCoreEvents::notifyDraw() [inlined] void ofNotifyEvent<ofEvent<ofEventArgs, std::__1::recursive_mutex>, ofEventArgs>(event=<unavailable>, args=<unavailable>) + 37 at ofEventUtils.h:222
    frame #13: 0x00000001003dee77 multiWindowTest`ofCoreEvents::notifyDraw(this=0x0000000101810a08) + 23 at ofEvents.cpp:204
    frame #14: 0x00000001004621f0 multiWindowTest`ofAppGLFWWindow::draw(this=0x0000000101810a00) + 64 at ofAppGLFWWindow.cpp:365
    frame #15: 0x0000000100405f55 multiWindowTest`ofMainLoop::loopOnce(this=0x0000000102003980) + 197 at ofMainLoop.cpp:140
    frame #16: 0x0000000100405e5e multiWindowTest`ofMainLoop::loop(this=0x0000000102003980) + 62 at ofMainLoop.cpp:121
    frame #17: 0x000000010000271b multiWindowTest`main + 779 at main.cpp:26
    frame #18: 0x0000000100002404 multiWindowTest`start + 52

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the multiwindow example in main.cpp, ofApp.cpp, and ofApp.h, including fullscreen, hide, and show operations. Start at ofGLRenderer.cpp:374 and follow the call path through ofVbo.cpp:905 and ofAppGLFWWindow.cpp:365. Done means the sample no longer crashes in glDrawArrays() after those window operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.