Could not fetch native window


#1

I am developing with ffplay+SDL2.
this is my code snapshot:

   window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                                  default_width, default_height, flags);
        SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
        if (window) {
            renderer = SDL_CreateRenderer(window, -1,
                                          SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
            if (!renderer) {
                av_log(NULL, AV_LOG_WARNING,
                       "Failed to initialize a hardware accelerated renderer: %s\n",
                       SDL_GetError());
                renderer = SDL_CreateRenderer(window, -1, 0);
            }
            if (renderer) {
                if (!SDL_GetRendererInfo(renderer, &renderer_info))
                    av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", renderer_info.name);
            }
        }
        if (!window || !renderer || !renderer_info.num_texture_formats) {
            av_log(NULL, AV_LOG_FATAL, "Failed to create window or renderer: %s", SDL_GetError());
            do_exit(NULL);
        }

Normally, there is no bug. but when user invork this code frequently, sometimes bugs occur:

07-05 10:04:23.232 23094 23414 E libEGL : validate_display:92 error 3008 (EGL_BAD_DISPLAY)
9007-05 10:04:23.232 23094 23414 V SDL : setOrientation() orientation=-1 width=576 height=704 resizable=true hint=
9107-05 10:04:23.233 23094 23414 E ffplay : Failed to create window or renderer: Could not fetch native window
9207-05 10:04:23.233 23094 23414 W SDL/SYSTEM:
9307-05 10:04:23.233 23094 23414 W SDL/SYSTEM:
9407-05 10:04:23.233 23094 23414 W SDL/SYSTEM: Assertion failure at SDL_DestroyRenderer_REAL (/home/gmy/android/project/Mypatroller/gmyplayer/src/main/jni/SDL/src/render/SDL_render.c:2071), triggered 1 time:
9507-05 10:04:23.233 23094 23414 W SDL/SYSTEM: 'renderer && renderer->magic == &renderer_magic'

2019-07-05%2010-33-59%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE