Skip to content

Movie throwing NullPointerException with usedBuffers with P2D/P3D #760

@processing-bot

Description

@processing-bot

Created by: Clarvel

Description

When trying to playback a movie file, Processing throws a null pointer exception because the usedBuffers property in the Texture class is never initialized before it is used in the copyBufferFromSource method.
I have made a pull request to fix this, it is linked at the bottom of this Issue.

Expected Behavior

Processing can load movie files and display them in the UI to the user.

Current Behavior

I see a single frame of the video loaded and get audio from the movie. the following exception is logged over and over in the console:

java.lang.NullPointerException: Cannot invoke "java.util.LinkedList.add(Object)" because "this.usedBuffers" is null
	at processing.opengl.Texture.copyBufferFromSource(Texture.java:827)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at processing.video.Movie$NewSampleListener.newSample(Unknown Source)
	at org.freedesktop.gstreamer.elements.AppSink$2.callback(AppSink.java:232)
	at jdk.internal.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:585)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:616)

Steps to Reproduce

  1. Try to load a movie and have Processing play it on loop:
import processing.video.*;

Movie movie;
boolean loaded = false;

void setup(){
  size(720, 480, P2D);
  movie = new Movie(this, "MOVIE_PATH.MOV");
  movie.loop();
}

void draw(){
  if(movie != null && movie.available()){
    if(!loaded){
      loaded = true;
      windowResize(movie.width, movie.height);
    }
    movie.read();
    image(movie, 0, 0);
  }
}

void movieEvent(Movie m){
  m.read();
}

Your Environment

  • Processing version: 4.3
  • Operating System and OS version: Windows 10 Home 10.0.19044 Build 19044
  • Other information:

Possible Causes / Solutions

Proposed pull request to fix the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions