9 Replies Latest reply on Nov 30, 2009 4:30 PM by mike_morearty

    [problem] Flex 4 and the Flash Debug Player

    divillysausages

      Hi guys,

       

      I'm currently writing a game engine using the Flex 4 SDK that shipped with Flash Builder. I keep running into a weird bug that's absolutely wrecking my head. I'm using FlashDevelop as my IDE.

       

      Basically what happens is that every so often when compiling in Debug mode, the Flash player will fail to launch and instead I get this message:

      "Set breakpoints and then type 'continue' to resume the session."

       

      Problem is, I'm using FlashDevelop and I don't have a debugger, or any way to type continue (not that I want to type it in the first place). Basically now, FlashDevelop, or Flash, is blocking. I can't launch again unless manually close the Flash Debug Player (the latest version 10 btw), or close FlashDevelop, in which case, the Flash Debug Player now starts up.

       

      Now, crazy as this sounds, I think it's related to file size. For example, the latest occurrence of this bug was when I added a setter to a class, that went like this:

       

      public function set BackgroundColour( c:Colour ):void

      {

           this.m_bgColour = c;.

      }

       

      Pretty innocuous, right? However adding this function means that now I can't run my program in debug. If I add the line:

       

      private var myRandomNumber:Number = 1;

       

      Before my function, everything works fine. If I change the Number to an int, everything breaks again!

       

      This doesn't happen all the time, and is fine when compiling in Release. Seriously, this bug is vexing me - does anyone know what's behind it or how to stop it happening (aside from filling your class with bloat)?

       

      Thanks,

      Damian

        • 1. Re: [problem] Flex 4 and the Flash Debug Player
          mike_morearty Level 1

          Hmm, interesting.  I've never tried FlashDevelop, but based on what you describe, it sounds like perhaps they need to make a change to their code.

           

          The message you mention, telling you to type "continue", is normally only seen when you use FDB, the free command-line debugger that is part of the Flex SDK.  In this case, it sounds like perhaps FlashDevelop is launching FDB programmaticaly, and then communicating with it over a pipe, and perhaps FDB sent a message that FlashDevelop didn't know how to respond to.  Probably what they want to do is just send the command "continue".  (Really, the recommended approach is not to talk to FDB over a pipe at all, but rather, to use FDB's Java API instead; but perhaps they have other reasons why they didn't do that, e.g. maybe FlashDevelop isn't written in Java.)

           

          - Mike Morearty, Flash Builder team

          • 2. Re: [problem] Flex 4 and the Flash Debug Player
            divillysausages Level 1

            Hi Mike,

             

            Thanks for getting back to me. I don't think this is a problem with FlashDevelop, I think it's the specific SDK - if I compile using the Flex3.4 SDK, it's fine, I've no problem (we're using the 4 SDK to make it easier to connect to DB's etc).

             

            If it helps, this is the output that FlashDevelop gives me when everything works fine (it's built in c# btw):

            Using the Flex Compiler Shell.

            Building Concept

            mxmlc -load-config+=obj\ConceptConfig.xml -debug=true -incremental=true -benchmark=false -static-link-runtime-shared-libraries=true -o obj\Concept633941407227323428

            Incremental compile of 2

            Loading configuration file D:\Flash\Concept\External\FlexSDK4.0.0\frameworks\flex-config.xml

            Loading configuration file D:\Flash\Concept\obj\ConceptConfig.xml

            Files changed: 1 Files affected: 0

            obj\Concept633941407227323428 (67119 bytes)

            (fcsh)Build succeeded

            Done (0)

            [FDB halted]

            [Capturing traces with FDB]

            Adobe fdb (Flash Player Debugger) [build 10485]

            Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.

            (fdb) run

            Waiting for Player to connect

            Player connected; session starting.

            Set breakpoints and then type 'continue' to resume the session.

            [SWF] D:\Flash\Concept\Concept.swf - 135,309 bytes after decompression

            (fdb) continue

             

            The line "(fdb) continue" there is automatic - I don't type it.

             

            When it doesn't work - I can't give you the exact output, because today it's fine (I even tried reverting to yesterday's build but no joy), but it stalls at "Set breakpoints and then type 'continue' to resume the session".

             

            Like I said, this is a bit random, but the only way I have of fixing it is to bloat the code a bit - this time is was adding a variable, last time it was calling a trace before the code that I added that was causing this. Eventually, later, I can go back and remove the defunct code.

             

            It's like I have to add something big enough to change how it's compiled down. For example, adding a int variable to the class before my function didn't work, but changing the int to a number did.

             

            Thanks,

            Damian

            • 3. Re: [problem] Flex 4 and the Flash Debug Player
              mike_morearty Level 1

              This is pretty much as I expected: It looks like FlashDevelop is launching your app by running FDB and then "typing" at it -- sending it commands through a pipe.  And FDB is responding in a way that FlashDevelop is not expecting.

               

              Each time a new SWF loads, FDB will halt again with a message saying to set breakpoints and then type "continue".  With Flex 3, the default compilation results in your entire app being in a single SWF, so you only get that message once.  But with Flex 4, the default compilation results in your app using RSLs (runtime shared libraries) for the Flex SDK part of the app, which keeps your main SWF a lot smaller.  But the result is that FDB will halt more than once.

               

              FlashDevelop probably needs to change their code to detect the message saying to set breakpoints and then type "continue", and to then respond appropriately.

              1 person found this helpful
              • 4. Re: [problem] Flex 4 and the Flash Debug Player
                divillysausages Level 1

                Thanks Mike,

                 

                Does this also hold true even when I've set "-static-link-runtime-shared-libraries=true" in the compiler options (see the code example above). Also, it's something that happens randomly - it's not all the time.

                 

                I'll link a post over at the FlashDevelop forums here as well.

                 

                Damian

                • 5. Re: [problem] Flex 4 and the Flash Debug Player
                  divillysausages Level 1

                  Ok, so now it's happening to me again - this time because I added a trace statement. The output from FlashDevelop when it fails:

                   

                  Running process: D:\Flash\FlashDevelop\Tools\fdbuild\fdbuild.exe "D:\Flash\Concept\Concept.as3proj" -ipc 8535486d-36d3-45fc-8f8c-dafb8660c40a -compiler "D:\Flash\Concept\External\FlexSDK4.0.0" -library "D:\Flash\FlashDevelop\Library"

                  Using the Flex Compiler Shell.

                  Building Concept

                  mxmlc -load-config+=obj\ConceptConfig.xml -debug=true -incremental=true -benchmark=false -static-link-runtime-shared-libraries=true -o obj\Concept633945750586751536

                  Incremental compile of 2

                  Loading configuration file D:\Flash\Concept\External\FlexSDK4.0.0\frameworks\flex-config.xml

                  Loading configuration file D:\Flash\Concept\obj\ConceptConfig.xml

                  Files changed: 1 Files affected: 0

                  obj\Concept633945750586751536 (52871 bytes)

                  (fcsh)Build succeeded

                  Done (0)

                  [FDB halted]

                  [Capturing traces with FDB]

                  Adobe fdb (Flash Player Debugger) [build 10485]

                  Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.

                  (fdb) run

                  Waiting for Player to connect

                  Player connected; session starting.

                  Set breakpoints and then type 'continue' to resume the session.

                   

                  and when it succeeds:

                   

                  Running process: D:\Flash\FlashDevelop\Tools\fdbuild\fdbuild.exe "D:\Flash\Concept\Concept.as3proj" -ipc 8535486d-36d3-45fc-8f8c-dafb8660c40a -compiler "D:\Flash\Concept\External\FlexSDK4.0.0" -library "D:\Flash\FlashDevelop\Library"

                  Using the Flex Compiler Shell.

                  Building Concept

                  mxmlc -load-config+=obj\ConceptConfig.xml -debug=true -incremental=true -benchmark=false -static-link-runtime-shared-libraries=true -o obj\Concept633945750586751536

                  Incremental compile of 2

                  Loading configuration file D:\Flash\Concept\External\FlexSDK4.0.0\frameworks\flex-config.xml

                  Loading configuration file D:\Flash\Concept\obj\ConceptConfig.xml

                  Nothing has changed since the last compile. Skip...

                  obj\Concept633945750586751536 (52893 bytes)

                  (fcsh)Build succeeded

                  Done (0)

                  [Shutting down FDB]

                  [Capturing traces with FDB]

                  Adobe fdb (Flash Player Debugger) [build 10485]

                  Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.

                  (fdb) run

                  Waiting for Player to connect

                  [FDB halted]

                  Player connected; session starting.

                  Set breakpoints and then type 'continue' to resume the session.

                  [SWF] D:\Flash\Concept\Concept.swf - 107,653 bytes after decompression

                  (fdb) continue

                   

                  Same solution - I need to declare something big enough to make it work. In this case, putting "var n:Number = 10;" before my trace statement lets it work.

                  • 6. Re: [problem] Flex 4 and the Flash Debug Player
                    divillysausages Level 1

                    Again, I'll point out again that this seems to be triggered by size. This happened when I added a trace() statement to a block of code.

                     

                    No trace: "obj\Concept633945750586751536 (52823 bytes)" Works

                    Trace: "obj\Concept633945750586751536 (52868 bytes)" Hangs

                    Declare a Number before trace: "obj\Concept633945750586751536 (52892 bytes)" Works

                    • 7. Re: [problem] Flex 4 and the Flash Debug Player
                      mike_morearty Level 1

                      > Does this also hold true even when I've set "-static-link-runtime-shared-libraries=true" in the compiler options (see the code example above)

                       

                      Oops, no, I hadn't noticed that.

                       

                      > Again, I'll point out again that this seems to be triggered by size

                       

                      Sorry I didn't address that directly in my earlier comments; it's just that I think it is probably a red herring.  But in any case, I continue to suspect that FlashDevelop is somehow misinterpreting the output that is coming from FDB.  There's a way to test my theory: Run the command-line FDB debugger by itself, outside of FlashDevelop, and see if it behaves properly.

                       

                      To try this: At a command line prompt, find fdb.exe (it's in the Flex SDK's "bin" directory) and run it, with the path to your swf as an argument, e.g. "fdb myapp.swf" (or "fdb myapp.html" if you want it to run in a web browser).  It should launch the swf and output a few lines that are very similar to the lines you are seeing in FlashDevelop.  If and when you see the "Set breakpoints and then type 'continue' to resume the session" prompt (and you will certainly see it at least once), just type the command "continue".

                       

                      It should work fine, with both the swf that FlashDevelop works with and the one that FlashDevelop doesn't work with.  By "work fine", I mean, if you type "continue" each time that prompt appears, eventually the app will just be running normally; I am not making any guarantees about how many times the prompt will appear.

                       

                      Let me know how it goes.

                      • 8. Re: [problem] Flex 4 and the Flash Debug Player
                        divillysausages Level 1

                        Thanks Mike,

                         

                        I had to wait until it was happening to me again. When it was stalling in FlashDevelop, I opened the fdb from the command window and tried running if from there. Once I type "continue" it works fine.

                         

                        For comparison, I ran the fdb from the command line on swf that FlashDevelop had no problem with, and the only difference seems to be a line that comes after "Set breakpoints..."

                         

                        For swfs that FlashDevelop has no problem with, there's the line "[SWF] (path to swf) - X bytes after decompression" just after this, whereas when there is a problem, this line doesn't appear. Is this a FlashDevelop thing, or is this something that the Flex compiler/fdb puts in?

                         

                        I'll update the post over at the FlashDevelop forums.

                         

                        thanks,

                        Damian

                        • 9. Re: [problem] Flex 4 and the Flash Debug Player
                          mike_morearty Level 1

                          For swfs that FlashDevelop has no problem with, there's the line "[SWF] (path to swf) - X bytes after decompression" just after this, whereas when there is a problem, this line doesn't appear. Is this a FlashDevelop thing, or is this something that the Flex compiler/fdb puts in?

                           

                          This is something that comes from FDB.  FDB outputs that text.  I wonder if there is something about that SWF that is causing FDB not to output that line.

                           

                          Do you have a SWF with which this problem reproduces consistently?  If so, can you email it to me at mmoreart@adobe.com, and I'll see if I can take a look.  No promises, but perhaps I'll be able to see something.