# pGraphics.beginDraw() RuntimeException: Too many pushFramebuffer calls

**URL:** <https://discourse.processing.org/t/pgraphics-begindraw-runtimeexception-too-many-pushframebuffer-calls/21765>\
**Category:** Coding Questions\
**Created:** [June 11, 2020, 10:12am UTC](https://discourse.processing.org/t/pgraphics-begindraw-runtimeexception-too-many-pushframebuffer-calls/21765 "2020-06-11T10:12:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgood7123](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Post date:** [June 11, 2020, 10:12am UTC](https://discourse.processing.org/t/pgraphics-begindraw-runtimeexception-too-many-pushframebuffer-calls/21765/1 "2020-06-11T10:12:46Z")

</div>

why would i get `RuntimeException: Too many pushFramebuffer calls` when calling

```auto
    window.graphics = createGraphics(window.width, window.height, type);
    window.graphics.beginDraw();

```

```auto

java.lang.RuntimeException: Too many pushFramebuffer calls
	at processing.opengl.PGraphicsOpenGL.pushFramebuffer(PGraphicsOpenGL.java:1148)
	at processing.opengl.FrameBuffer.initColorBufferMultisample(FrameBuffer.java:388)
	at processing.opengl.FrameBuffer.allocate(FrameBuffer.java:340)
	at processing.opengl.FrameBuffer.<init>(FrameBuffer.java:137)
	at processing.opengl.PGraphicsOpenGL.initOffscreen(PGraphicsOpenGL.java:6650)
	at processing.opengl.PGraphicsOpenGL.beginOffscreenDraw(PGraphicsOpenGL.java:6682)
	at processing.opengl.PGraphicsOpenGL.beginDraw(PGraphicsOpenGL.java:1461)
	at Processing3Compositor$WindowObject.resizeWindow(Processing3Compositor.java:1160)
	at Processing3Compositor$WindowObject.setup(Processing3Compositor.java:1167)
	at Processing3Compositor$Compositor.setup(Processing3Compositor.java:408)
	at Processing3Compositor.setup(Processing3Compositor.java:69)
	at processing.core.PApplet.handleDraw(PApplet.java:2432)
	at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:866)
	at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
	at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
	at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
	at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
	at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
	at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759)
	at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
	at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
	at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 11, 2020, 10:51am UTC](https://discourse.processing.org/t/pgraphics-begindraw-runtimeexception-too-many-pushframebuffer-calls/21765/2 "2020-06-11T10:51:47Z")

</div>

> [@mgood7123](#):
>
> ` window.graphics.beginDraw();`

is this in setup() or in draw()?

Do you use

```auto
    window.graphics.endDraw();

```

?

Can you post an mcve?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 11, 2020, 9:18pm UTC](https://discourse.processing.org/t/pgraphics-begindraw-runtimeexception-too-many-pushframebuffer-calls/21765/3 "2020-06-11T21:18:44Z")

</div>

> [@Chrisir](#):
>
> Can you post an mcve?

Yes, please do!

> [@mgood7123](#):
>
> Too many pushFramebuffer calls

For example:

> [beginRecord() with a PGraphics2D interferes with the background of the main PApplet · Issue #3180 · processing/processing · GitHub](https://github.com/processing/processing/issues/3180#issuecomment-89858364)

> <https://github.com/processing/processing/issues/3180#issuecomment-89858364>
>
> This should show a white background with a black diagonal line. But the backgrou…nd stays the default gray. If you remove the P2D argument to createGraphics, it works OK (then the default Java2D renderer is used).
> 
> \`\`\` processing
> PGraphics offscreenBuffer;
> 
> void setup() {
> size(200, 200, P2D);
> offscreenBuffer = createGraphics(width, height, P2D);
> }
> 
> void draw() {
> beginRecord(offscreenBuffer);
> background(255);
> line(0, 0, width, height);
> endRecord();
> }
> \`\`\`
> 
> Thanks anyway for producing this awesome software!

> Don’t call `createGraphics()` inside `draw()` . That example is creating new OpenGL drawing contexts at 60 frames a second. That’s not a Processing problem, you’re going to crash your machine no matter what language you use.
