beginDraw endDraw optimizing (trying to reduce the amount of beginDraw endDraw calls required) fails to render

in the following code

Compositor compositor;

void settings() {
  //fullScreen(P3D); // 31 fps
  size(400, 400, P3D); // 60 fps
}

class Applications_Cube extends Window {

  @Override
    void draw() {
    graphics.lights();
    graphics.background(0);
    graphics.noStroke();
    graphics.translate(width/2, height/2);
    graphics.rotateX(frameCount/100.0);
    graphics.rotateY(frameCount/200.0);
    graphics.box(40);
  }
}

void addApplications() {
  compositor.add(new Applications_Cube(), 200, 200);
  compositor.setLocation(0, 0);
  compositor.add(new Applications_Cube(), 200, 200);
  compositor.setLocation(0, 200);
  compositor.add(new Applications_Cube(), 200, 200);
  compositor.setLocation(200, 0);
  compositor.add(new Applications_Cube(), 200, 200);
  compositor.setLocation(200, 200);
  compositor.add(new Applications_Cube(), 200, 200);
  compositor.setLocation(400, 400);
}

void setup() {
  compositor = new Compositor(width, height);
  compositor.displayFPS = true;
  addApplications();
  compositor.setup();
}

void draw() {
  compositor.draw();
}

class Compositor {
  public PGraphics graphics;
  ArrayList<WindowObject> windows = new ArrayList<WindowObject>();
  WindowObject w;
  int windowFocus = -1;
  int lastWindowFocus = -1;
  boolean displayFPS = false;

  Compositor(int width, int height) {
    graphics = createGraphics(width, height, P3D);
  }

  void add(Window window, int width, int height) {
    w = new WindowObject(width, height);
    windows.add(w);
    w.attach(window);
  }

  void setLocation(int x, int y) {
    w.x = x;
    w.y = y;
  }

  void drawGraphics() {
    if (displayFPS) {
      graphics.beginDraw();
      int oldColor = graphics.fillColor;
      graphics.fill(255);
      graphics.textSize(16);
      graphics.text("FPS: " + frameRate, 10, 20);
      graphics.fill(oldColor);
      graphics.endDraw();
    }
    image(graphics, 0, 0);
  }

  void drawGraphics(WindowObject window) {
    graphics.image(
      window.graphics, 
      window.x, 
      window.y, 
      window.width, 
      window.height
    );
  }

  void setup() {
    graphics.beginDraw();
    for (WindowObject window : windows) {
      window.setup();
      drawGraphics(window);
    }
    graphics.endDraw();
    drawGraphics();
  }

  void draw() {
    graphics.beginDraw();
    graphics.background(0);
    for (WindowObject window : windows) {
      window.draw();
      drawGraphics(window);
    }
    graphics.endDraw();
    drawGraphics();
  }
}

class Window {
  public PGraphics graphics = null;

  int height;
  int width;
  int x, y;
  int mouseX, mouseY;
  Window() {
  } // implicit super constructor required
  void onBeforeResize() {
  }
  String onRequestType() { 
    return P3D;
  }
  void onAfterResize() {
  }
  void setup() {
    graphics.background(0);
  }
  void draw() {
    graphics.background(0);
  }
}

class WindowObject {
  public PGraphics graphics;
  Window window;

  int height;
  int width;
  int x;
  int y;

  int borderTop = 20;
  int borderLeft = 3;
  int borderBottom = 3;
  int borderRight = 3;

  WindowObject() {
  } // implicit super constructor required

  WindowObject(int width, int height) {
    this.width = width;
    this.height = height;
    graphics = createGraphics(width, height, P3D);
  }

  void attach(Window window) {
    this.window = window;

    this.window.x = borderLeft;
    this.window.width = width-borderLeft-borderRight;

    this.window.y = borderTop;
    this.window.height = height-borderTop-borderBottom;
  }

  void clearScreen() {
    graphics.background(0);
  }

  void drawBordersWithFill(int fill__) {
    graphics.rectMode(CORNER);
    graphics.stroke(0);
    graphics.fill(fill__);
    graphics.rect(0, 0, width, height, 10);
  }
  void drawBorders() {
    drawBordersWithFill(87);
  }

  void drawGraphics() {
    window.graphics.endDraw();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
    window.graphics.beginDraw();
  }

  void drawWindow() {
    graphics.beginDraw();
    clearScreen();
    drawBorders();
    drawGraphics();
    graphics.endDraw();
  }

  void resizeWindow() {
    String type = window.onRequestType();
    window.onBeforeResize();
    window.graphics = createGraphics(window.width, window.height, type);
    window.graphics.beginDraw();
    window.onAfterResize();
  }

  //void setup() {
  //  String type = window.onRequestType();
  //  window.onBeforeResize();
  //  window.graphics = createGraphics(window.width, window.height, type);
  //  window.graphics.beginDraw();
  //  window.onAfterResize();
  //  window.setup();
  //  graphics.beginDraw();
  //  clearScreen();
  //  drawBorders();
  //  window.graphics.endDraw();
  //  graphics.image(window.graphics, window.x, window.y, window.width, window.height);
  //  graphics.endDraw();
  //}

  //void draw() {
  //  window.graphics.beginDraw();
  //  window.draw();
  //  window.graphics.endDraw();
  //  graphics.beginDraw();
  //  clearScreen();
  //  drawBorders();
  //  graphics.image(window.graphics, window.x, window.y, window.width, window.height);
  //  graphics.endDraw();
  //}
  
  void setup() {
    String type = window.onRequestType();
    window.onBeforeResize();
    window.graphics = createGraphics(window.width, window.height, type);
    window.graphics.beginDraw();
    window.onAfterResize();
    window.setup();
    graphics.beginDraw();
    clearScreen();
    drawBorders();
    window.graphics.endDraw();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
    graphics.endDraw();
  }

  void draw() {
    window.graphics.beginDraw();
    window.draw();
    window.graphics.endDraw();
    graphics.beginDraw();
    clearScreen();
    drawBorders();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
    graphics.endDraw();
  }
}

why does my application fail to get rendered if i replace

  void drawGraphics(WindowObject window) {
    graphics.image(
      window.graphics, 
      window.x, 
      window.y, 
      window.width, 
      window.height
    );
  }
// ...
}
{
  void setup() {
    String type = window.onRequestType();
    window.onBeforeResize();
    window.graphics = createGraphics(window.width, window.height, type);
    window.graphics.beginDraw();
    window.onAfterResize();
    window.setup();
    graphics.beginDraw();
    clearScreen();
    drawBorders();
    window.graphics.endDraw();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
    graphics.endDraw();
  }

  void draw() {
    window.graphics.beginDraw();
    window.draw();
    window.graphics.endDraw();
    graphics.beginDraw();
    clearScreen();
    drawBorders();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
    graphics.endDraw();
  }
// ...
}

with

  void drawGraphics(WindowObject window) {
    window.graphics.endDraw();
    graphics.image(
      window.graphics, 
      window.x, 
      window.y, 
      window.width, 
      window.height
    );
    window.graphics.beginDraw();
  }
// ...
}
{
// ...
  void setup() {
    String type = window.onRequestType();
    window.onBeforeResize();
    window.graphics = createGraphics(window.width, window.height, type);
    window.graphics.beginDraw();
    window.onAfterResize();
    window.setup();
    graphics.beginDraw();
    clearScreen();
    drawBorders();
    window.graphics.endDraw();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
  }

  void draw() {
    window.graphics.beginDraw();
    window.draw();
    window.graphics.endDraw();
    clearScreen();
    drawBorders();
    graphics.image(window.graphics, window.x, window.y, window.width, window.height);
  }
// ...
}