New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeException when calling strokeWeight using FX2D #4206

Closed
mikechambers opened this Issue Dec 17, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@mikechambers

mikechambers commented Dec 17, 2015

Processing 3.0.1
OS X 10.10.5 / Windows 10

When using FX2D renderer, I get a RuntimeException (see below). Exception does not occur when using default renderer, or in processing 2.

Exception:

java.lang.RuntimeException: pushMatrix() cannot use push more than 32 times
    at processing.javafx.PGraphicsFX2D.pushMatrix(PGraphicsFX2D.java:1598)
    at processing.javafx.PGraphicsFX2D.beginShape(PGraphicsFX2D.java:217)
    at processing.core.PGraphics.beginShape(PGraphics.java:1185)
    at processing.core.PApplet.beginShape(PApplet.java:10710)
    at BezierPlay2.draw(BezierPlay2.java:110)
    at processing.core.PApplet.handleDraw(PApplet.java:2399)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:75)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:1)
    at com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:226)
    at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:184)
    at javafx.animation.Timeline.impl_playTo(Timeline.java:176)
    at javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
    at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:126)
    at javafx.animation.Animation.impl_timePulse(Animation.java:1102)
    at javafx.animation.Animation$1.lambda$timePulse$26(Animation.java:186)
    at javafx.animation.Animation$1$$Lambda$98/682942078.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.Animation$1.timePulse(Animation.java:185)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:344)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:521)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:505)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$400(QuantumToolkit.java:334)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$56/1775377411.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
handleDraw() called before finishing
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

The issue is the call to strokeWeight(1.0) on line 82. If you comment out this line, project works without issue.

Note: If you also set strokeWeight to a value greater that 1.0, everything works. When it is set to 1.0, then PGraphicsFX2D.drawingThinLines() returns true, which cause all of the pushMatrix calls.

  @Override
  public void beginShape(int kind) {
    shape = kind;
    vertexCount = 0;

    workPath.reset();
    auxPath.reset();

    flushPixels();

    if (drawingThinLines()) {
      pushMatrix();
      translate(0.5f, 0.5f);
    }
  }

drawingThingLines was added in this commit in august: 0b143c6

Project attached.
BezierPlay2.zip

To reproduce, run code, move mouse around on screen. RTE.

@mikechambers mikechambers changed the title from RuntimeException when calling setStroke using FX2D to RuntimeException when calling strokeWeight using FX2D Dec 17, 2015

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Dec 18, 2015

Contributor

The problem is that you are changing the stroke weight in the beginShape/endShape block, which is not supported. I will add a warning if this happens.

Contributor

JakubValtar commented Dec 18, 2015

The problem is that you are changing the stroke weight in the beginShape/endShape block, which is not supported. I will add a warning if this happens.

@JakubValtar JakubValtar self-assigned this Dec 18, 2015

@mikechambers

This comment has been minimized.

Show comment
Hide comment
@mikechambers

mikechambers Dec 18, 2015

Thanks. Moving the stokeWeight call outside of the beginShape fixed the RTE.

This might be something worth adding to: https://github.com/processing/processing/wiki/Changes-in-3.0

mikechambers commented Dec 18, 2015

Thanks. Moving the stokeWeight call outside of the beginShape fixed the RTE.

This might be something worth adding to: https://github.com/processing/processing/wiki/Changes-in-3.0

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Feb 13, 2016

Member

It's already covered in the reference: https://processing.org/reference/beginShape_.html

Settings such as strokeWeight(), strokeCap(), and strokeJoin() cannot be changed while inside a beginShape()/endShape() block with any renderer.

Member

benfry commented Feb 13, 2016

It's already covered in the reference: https://processing.org/reference/beginShape_.html

Settings such as strokeWeight(), strokeCap(), and strokeJoin() cannot be changed while inside a beginShape()/endShape() block with any renderer.

@benfry benfry closed this Feb 13, 2016

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Feb 13, 2016

Member

(Re-opening so that @JakubValtar can add that warning.)

Member

benfry commented Feb 13, 2016

(Re-opening so that @JakubValtar can add that warning.)

@benfry benfry reopened this Feb 13, 2016

JakubValtar added a commit to JakubValtar/processing that referenced this issue Dec 29, 2016

FX: Prevent matrix stack overflow
Matrix stack could overflow in a very special case when beginShape() was
called while strokeWeight=1 and then strokeWeight was changed before
endShape(). This PR makes sure matrix is popped correctly even when user
changes strokeWeight in the beginShape()/endShape() block.

Decided to bug user only when necessary and not show warining when user
changes strokeWeight in the beginShape()/endShape() block, same as in
JAVA2D. Otherwise we could add checks for all the other things which are
mentioned in the docs, but it would be hell to maintain and use.

Fixes #4206

@benfry benfry closed this in #4799 Jan 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment