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

Framebuffer not complete! ErrorCode=36061 after opening too many threads #37

Open
ppwwyyxx opened this Issue Aug 7, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@ppwwyyxx
Contributor

ppwwyyxx commented Aug 7, 2018

Me and @abhshkdz saw this error quite a while a go. After some investigation this seems to be an EGL issue.
The cause seems to be: the GPU resource used by an EGL context does not get released until all EGL context within the process get destroyed. In other words: destroying a single EGL context does not actually release its resource, until all EGL context within the process get destroyed.

This can be verified by the following code:

#include <cstdio>
#include "suncg/render.hh"
using namespace render;
using namespace std;
int main() {
    std::vector<SUNCGRenderAPIThread*> apis;
    apis.resize(1000);
    for (int i = 0; i < 1000; ++i) {
        printf("%d\n", i);
        apis[i] = new SUNCGRenderAPIThread(800, 600, 0);
        if (i >= 1) {
            delete apis[i - 1];
        }
    }
}

This code always destroys a context after creating a new context. It gives the framebuffer error under EGL backend, but not under GLX backend.


#include <cstdio>
#include "suncg/render.hh"
using namespace render;
using namespace std;
int main() {
    std::vector<SUNCGRenderAPIThread*> apis;
    apis.resize(1000);
    for (int i = 0; i < 1000; ++i) {
        if (i % 10 == 0 && i >= 10) {
            for (int k = 0; k < 10; ++k) {
                printf("Delete %d\n", i - k - 1);
                delete apis[i - k - 1];
            }
        }
        printf("%d\n", i);
        apis[i] = new SUNCGRenderAPIThread(800, 600, 0);
    }
}

However this works fine, because after creating every 10 contexts, it destroys all of them.

Similar tricks apply to python side as well. To free the resources, it's important and not very easy, to make sure no references to any SUNCGRenderAPIThread is alive.

For instance, this code results in error:

for k in range(1000):
    api = objrender.RenderAPIThread(...)

because in every assignment, it first creates a new api, then destroys the old one. However this works:

for k in range(1000):
    api = None
    api = objrender.RenderAPIThread(...)
@ppwwyyxx

This comment has been minimized.

Contributor

ppwwyyxx commented Aug 26, 2018

Write it down here for future reference: a driver bug in certain versions can cause multithread rendering to segfault. The bug was fixed in driver 396.45. A known good version is 384.81. So the bug probably appears somewhere in between these two versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment