wasabeef/android-gpuimage · error · IllegalArgumentException

r must not be null

Error message

r must not be null

What it means

GLTextureView.queueEvent(Runnable) requires a non-null runnable to schedule on the GL rendering thread. A null argument throws IllegalArgumentException("r must not be null") before the event is added to the internal event queue.

Solutions

  1. Check for null before calling queueEvent and skip the call when there is nothing to run.
  2. Initialize or re-create the Runnable before scheduling it on the GL thread.
  3. Centralize GL-thread scheduling in a helper that no-ops on null runnables.

Example fix

// before
 glTextureView.queueEvent(pendingTask);
// after
 if (pendingTask != null) {
     glTextureView.queueEvent(pendingTask);
 }
Defensive patterns

Strategy: type-guard

Validate before calling

if (task == null) return; // nothing to schedule

Type guard

boolean canQueue(Runnable r) { return r != null; }

Prevention

When it happens

Trigger: Calling glTextureView.queueEvent(null), typically when a Runnable field or callback is null (not yet initialized, already consumed, or a failed lookup) and passed without a check.

Common situations: A lazily-initialized runnable is still null when the view becomes available; a listener returning null on some paths; race conditions where a cleanup routine nulled the runnable before the UI scheduled it.

Related errors


AI-assisted analysis of wasabeef/android-gpuimage@ceea576ec9 (2026-09-11). Data as JSON: /api/errors/e59b7647832f66b0. Report an issue: GitHub.

Appendix: source

Thrown at library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java:1613

                        Thread.currentThread().interrupt();
                    }
                }
            }
        }

        public void requestReleaseEglContextLocked() {
            shouldReleaseEglContext = true;
            glThreadManager.notifyAll();
        }

        /**
         * Queue an "event" to be run on the GL rendering thread.
         *
         * @param r the runnable to be run on the GL rendering thread.
         */
        public void queueEvent(Runnable r) {
            if (r == null) {
                throw new IllegalArgumentException("r must not be null");
            }
            synchronized (glThreadManager) {
                eventQueue.add(r);
                glThreadManager.notifyAll();
            }
        }

        // Once the thread is started, all accesses to the following member
        // variables are protected by the glThreadManager monitor
        private boolean shouldExit;
        private boolean exited;
        private boolean requestPaused;
        private boolean paused;
        private boolean hasSurface;
        private boolean surfaceIsBad;
        private boolean waitingForSurface;
        private boolean haveEglContext;
        private boolean haveEglSurface;

View on GitHub (pinned to ceea576ec9)