locked
BUG: Silverlight makes browser hang after BeginSaveChanges on some machines RRS feed

  • Question

  • Hi

    I'm releasing a webapp using Silverlight to a number of trial clients (about 30), and so far I have 3 reports of an issue with IE only where the app functions normally until an attempt to save data back to a data service is made (interestingly, data can be read from the data service no problem).  BeginSaveChanges() is called at various points with differing data updates but all of them cause this problem.  The changes are received and processed by the server, the code after the call to BeginSaveChanges() completes successfully, and it hangs either after control is returned to non-user code or in the method where EndSaveChanges() is called.  I can't determine which because I can't debug the app as I can't reproduce it in a development environment, and I can't display debug messages because you can't get SL's UI to immediately update before it hits the hang.  Note this is not a timeout - the hang comes within a few seconds of the save, and the whole browser is dead.

    I've checked the client is using SL 2.0.40115, it seems this may be an IE6 only issue. 2 problem machines use McAfee and one uses Symantec.

    Hope I can get some response on this as this looks like a significant problem with SL / Data Services affecting (in my case) 10% of users of apps that write data using Data Services.
    Thursday, June 25, 2009 10:32 AM

Answers

  • Hello,


    Can you try changing the code to dispatch the result of the EndExecute to the UI thread:

    Dispatcher.BeginInvoke( () =>
    {

    try

         {
                DataServiceResponse response = ctx.EndSaveChanges(result);
          }

    catch(DataServiceRequestException ex)

    {}

    }

    Thanks,

    Monica

     



    }

    Thursday, December 17, 2009 6:27 PM
    Moderator

All replies

  • Hi James, 
      Can you share some sample code with us ?
      This looks like an issue wherein the code in the savechanges callback is  hanging after saving changes.
     

    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Thursday, June 25, 2009 5:00 PM
    Moderator
  • Hi Phani

    Thanks for responding.

            public void Process(object context)
            {
                ctx = context as CraftworksEntities;
    
                Security_Users security_User = this.person.DataServicesObject as Security_Users;
                if (security_User == null)
                {
                    security_User = new Security_Users();
                    ctx.AddToSecurity_Users(security_User);
                }
    
                if (LocalDataCache.PersonObjectToData(this.person, security_User, ctx))
                {
                    AppFunctions.ApplicationErrorHandler.ShowDebug("Before saving");
                    ctx.BeginSaveChanges(SaveChangesOptions.Batch, new AsyncCallback(Processed), security_User);
                    AppFunctions.ApplicationErrorHandler.ShowDebug("Saving Person");
                }
            }
    
            private void Processed(IAsyncResult result)
            {
                try
                {
                    AppFunctions.ApplicationErrorHandler.ShowDebug("Person Saved");
                    DataServiceResponse response = ctx.EndSaveChanges(result);
                    AppFunctions.ApplicationErrorHandler.ShowDebug("Read Response");
                    if (response.BatchStatusCode >= 400)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        if (this.person is Customer)
                            (this.person as Customer).PointsForRegistration = 0;
                        else if (this.person is MemberOfStaff)
                        {
                            StaffDisplay display = new StaffDisplay();
                            if (!LocalDataCache.AllStaffDatas.Any(su => su.suID == this.person.UserId))
                            {
                                LocalDataCache.StaffDataToDisplay(this.person as MemberOfStaff, display);
                                LocalDataCache.StaffDisplays.Add(display);
                                LocalDataCache.AllStaffDatas.Add(this.person.DataServicesObject as Security_Users);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    AppFunctions.ApplicationErrorHandler.ShowDebug("Error: " + ex.Message);
                    AppFunctions.ApplicationErrorHandler.OnDataError("A connection error meant your changes or additions to staff or customers were not saved");
                }
                finally
                {
                    AppFunctions.ApplicationErrorHandler.ShowDebug("Calling progress changed");
                    OnProgressChanged(1.0);
                }
    
            }
    I inserted the calls to 'ShowDebug' in order to pin down where the hang was happening.  This call pops up an alert window from the browser (Silverlight itself won't update its display until it returns from any problem code whereas it will show the alert window immediately).

    It shows the "Before saving" message and the "Saving Person" message, but the "Person Saved" message is never shown indicating to me that the browser hangs somewhere in the code that receives the response from the web request to do the SaveChanges, before this response is returned to my code.  I could guess that some bit of security software is interfering with the response calling an exception to be generated which is not dealt with properly by the code.

    I have also now seen this issue persisting for a client after he upgraded to IE8 from IE6, however the issue does not occur with Firefox.  I checked all his internet settings against a machine where the app works fine, but found no significant differences.

    cheers

    James
    Monday, August 3, 2009 3:03 PM
  • I'm exactly with the same problem.
    Did you find a solution?

    Thank You in advance,
    Helder
    Monday, December 14, 2009 4:23 PM
  • Hello,


    Can you try changing the code to dispatch the result of the EndExecute to the UI thread:

    Dispatcher.BeginInvoke( () =>
    {

    try

         {
                DataServiceResponse response = ctx.EndSaveChanges(result);
          }

    catch(DataServiceRequestException ex)

    {}

    }

    Thanks,

    Monica

     



    }

    Thursday, December 17, 2009 6:27 PM
    Moderator
  • Hello,


    Can you try changing the code to dispatch the result of the EndExecute to the UI thread:

    Dispatcher.BeginInvoke( () =>
    {

    try

         {
                DataServiceResponse response = ctx.EndSaveChanges(result);
          }

    catch(DataServiceRequestException ex)

    {}

    }

    Thanks,

    Monica

     



    }


    Could you give more explanation on it? Why this? I know it's something stupid.
    Friday, August 6, 2010 4:13 AM