11 Replies Latest reply on Oct 20, 2010 1:01 AM by Claudiu Ursica

    Webservice problem, ui locked while parsing

    cyberjunk1234

      dear community,

       

      our flex-application consumes a SOAP webservice that was integrated by what I call the "flex-framework" for webservices.

      That means we used FlashBuilder to integrate the Webservice. It automatically created proxy classes for return-objects and the webservice itself with its available methods. Basically it's working nicely.

       

      To call a webservice we do something like:

      var token:AsynToken = webservice.ourMethod();

      token.addResponder(new mx.rpc.Responder(result_CallBack, fault_CallBack);

       

      there are no problems, except this:

      one of your methods returns "huge amount of data". it's about 100kb (compressed-http transfer) / 500kb (uncompressed-http transfer) that represent a list of about 1000-2000 serialized objects of the according proxy-class. (flex generates an arraycollection of according proxy-class during parsing).

      while download of this data is in progress, the user interface is not blocked and an enabled busycursor is rotating but unfortunately while parsing the data (which takes about 5s on a fast machine) the user interfaces seems to be blocked/hanging

       

      is there any way to avoid this user-interface lock during parsing?

      it would be nice if someone could give me a hing on how to adopt the download-behaviour for parsing-behaviour.

       

      thanks for your time & help

        • 1. Re: Webservice problem, ui locked while parsing
          Claudiu Ursica Level 4

          Do you actually need 1000 - 2000 objects? If not do data paging. Otherwise try

          to simulate some threading. Process only chunks of them on enter frame - you

          need to write some logis of your own though. Probably not trivial but doable. I

          was able to fix my similar issue by loading around 50 -100 objects and only when

          needed more.

           

          C

          • 2. Re: Webservice problem, ui locked while parsing
            cyberjunk1234 Level 1

            dear Ursica,

             

            thanks for your reply. splitting up the data might be a solution, but this would require major changes of the webservice and currently we're looking for a way to solve this without changing the webservice. so paging is no solution (at least not for the moment).

             

            I've also read about simulating threads in flex, but that seemed a little bit confusing to me...

            anyway, the built-in behaviour while downloading is pretty nice, too bad they didn't adopt this for parsing

             

            at the moment I don't have any idea how to get started..

            I think I will need to derive from some builtin-classes that manage the webservice-calls and then change the behaviour according to my requirements

             

            unfortunately I don't have that much experience with flex right now..

            • 3. Re: Webservice problem, ui locked while parsing
              Claudiu Ursica Level 4

              Normally your web service operations should at least give you the option to set

              how manny records to fetch. The paging logic will stay then in the client.

               

              Back to the other option. Your issue is not getting data is taht when you need

              to process data your UI freezes. That is because actionscript nature si single

              threaded and it freezes everything until it finishes looping through your data.

              You need to break that loop. You can do it based on time (e.g. loop for 30 ms -

              this is just bogus number), or you can do it based on a certain number e.g when

              you already looped 100 times (bogus number againg) break out. Set this login on

              the Enter_Frame event handler. So then you will process only certain amounts of

              data on every frame and give the player a chance to draw the screen. Now this is

              oversimplified. You need to test it to see how it works and tune it...

              Unfortunately I don't have an example. When I had the issue I was able to do

              paging....

               

              C

              • 4. Re: Webservice problem, ui locked while parsing
                Devtron Level 3

                Threading is a subject I have not seen covered in any of my FLEX books. Does anyone have any examples or demos of FLEX threading?


                • 5. Re: Webservice problem, ui locked while parsing
                  Claudiu Ursica Level 4

                  The closest you'll get are these links

                   

                  http://www.senocular.com/flash/tutorials/asyncoperations/

                  http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html

                   

                  Implementing something like that is on my personal roadmap but I have noi idea

                  when I'll find some spare time to do it ...

                   

                  C

                  • 6. Re: Webservice problem, ui locked while parsing
                    Devtron Level 3

                    ^ Cheers for that!! I have often thought about writing a FLEX threading class myself...I wish I had more time...

                    • 7. Re: Webservice problem, ui locked while parsing
                      cyberjunk1234 Level 1

                      thanks for those links, they're helpful on the topic of "threading-emulation", especially the first one is very good to understand..

                       

                      I think I would be able to implement such thing in more simple scenarios, like doing a expansive calculation on button click,

                      but at the moment I'm stuck in an earlier stage - how to "hijack" the existing process of retrieving and parsing the webservice-data (that is nearly entirely done by flex-framework "automatically")

                       

                      it would be a good point to start if I would know which class provides the parsing of the soap envelope.

                      I think I will have to derive from that class and overwrite its parsing function with an frame_event based parsing.

                       

                      I'll tell you if there will be created any useful solution

                      • 8. Re: Webservice problem, ui locked while parsing
                        Claudiu Ursica Level 4

                        By the time your result_CallBack is called you should have the data already in

                        strong typed objects (especially if you generated the server by flex/flash

                        builder). Are you sure the app hangs there? When I had the issue was after

                        having the data the data needed further processing. I think that the call is

                        covered by the busy cursor. It did not happen to me to have issue with the data

                        during the call itself. One more question are you loading the data on user

                        demand or on startup ? Actually 2: How are you displaying 2000 obejects on the

                        UI ?

                         

                        C

                        • 9. Re: Webservice problem, ui locked while parsing
                          cyberjunk1234 Level 1

                          hey Ursica,

                           

                          I might have been misunderstood about that.

                           

                          The App hangs between calling my webservice method and waiting for the call to callback handler.

                          because as you mentioned, there's already a fully populated dataset in the event args when the callback handler is called.

                           

                          it's:

                          1. call webservice method

                          2. < app hangs during parsing, not during download>

                          3. callback handler is executed

                           

                          that (exactly) is, what makes it so difficult for me, I don't have any idea what's exactly going on during that period.

                          cheers

                          • 10. Re: Webservice problem, ui locked while parsing
                            Flex harUI Adobe Employee

                            If you are asking for objects from the webservice, the XML has to be

                            converted to objects and if that takes a long time it will lock the UI.

                            • 11. Re: Webservice problem, ui locked while parsing
                              Claudiu Ursica Level 4

                              How about get XML from Web Servi ce and do you own parsing. It will be easier to

                              tap into the parsing logic since it's your own.

                               

                              Still feel better about data paging thoug if there's a small chance to load less

                              data.

                              C