endless loop printing a line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

endless loop printing a line

Dave Stevenson-3
I've got an endless loop in VW 7.6 trying to print the border of a widget to a scaled MockMedium. In particular, the problem happens when printing the bottom of line of the border. Here is the repeating part of the stack:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
    ScreenGraphicsContext>>roundedDisplayPolygon:at:
    ScreenGraphicsContext>>primDisplayPolygon:at:
    ScreenGraphicsContext(GraphicsContext)>>displayPolygon:at:
    ScreenGraphicsContext(GraphicsContext)>>displayPolygon:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
    ...

And the relevant data:
    pointCollection = #(3@25 3@24 797@24 797@25)
    clippingBounds = 0@0 corner: 800@25
Note that the pointCollection is aligned with the bottom of the clippingBounds.

At issue is an apparent mismatch between Rectangle and GraphicsContext as to whether the bottom points (3@25 or 797@25) are inside the clippingBounds. Rectangle thinks it is out:
    Rectangle>>containsPoint:
    optimized [] in GraphicsContext>>isPolygon:inside:
    Array(ArrayedCollection)>>allSatisfy:
    ScreenGraphicsContext(GraphicsContext)>>isPolygon:inside:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:

because it checks for aPoint < corner, but aPoint y is not less than corner y, so it answers false:

    Rectangle>>containsPoint: aPoint
        "Answer whether the argument aPoint is within the receiver."
        ^origin <= aPoint and: [aPoint < corner]

    Point>>< aPoint
        "Answer whether the receiver is 'above and to the left' of the
        argument, aPoint."
        | p |
        p := aPoint asPoint.
        ^x < p x and: [y < p y]

But GraphicsContext thinks it is in:
    ScreenGraphicsContext(GraphicsContext)>>clipPolygon:toBottom:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:

because it checks for point y <= aNumber, and they are indeed equal:

    GraphicsContext>>clipPolygon: pointCollection toBottom: aNumber
        ^self
            clipPolygon: pointCollection
            insideBlock: [:point | point y <= aNumber]
            intersectionBlock: [:point1 :point2 | aNumber - point1 y * (point2 x - point1 x) // (point2 y - point1 y) + point1 x @ aNumber]

So the difference of #< in #containsPoint: and #<= in #clipPolygon:toBottom: means the pointCollection never gets clipped, and we happily spin the cpu. The relevant code appears unchanged in the 7.8 beta.

Any recommendations as to how to fix or work around this?

Thanks,

Dave Stevenson
[hidden email]

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: EXT : endless loop printing a line

Lopeman, Chris (IS)

Sound like we should get immediate support on this one.  I sounds like they need to aligned the two methods it does not get lost. 

 

From: Dave Stevenson [mailto:[hidden email]]
Sent: Monday, May 02, 2011 3:17 PM
To: [hidden email]
Subject: EXT :[vwnc] endless loop printing a line

 

I've got an endless loop in VW 7.6 trying to print the border of a widget to a scaled MockMedium. In particular, the problem happens when printing the bottom of line of the border. Here is the repeating part of the stack:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
    ScreenGraphicsContext>>roundedDisplayPolygon:at:
    ScreenGraphicsContext>>primDisplayPolygon:at:
    ScreenGraphicsContext(GraphicsContext)>>displayPolygon:at:
    ScreenGraphicsContext(GraphicsContext)>>displayPolygon:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
    ...

And the relevant data:
    pointCollection = #(3@25 3@24 797@24 797@25)
    clippingBounds = 0@0 corner: 800@25
Note that the pointCollection is aligned with the bottom of the clippingBounds.

At issue is an apparent mismatch between Rectangle and GraphicsContext as to whether the bottom points (3@25 or 797@25) are inside the clippingBounds. Rectangle thinks it is out:
    Rectangle>>containsPoint:
    optimized [] in GraphicsContext>>isPolygon:inside:
    Array(ArrayedCollection)>>allSatisfy:
    ScreenGraphicsContext(GraphicsContext)>>isPolygon:inside:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:

because it checks for aPoint < corner, but aPoint y is not less than corner y, so it answers false:

    Rectangle>>containsPoint: aPoint
        "Answer whether the argument aPoint is within the receiver."
        ^origin <= aPoint and: [aPoint < corner]

    Point>>< aPoint
        "Answer whether the receiver is 'above and to the left' of the
        argument, aPoint."
        | p |
        p := aPoint asPoint.
        ^x < p x and: [y < p y]

But GraphicsContext thinks it is in:
    ScreenGraphicsContext(GraphicsContext)>>clipPolygon:toBottom:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:

because it checks for point y <= aNumber, and they are indeed equal:

    GraphicsContext>>clipPolygon: pointCollection toBottom: aNumber
        ^self
            clipPolygon: pointCollection
            insideBlock: [:point | point y <= aNumber]
            intersectionBlock: [:point1 :point2 | aNumber - point1 y * (point2 x - point1 x) // (point2 y - point1 y) + point1 x @ aNumber]

So the difference of #< in #containsPoint: and #<= in #clipPolygon:toBottom: means the pointCollection never gets clipped, and we happily spin the cpu. The relevant code appears unchanged in the 7.8 beta.

Any recommendations as to how to fix or work around this?

Thanks,

Dave Stevenson
[hidden email]


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: endless loop printing a line

Dave Stevenson-3
In reply to this post by Dave Stevenson-3
My print routine does these basic steps:
    - open a window on my #printSpec
    - get a new print job with a MockMedium on a ScalingWrapper on the print window
    - ask the medium to display
    - send the completed print job to the printer

When the scale of the print job is extreme enough (like when printing a very large visual on too small a paper size), display primitives (such as HostPrinterGraphicsContext>>primDisplayLineFrom:to:) can fail because the coordinates exceed the number ranges allowed in the primitives. The prim failure code leads to #displayClippedPolygon:, which begins the endless loop.

My partial work around is to override #displayClippedPolygon: to raise a Notification if pointCollection cannot be clipped (at the end of the method, is clippedPointCollection asArray = pointCollection asArray?). I have to handle this notification in the #displayOn: method for my main visual object to abort the endless loop (I abort when unable to clip the same pointCollection more than once consecutively, because I'm unsure whether any paths through this code would resolve after a single clipping failure).
 
However, this is only a partial work around because there remain the coordinate limitations of the graphics primitives. When will those limits be raised? Are they higher in the 64 bit VM?

Dave Stevenson
[hidden email]



From: Dave Stevenson <[hidden email]>
To: [hidden email]
Sent: Mon, May 2, 2011 3:16:31 PM
Subject: [vwnc] endless loop printing a line

I've got an endless loop in VW 7.6 trying to print the border of a widget to a scaled MockMedium. In particular, the problem happens when printing the bottom of line of the border. Here is the repeating part of the stack:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
    ScreenGraphicsContext>>roundedDisplayPolygon:at:
    ScreenGraphicsContext>>primDisplayPolygon:at:
    ScreenGraphicsContext(GraphicsContext)>>displayPolygon:at:
    ScreenGraphicsContext(GraphicsContext)>>displayPolygon:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
    ...

And the relevant data:
    pointCollection = #(3@25 3@24 797@24 797@25)
    clippingBounds = 0@0 corner: 800@25
Note that the pointCollection is aligned with the bottom of the clippingBounds.

At issue is an apparent mismatch between Rectangle and GraphicsContext as to whether the bottom points (3@25 or 797@25) are inside the clippingBounds. Rectangle thinks it is out:
    Rectangle>>containsPoint:
    optimized [] in GraphicsContext>>isPolygon:inside:
    Array(ArrayedCollection)>>allSatisfy:
    ScreenGraphicsContext(GraphicsContext)>>isPolygon:inside:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:

because it checks for aPoint < corner, but aPoint y is not less than corner y, so it answers false:

    Rectangle>>containsPoint: aPoint
        "Answer whether the argument aPoint is within the receiver."
        ^origin <= aPoint and: [aPoint < corner]

    Point>>< aPoint
        "Answer whether the receiver is 'above and to the left' of the
        argument, aPoint."
        | p |
        p := aPoint asPoint.
        ^x < p x and: [y < p y]

But GraphicsContext thinks it is in:
    ScreenGraphicsContext(GraphicsContext)>>clipPolygon:toBottom:
    ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:

because it checks for point y <= aNumber, and they are indeed equal:

    GraphicsContext>>clipPolygon: pointCollection toBottom: aNumber
        ^self
            clipPolygon: pointCollection
            insideBlock: [:point | point y <= aNumber]
            intersectionBlock: [:point1 :point2 | aNumber - point1 y * (point2 x - point1 x) // (point2 y - point1 y) + point1 x @ aNumber]

So the difference of #< in #containsPoint: and #<= in #clipPolygon:toBottom: means the pointCollection never gets clipped, and we happily spin the cpu. The relevant code appears unchanged in the 7.8 beta.

Any recommendations as to how to fix or work around this?

Thanks,

Dave Stevenson
[hidden email]

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: endless loop printing a line

Andres Valloud-6
What platform is the code running on?

On 5/3/2011 10:35 AM, Dave Stevenson wrote:

> My print routine does these basic steps:
> - open a window on my #printSpec
> - get a new print job with a MockMedium on a ScalingWrapper on the print
> window
> - ask the medium to display
> - send the completed print job to the printer
>
> When the scale of the print job is extreme enough (like when printing a
> very large visual on too small a paper size), display primitives (such
> as HostPrinterGraphicsContext>>primDisplayLineFrom:to:) can fail because
> the coordinates exceed the number ranges allowed in the primitives. The
> prim failure code leads to #displayClippedPolygon:, which begins the
> endless loop.
>
> My partial work around is to override #displayClippedPolygon: to raise a
> Notification if pointCollection cannot be clipped (at the end of the
> method, is clippedPointCollection asArray = pointCollection asArray?). I
> have to handle this notification in the #displayOn: method for my main
> visual object to abort the endless loop (I abort when unable to clip the
> same pointCollection more than once consecutively, because I'm unsure
> whether any paths through this code would resolve after a single
> clipping failure).
> However, this is only a partial work around because there remain the
> coordinate limitations of the graphics primitives. When will those
> limits be raised? Are they higher in the 64 bit VM?
>
> Dave Stevenson
> [hidden email]
>
>
> ------------------------------------------------------------------------
> *From:* Dave Stevenson <[hidden email]>
> *To:* [hidden email]
> *Sent:* Mon, May 2, 2011 3:16:31 PM
> *Subject:* [vwnc] endless loop printing a line
>
> I've got an endless loop in VW 7.6 trying to print the border of a
> widget to a scaled MockMedium. In particular, the problem happens when
> printing the bottom of line of the border. Here is the repeating part of
> the stack:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
> ScreenGraphicsContext>>roundedDisplayPolygon:at:
> ScreenGraphicsContext>>primDisplayPolygon:at:
> ScreenGraphicsContext(GraphicsContext)>>displayPolygon:at:
> ScreenGraphicsContext(GraphicsContext)>>displayPolygon:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
> ...
>
> And the relevant data:
> pointCollection = #(3@25 3@24 797@24 797@25)
> clippingBounds = 0@0 corner: 800@25
> Note that the pointCollection is aligned with the bottom of the
> clippingBounds.
>
> At issue is an apparent mismatch between Rectangle and GraphicsContext
> as to whether the bottom points (3@25 or 797@25) are inside the
> clippingBounds. Rectangle thinks it is out:
> Rectangle>>containsPoint:
> optimized [] in GraphicsContext>>isPolygon:inside:
> Array(ArrayedCollection)>>allSatisfy:
> ScreenGraphicsContext(GraphicsContext)>>isPolygon:inside:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
>
> because it checks for aPoint < corner, but aPoint y is not less than
> corner y, so it answers false:
>
> Rectangle>>containsPoint: aPoint
> "Answer whether the argument aPoint is within the receiver."
> ^origin <= aPoint and: [aPoint < corner]
>
> Point>>< aPoint
> "Answer whether the receiver is 'above and to the left' of the
> argument, aPoint."
> | p |
> p := aPoint asPoint.
> ^x < p x and: [y < p y]
>
> But GraphicsContext thinks it is in:
> ScreenGraphicsContext(GraphicsContext)>>clipPolygon:toBottom:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
>
> because it checks for point y <= aNumber, and they are indeed equal:
>
> GraphicsContext>>clipPolygon: pointCollection toBottom: aNumber
> ^self
> clipPolygon: pointCollection
> insideBlock: [:point | point y <= aNumber]
> intersectionBlock: [:point1 :point2 | aNumber - point1 y * (point2 x -
> point1 x) // (point2 y - point1 y) + point1 x @ aNumber]
>
> So the difference of #< in #containsPoint: and #<= in
> #clipPolygon:toBottom: means the pointCollection never gets clipped, and
> we happily spin the cpu. The relevant code appears unchanged in the 7.8
> beta.
>
> Any recommendations as to how to fix or work around this?
>
> Thanks,
>
> Dave Stevenson
> [hidden email]
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: endless loop printing a line

Dave Stevenson-3
Windows XP
 
Dave Stevenson
[hidden email]



From: Andres Valloud <[hidden email]>
To: "[hidden email]" <[hidden email]>
Sent: Tue, May 3, 2011 2:55:49 PM
Subject: Re: [vwnc] endless loop printing a line

What platform is the code running on?

On 5/3/2011 10:35 AM, Dave Stevenson wrote:

> My print routine does these basic steps:
> - open a window on my #printSpec
> - get a new print job with a MockMedium on a ScalingWrapper on the print
> window
> - ask the medium to display
> - send the completed print job to the printer
>
> When the scale of the print job is extreme enough (like when printing a
> very large visual on too small a paper size), display primitives (such
> as HostPrinterGraphicsContext>>primDisplayLineFrom:to:) can fail because
> the coordinates exceed the number ranges allowed in the primitives. The
> prim failure code leads to #displayClippedPolygon:, which begins the
> endless loop.
>
> My partial work around is to override #displayClippedPolygon: to raise a
> Notification if pointCollection cannot be clipped (at the end of the
> method, is clippedPointCollection asArray = pointCollection asArray?). I
> have to handle this notification in the #displayOn: method for my main
> visual object to abort the endless loop (I abort when unable to clip the
> same pointCollection more than once consecutively, because I'm unsure
> whether any paths through this code would resolve after a single
> clipping failure).
> However, this is only a partial work around because there remain the
> coordinate limitations of the graphics primitives. When will those
> limits be raised? Are they higher in the 64 bit VM?
>
> Dave Stevenson
> [hidden email]
>
>
> ------------------------------------------------------------------------
> *From:* Dave Stevenson <[hidden email]>
> *To:* [hidden email]
> *Sent:* Mon, May 2, 2011 3:16:31 PM
> *Subject:* [vwnc] endless loop printing a line
>
> I've got an endless loop in VW 7.6 trying to print the border of a
> widget to a scaled MockMedium. In particular, the problem happens when
> printing the bottom of line of the border. Here is the repeating part of
> the stack:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
> ScreenGraphicsContext>>roundedDisplayPolygon:at:
> ScreenGraphicsContext>>primDisplayPolygon:at:
> ScreenGraphicsContext(GraphicsContext)>>displayPolygon:at:
> ScreenGraphicsContext(GraphicsContext)>>displayPolygon:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
> ...
>
> And the relevant data:
> pointCollection = #(3@25 3@24 797@24 797@25)
> clippingBounds = 0@0 corner: 800@25
> Note that the pointCollection is aligned with the bottom of the
> clippingBounds.
>
> At issue is an apparent mismatch between Rectangle and GraphicsContext
> as to whether the bottom points (3@25 or 797@25) are inside the
> clippingBounds. Rectangle thinks it is out:
> Rectangle>>containsPoint:
> optimized [] in GraphicsContext>>isPolygon:inside:
> Array(ArrayedCollection)>>allSatisfy:
> ScreenGraphicsContext(GraphicsContext)>>isPolygon:inside:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
>
> because it checks for aPoint < corner, but aPoint y is not less than
> corner y, so it answers false:
>
> Rectangle>>containsPoint: aPoint
> "Answer whether the argument aPoint is within the receiver."
> ^origin <= aPoint and: [aPoint < corner]
>
> Point>>< aPoint
> "Answer whether the receiver is 'above and to the left' of the
> argument, aPoint."
> | p |
> p := aPoint asPoint.
> ^x < p x and: [y < p y]
>
> But GraphicsContext thinks it is in:
> ScreenGraphicsContext(GraphicsContext)>>clipPolygon:toBottom:
> ScreenGraphicsContext(GraphicsContext)>>displayClippedPolygon:
>
> because it checks for point y <= aNumber, and they are indeed equal:
>
> GraphicsContext>>clipPolygon: pointCollection toBottom: aNumber
> ^self
> clipPolygon: pointCollection
> insideBlock: [:point | point y <= aNumber]
> intersectionBlock: [:point1 :point2 | aNumber - point1 y * (point2 x -
> point1 x) // (point2 y - point1 y) + point1 x @ aNumber]
>
> So the difference of #< in #containsPoint: and #<= in
> #clipPolygon:toBottom: means the pointCollection never gets clipped, and
> we happily spin the cpu. The relevant code appears unchanged in the 7.8
> beta.
>
> Any recommendations as to how to fix or work around this?
>
> Thanks,
>
> Dave Stevenson
> [hidden email]
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: endless loop printing a line

Travis Griggs-4
In reply to this post by Dave Stevenson-3

On May 3, 2011, at 10:35 AM, Dave Stevenson wrote:

My print routine does these basic steps:
    - open a window on my #printSpec
    - get a new print job with a MockMedium on a ScalingWrapper on the print window
    - ask the medium to display
    - send the completed print job to the printer

When the scale of the print job is extreme enough (like when printing a very large visual on too small a paper size), display primitives (such as HostPrinterGraphicsContext>>primDisplayLineFrom:to:) can fail because the coordinates exceed the number ranges allowed in the primitives. The prim failure code leads to #displayClippedPolygon:, which begins the endless loop. 

My partial work around is to override #displayClippedPolygon: to raise a Notification if pointCollection cannot be clipped (at the end of the method, is clippedPointCollection asArray = pointCollection asArray?). I have to handle this notification in the #displayOn: method for my main visual object to abort the endless loop (I abort when unable to clip the same pointCollection more than once consecutively, because I'm unsure whether any paths through this code would resolve after a single clipping failure).
 
However, this is only a partial work around because there remain the coordinate limitations of the graphics primitives. When will those limits be raised? Are they higher in the 64 bit VM? 

This sounds an awful lot like:

58370: "Infinite failure mode in polygon display"

Which was fixed in the Dec09.3 build (candle which became 7.7.1 I think)

--
Travis Griggs
Objologist
"I did not have time to write you a short program, so I wrote you a long one instead."


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc