m1k1o/neko · warning

image data not found

Error message

image data not found

What it means

GetImage on the screencast manager returns this error when the cached image buffer (manager.image.Data) is nil, meaning no frame has ever been captured and stored. The library throws it because there is no screenshot data to hand back to the caller yet. It is a signal that the screencast pipeline has not produced its first sample (or was never started) before GetImage was called.

Source

Thrown at server/internal/capture/screencast.go:144

	manager.mu.Lock()
	defer manager.mu.Unlock()

	return manager.started
}

func (manager *ScreencastManagerCtx) Image() ([]byte, error) {
	atomic.StoreInt32(&manager.expired, 0)

	err := manager.start()
	if err != nil && !errors.Is(err, types.ErrCapturePipelineAlreadyExists) {
		return nil, err
	}

	manager.imageMu.Lock()
	defer manager.imageMu.Unlock()

	if manager.image.Data == nil {
		return nil, errors.New("image data not found")
	}

	return manager.image.Data, nil
}

func (manager *ScreencastManagerCtx) start() error {
	manager.mu.Lock()
	defer manager.mu.Unlock()

	if !manager.enabled {
		return errors.New("screencast not enabled")
	}

	err := manager.createPipeline()
	if err != nil {
		return err
	}

View on GitHub (pinned to b0f01cedea)

Solutions

  1. Ensure the screencast is started (or an existing streaming session exists) before calling GetImage, so createPipeline populates the first image
  2. Retry GetImage with a short backoff until the first frame arrives instead of calling it once immediately
  3. Enable the screencast via its config/manager so start() runs and sets an initial image
  4. Verify the underlying capture pipeline (GStreamer) actually emits samples — check logs for 'started receiving images'

Example fix

// before
img, err := screencastManager.GetImage() // may fail: image data not found
// after
if err := screencastManager.StartStreamingIfStopped(); err != nil { return err }
for i := 0; i < 10; i++ {
    img, err := screencastManager.GetImage()
    if err == nil { return img }
    time.Sleep(100 * time.Millisecond)
}
Defensive patterns

Strategy: retry

Validate before calling

// No public accessor for image state; validate indirectly by ensuring the screencast was started first.
if screencastManager == nil {
    return errors.New("screencast manager not initialized")
}
// Optionally attempt start (idempotent) before fetching:
if err := ensureScreencastStarted(); err != nil { return err }

Type guard

func hasImageData(m *capture.ScreencastManagerCtx) bool {
    // Only reachable via GetImage error; treat error as the guard.
    _, err := m.GetImage()
    return err == nil
}

Try / catch

img, err := manager.GetImage()
if err != nil {
    if err.Error() == "image data not found" {
        // first frame not ready yet: retry with backoff
        time.Sleep(200 * time.Millisecond)
        img, err = manager.GetImage()
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: Calling ScreencastManagerCtx.GetImage() before the pipeline has stored any frame — e.g. right after construction with no prior start/Image invocation that populated manager.image, or after creation where the first-sample select in createPipeline stored nothing.

Common situations: Developers hit this when taking an immediate screenshot on session open without waiting for the screencast to start; after toggling screencast off/on; in headless environments where GStreamer never emits a first sample; or when wiring a new client that fetches an image before any streaming client triggered pipeline creation.

Related errors


AI-assisted analysis of m1k1o/neko@b0f01cedea (2026-09-01). Data as JSON: /api/errors/364ae2b98517cdbd. Report an issue: GitHub.