Minor change in handling NaN positions in Flash Player 10,0,22

I’ve just discovered a “bug” in the latest Flash Player. Actually the “bug” was in a production, that only worked in the latest player and not in previous players. I’ve boiled it down to this:

If the x- or y-attribute of a DisplayObject is set to NaN, in previous players this caused the attribute to be set to -107374182.4. In the latest player, the attribute is set to 0.

The value -107,374,182.4 is -2,147,483,648/20. Flash uses “twixels” for positions, which is a twentieth pixel. Thus the lowest possible value x or y can hold is -(2^31)/20 which is exactly -107,374,182.4. This means, that when rendering DisplayObjects with a position in either direction with a value of NaN, the position was instead rendered with the lowest possible value for this attribute previously, but now it is rendered with this attribute set to 0 instead.

Thus, it is not a bug per se, but it is a change in behavior in response to an error condition – namely bad positioning.

My test-page can be found here. Please try this page out and copy-paste the results in the comments, if you do not experience the same results as described above. The result in Flash Player 10,0,22(,87) on Mac is:

Player version: MAC 10,0,22,87
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: 0 <--
typeof sprite.x: number

In the previous player 10,0,12(,36) the result was:

Player version: MAC 10,0,12,36
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4 <--
typeof sprite.x: number

Note the second-to-last line – the value of x is different when “undefined” is added to the current value.

Some other test results from non-Mac versions as well as previous versions:

Player version: MAC 10,0,2,54
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4
typeof sprite.x: number
 
Player version: MAC 9,0,159,0
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4
typeof sprite.x: number
 
Player version: MAC 9,0,124,0
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: -107374182.4
typeof sprite.x: number
 
Player version: WIN 10,0,22,87
1 + undefined: NaN
typeof (1 + undefined): number
1 + (1 + undefined): NaN
typeof (1 + (1 + undefined)): number
sprite.x: 70
typeof sprite.x: number
sprite.x += undefined
sprite.x: 0
typeof sprite.x: number

My very simple source FLA file is available here. The xtra info in the above is simply to make sure, that no other changes in handling NaN or undefined has happened.

Thanks to David Wulff, Anders Krarup and Katharina Berg for help in testing.

Update 4.07PM: It is actually mentioned in the release notes as: “Fix AS APIs’ inconsistent handling of NaN parameters on different platforms. (FP-612,FP- 903, FP-964/2200454)”. However, all these reports are about Windows installations only and they all mention, that all players before FP10 set the attribute to 0 and setting the attribute to -107374182.4 only happened in Flash Player 10,0,2 and 10,0,12 (and probably also the Linux-only 10,0,15). From my results however, it is clear that for Mac this issue has always been the case also in Flash Player 9, which is revealed in the comment about the fix as “inconsistent handling [...] on different platforms”.

It seems to be an actual desired result that this was “fixed” in order to bring the error condition handling back to the way it has always been in flash players for Windows in all previous versions before FP10.

Related posts:

  1. Weird bitmap fill crash error in Flash CS4.
  2. Using AddThis with Flash
  3. Flash development and the practice of Scripted Layout

Category: AS2, AS3 4 comments »

4 Responses to “Minor change in handling NaN positions in Flash Player 10,0,22”

  1. dominic

    Player version: LNX 10,0,22,87
    1 + undefined: NaN
    typeof (1 + undefined): number
    1 + (1 + undefined): NaN
    typeof (1 + (1 + undefined)): number
    sprite.x: 70
    typeof sprite.x: number
    sprite.x += undefined
    sprite.x: 0
    typeof sprite.x: number

    On an unrelated note, there is some CSS weirdness, the text for “Name (required)”, “Mail (will not be published) (required)” and “Website” appears to be the same color as the background, resulting in essentially invisible text.

    I had to highlight the page to find out what to type where.

  2. Barklund

    Hi Dominic,

    Thanks for your input – it is clear that the handling of NaN coordinates is also done properly on Linux in the latest Flash Player – the interesting thing would be to see the result using FP9 and using FP10

    I’ve fixed the CSS (I think).

  3. Barklund

    Or well, not “properly”, but at least consistently :)

  4. Tim K

    This tip may have saved me HOURS upon HOURS. If so, I thank you in advance. We’ll see after the client tests the new build on their 10,0,2,54 version of Flash Player.


Leave a Reply



Back to top

     

Get Adobe Flash playerPlugin by wpburn.com wordpress themes