次の方法で共有


Differential updates for UWP apps

One of the key benefits of building a UWP app are the savings users see when downloading updates. With Windows 10, updating UWP apps is optimized to ensure that only the minimal, required, changed bits of the app are downloaded - netting Windows 10 users tons of savings!

At a high level, during package creation, a piece of metadata is created and stored in the .appx or .appxbundle package which allows parts of the package to be uniquely identified by Windows. Later on, during update, Windows can use this metadata file to compare the old package to the new package and determine the things that need to be downloaded to the device.

But wait, there's more!

Given this metadata allows parts of the package to be uniquely identified, this means the differential update machinery fully functions from any version of a package to any other version of a package (assuming source package has a lower version than target package).

Long gone are the days of patch files that are crafted specifically from version x to version y of a package. With UWP app differential updates, you simply build the package and Windows takes care of the rest!

 

Interested in learning more? Read on!

It all starts at the AppxBlockMap.xml file (the aforementioned metadata). The AppxBlockMap.xml file is an XML document that contains a two dimensional list of information about files in the package. The first dimension lays out high level details on the file (e.g. name and size) and the second dimension provides SHA2-256 hash representations of each 64KB slice of that file (aka the "block").

Here's a sample of the AppxBlockMap.xml

 <!--?xml version="1.0" encoding="UTF-8"?-->
<blockmap hashmethod="https://www.w3.org/2001/04/xmlenc#sha256" 
          xmlns="https://schemas.microsoft.com/appx/2010/blockmap">
  <file lfhsize="66" size="101188" name="asset1.jpg">
    <block hash="2bidNE0JyaO+FjaTpRe0g8HzUCblUf/cfBcTXiZR74c="/>
    <block hash="+jeFwKrGk5gw9wSICWsWRtEQXwcLC7af4EWS7DgrAkY="/>
  </file>
  <file lfhsize="61" size="108823" name="asset2.jpg">
    <block hash="u0+5S0GOzwyAfYx54tKycZyHRBYm2ybvq27dkIKqDsQ="/>
    <block hash="F9h0FRMetL6BNCszAYB0bgyx2KWN+dO1bls4Q9m267c="/>
  </file>
  ...
</blockmap>

Looking at the first file (asset1.jpg) we'll see that the file has two block hashes, the first hash represents the first 64KB block of the file and the second hash represents the remaining 35KB - given the file is 101188 bytes.

During an update, if the second block of that file was modified, the hash would also be updated to reflect this fact. The download component understands this and will only pull down the second block and reuse the first unchanged block from the old package.

Up leveling this even further, if an entire file hasn't changed (which is determined by the full set of blocks not changing) then that file can be reused from the existing package - resulting in tremendous savings for Windows 10 users, especially for larger UWP apps!

 

Want to get this working with your UWP apps? There are a couple of tactics that you can employ to take advantage of this delta update technology.

  1. Keep files in the package small - doing this will ensure that if a change is needed that would impact the full file, the update would still be small.
  2. Modifications to files should be additive if possible - additive changes will ensure that end-user devices only download those changed blocks
  3. Modifications to files should be contained to 64KB blocks if possible - if your app does have large files and requires changes to the middle of a file, containing changes to a set of blocks will go a long way

 

With the amount of updates that happen so regularly, we're happy that we've enabled UWP app developers to build an experience that keeps users up to date with the latest and greatest without full app download every single time.

 

Any questions? leave them in the comments!

 

Thanks!

Jason Salameh, Senior Program Manager – Windows Developer Platform

Comments

  • Anonymous
    December 07, 2016
    Hi,Is windows store allow only delta update or we can update in some other way?.
    • Anonymous
      December 07, 2016
      I'm not quite sure I understand, could you help me clarify?. Are you asking if there is a way to turn off differential updates or are you asking if there are other supported update methods?
      • Anonymous
        December 07, 2016
        I want to know if there is any other supported update methods?
        • Anonymous
          December 08, 2016
          The way our update tech works, we only perform the update one way - using differential updates.
  • Anonymous
    December 07, 2016
    What happens to update if we did not add the metadata in AppxBlockMap.xml at the time of deployment?if i update the app,what are the files are downloaded by the user?
    • Anonymous
      December 07, 2016
      Actually you as the developer never author this file yourself. Rather, during package creation via MakeAppx.exe, the AppxBlockMap.xml file will be generated automatically and stored in the package.
      • Anonymous
        December 07, 2016
        Thanks jason, how can we verify this upgrade process by means of any log or other thing.?
        • Anonymous
          December 08, 2016
          Currently there's no way to do this. In the future we'll be adding a tool in the SDK that will allow you to validate the savings will happen on the device.
  • Anonymous
    December 19, 2017
    Hello, if I add a block 64kb to the middle of a file, are containing changes a set of blocks from the middle to the end this file? it happens on UWP app and windows 8.1 app?
    • Anonymous
      February 20, 2018
      It depends on the change. If you are doing an in place change such that the change is restricted to a block then only that block will change and hence be downloaded. However if the change spills over, then the changes will have a ripple effect to all the blocks to the end of the file. Yes this will happen on Windows 8.1 & Windows 10 app (UWP)