locked
SecondaryTile.updateAsync() crashes

    Question

  • Windows.UI.StartScreen.SecondaryTile.findAllAsync().then(function (tiles) {
        for (var i = 0; i != tiles.size; ++i) {
            tiles[i].updateAsync();
        }
    });

    This code should essentially do nothing, as I'm not updating any of the tile properties. However, my app crashes with this error:

    SCRIPT87: Exception is about to be caught by JavaScript library code at line 511, column 21 in <app>/js/application.js
    0x80070057 - JavaScript runtime error: The parameter is incorrect.
    WinRT information: Property ShortName is invalid or missing.

    I have verified that tiles[i].shortName exists and is set to the expected value. Any ideas?

    EDIT: This code works:

    Windows.UI.StartScreen.SecondaryTile.findAllAsync().then(function (tiles) {
        for (var i = 0; i != tiles.size; ++i) {
            var tile = new Windows.UI.StartScreen.SecondaryTile(tiles[i].tileId);
            tile.updateAsync();
        }
    });

    But this feels like a bug - the vector of tiles I get back from findAllAsync() should work as well.

    EDIT2: <redacted>

    EDIT3: <redacted>

    EDIT4: constructing the new tile and changing its background does what I want, but I'd still argue that I should be able to call updateAsync() on tiles[i].




    Tuesday, April 23, 2013 3:03 AM

Answers

  • May I ask what you are trying to accomplish with this code? Calling updateAsync on a tile suggests that you've changed one of the tile properties. Calling updateAsync without any change seems to be triggering an exception with what looks like a poor error message (in fact, you can't change shortName through this method anyway).

    If your intent is to "freshen" the tiles, e.g. trigger a new live tile update, calling updateAsync won't affect this. It's really just for changing static properties like colors and graphics. Admittedly the docs could be better. Live tile updates operate independently and will, in any case, replace the static properties.

    Kraig
    Author, Programming Windows 8 Apps in HTML, CSS, and JavaScript, a free ebook from Microsoft Press.

    Tuesday, April 23, 2013 4:25 AM

All replies

  • May I ask what you are trying to accomplish with this code? Calling updateAsync on a tile suggests that you've changed one of the tile properties. Calling updateAsync without any change seems to be triggering an exception with what looks like a poor error message (in fact, you can't change shortName through this method anyway).

    If your intent is to "freshen" the tiles, e.g. trigger a new live tile update, calling updateAsync won't affect this. It's really just for changing static properties like colors and graphics. Admittedly the docs could be better. Live tile updates operate independently and will, in any case, replace the static properties.

    Kraig
    Author, Programming Windows 8 Apps in HTML, CSS, and JavaScript, a free ebook from Microsoft Press.

    Tuesday, April 23, 2013 4:25 AM
  • I need (in C#) to update the "Arguments" property of a SecondaryTile and this is precisely the purpose of "UpdateAsync", but I can't because this problem makes the method completely useless. Replace any call with "throw new ArgumentException();" would be the same, really. For now I will just see SecondaryTile as imutable and use a workaround with the help of "TileId".

    But this is a serious bug and it must be fixed ASAP. (And I don't know how to report it.)

    And if I can whine a little more :

    I'm making a TINY app just to learn how to create WinRT apps and this is the SECOND bug I encounter in the process (the first nasty one being: set both the "Bounds" and "ScaledWidth/Height" properties on a BitmapTransform = BOOM). So far WinRT exceptions shows cryptics messages, the docs is often useless, and VS debugger just show me "mscorlib.dll" all the time, without being able to tell me where the faulty call is in my code. I have developed others bigger apps in WPF/C#, but it's a nightmare to develop this little one...

    I think the WinRT API really needs QA and patchs ASAP because it looks terrible at this point...

    Have a good day. :)



    • Edited by Kwanonn Saturday, May 11, 2013 5:46 PM
    Saturday, May 11, 2013 4:53 PM
  • If you're working in C#, please ask your questions over in the C#/VB forum, as they can deal with any language-specific issues there. This forum is just JavaScript/HTML/CSS.

    For what it’s worth, I made a small change to scenario 8 of the Secondary Tiles sample, in both the JS and C# versions, to set a new arguments value for use with updateAsync. Both worked just fine. But it appears in both those samples that they’re creating a new SecondaryTile object with the same ID as the old one, assigning arguments, then calling updateAsync on that new object. You might try following that example ans see if you get different results.

    Monday, May 13, 2013 7:05 PM
  • YES! You are right! Thank you. I knew if we create a new SecondaryTile with the same TileId it will replace the old one, this is specified in the doc. But I never thought of instanciate a new SecondaryTile and update it. It even works with an uninitialized SecondaryTile if you don't want to replace the old values (it looks a little awful). So a simple fix would be (sorry it's in C# but I think it shouldn't be too hard to translate):

    public static async void FixedUpdateAsync(this SecondaryTile tile)
    {
    	await new SecondaryTile()
    	{
    		Arguments = tile.Arguments,
    		BackgroundColor = tile.BackgroundColor,
    		DisplayName = tile.DisplayName,
    		ForegroundText = tile.ForegroundText,
    		LockScreenBadgeLogo = tile.LockScreenBadgeLogo,
    		LockScreenDisplayBadgeAndTileText = tile.LockScreenDisplayBadgeAndTileText,
    		Logo = tile.Logo,
    		ShortName = tile.ShortName,
    		SmallLogo = tile.SmallLogo,
    		TileId = tile.TileId,
    		TileOptions = tile.TileOptions,
    		WideLogo = tile.WideLogo
    	}.UpdateAsync();
    }

    Yet, if it's the correct way to go (seriously!?), WinRT should at least throw a MustCreateANewObjectException instead. And if it's not, then we have a workaround but the bug still needs to be fixed.

    And I posted here because I wanted to reply to someone to tell him that there is in fact a bug here, not just a misuse of a WinRT method. Plus, this problem is not language specific, if the framework don't work, it won't work for anyone.

    EDIT: And I just realized this is what the original poster was saying. I didn't paid much attention to the code since I'm not good with JavaScript. (Google dropped me here if you are wondering what I'm doing in this forum.)
    • Edited by Kwanonn Monday, May 13, 2013 8:49 PM
    Monday, May 13, 2013 8:40 PM
  • Thanks. Sounds like we can either improve the API or improve the documentation. I'll take care of that internally here, but don't expect a report back as those sorts of things can take time depending on the stage of the product cycle.
    Tuesday, May 14, 2013 8:15 PM