OutOfMemoryExceptions on Tile Updates

7 posts, 0 answers
  1. Nachiket
    Nachiket avatar
    15 posts
    Member since:
    Jul 2012

    Posted 07 Jul 2014 Link to this post

    Hi,
    I am receiving a lot of Crash Reports for my App "Battery.Net Pro" on windows phone 8 store. After analyzing the Crash Reports from dev center. It seems like 90 % of these crashes are in the background agent on this line of code. 

    "BackgroundAgent.TileHelper.UpdateLiveTile"

    I have tried to optimize my background agent and seen that the Memory used by app before this line of code is about 6 Megs. This is an in-frequent error. Does not happen always, but surely affecting the user experience and it is getting bad reviews for my app. 

    This is the stacktrace. 
    "0        telerik_windows_backgroundagenttools_ni    Telerik.Windows.Controls.PngEncoder.PNGWriter.WriteDataChunksUncompressed                     0x000000b4    
    1        telerik_windows_backgroundagenttools_ni    Telerik.Windows.Controls.PngEncoder.PNGWriter.WritePNG                                        0x000000ba    
    2        telerik_windows_backgroundagenttools_ni    Telerik.Windows.Controls.LiveTileHelper.SaveTileImage                                         0x0000006c    
    3        telerik_windows_backgroundagenttools_ni    Telerik.Windows.Controls.LiveTileHelper.SaveImageFromVisual                                   0x0000015a    
    4        telerik_windows_backgroundagenttools_ni    Telerik.Windows.Controls.RadFlipTileData.Telerik.Windows.Controls.ITileData.CreateTileData    0x00000132    
    5        telerik_windows_backgroundagenttools_ni    Telerik.Windows.Controls.LiveTileHelper.UpdateTile                                            0x0000003e    
    6        backgroundagent_ni                         BackgroundAgent.TileHelper.UpdateLiveTile                                                     0x000001f6    
    7        backgroundagent_ni                         BackgroundAgent.BackgroundTask+__c__DisplayClass5._OnInvoke_b__2                              0x00000024"


    Can you please help ?

    Thanks,
    Nachiket
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 10 Jul 2014 Link to this post

    Hi Nachiket,

    Can you send us an example, which reproduces the problem? I understand it does not happen all the time, but having a project which reproduces the error would be really helpful for us to investigate the possible reasons and provide a fix. Thank you.

    Best regards,
    Ves
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Nachiket
    Nachiket avatar
    15 posts
    Member since:
    Jul 2012

    Posted 14 Jul 2014 in reply to Ves Link to this post

    Hi Ves,
    Thanks for your reply. I cannot send you the project, entirely and the just the background agent code piece wont work without entire solution. 
    However I will try to give you all the information about what I do in background agent here.

    "
    RadFlipTileData flipTileData = new RadFlipTileData();
                        flipTileData.Count = 0;
                        flipTileData.Title = "";

                       

                        flipTileData.MeasureMode = MeasureMode.Element;

                        flipTileData.IsTransparencySupported = true;

                        flipTileData.SmallVisualElement = GetSmallFrontVisualContent(DbManager);

                        flipTileData.VisualElement = GetMediumFrontVisualContent();

                        flipTileData.BackVisualElement = GetMediumBackVisualContent();

                        flipTileData.WideVisualElement = GetWideFrontVisualContent();
                        flipTileData.WideBackVisualElement = GetWideBackVisualContent();


                        LiveTileHelper.UpdateTile(appTile, flipTileData);
    "
    Inside each method which returns a visual element I am creating a container Grid with the following dimensions
     ///Small 159 x 159
                ///Medium 336 x 336
                ///Large 691 x 336
    and it inside grid there will be an image element for the Icon and a few textblocks and stack panels in a few tiles. Nothing crazy.

    I have attached a screenshot of 3 types of tiles. Please let me know if this should be enough information or you need more. 






  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 17 Jul 2014 Link to this post

    Hi Nachiket,

    The LiveTileHelper saves images of the UIElements that you pass to it. If IsTransparencySupported is set to true, the images are saved in .png format and if it is set to false, they are saved as jpg-s. The png format takes significantly more memory than the jpg, so if you save in png from a BackgroundAgent you may hit the memory limits. Background agent has this limitation of 20MB memory usage on 1GB device and 11MB for devices equipped with less memory.

    If you need to update the tile from an agent, you may have to disable the transparency (i.e. use .jpg) and/or the wide tile size so that you reduce the memory consumption. In addition, please make sure that the images provided within the visual element are not larger than their actual display size i.e. you do not need an 600x600 image to show it in a small tile.


    Best regards,
    Ves
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. ckruhs
    ckruhs avatar
    2 posts
    Member since:
    Oct 2013

    Posted 04 Aug 2014 in reply to Nachiket Link to this post

    Hi Nachiket,
    Did you find a solution for this issue? I struggle with the same problem.
    Even if I use IsTransparencySupported = false the Live Tile is sometimes corrupt.
    That also happens if I update the Live Tile when closing the app.

    Best regards
    ckruhs
  7. Nachiket
    Nachiket avatar
    15 posts
    Member since:
    Jul 2012

    Posted 27 Jan 2015 in reply to ckruhs Link to this post

    Hi Ckruhs,
    No I have not yet found the solution for this. I have seen improvement on lower memory devices when I set IsTransparentcySupported to False. 
    I think you are talking about corrupt tiles. It may be something else. Because In my case I either get the tile updated or not. When its updates it is fine. When it fails, my tile doesnt not change.

    Please check if you are calling "UpdateLayout()" on the visual elements when you update the LiveTile. 

    -Nachiket
  8. ckruhs
    ckruhs avatar
    2 posts
    Member since:
    Oct 2013

    Posted 02 Feb 2015 in reply to Nachiket Link to this post

    Hi Nachiket,
    Thanks for the update.

    Best regards
    ckruhs
Back to Top
DevCraft banner