Windows Phone 8: Evolution of the runtime and application compatibility

Source: Internet
Author: User

Long time back at the wake of the release of Windows Phone 7 (WP7) I posted about the windows
Phone 7 series programming model. I also published how. NET Compact
Framework powered the applications on wp7.

Further Simplifying the block digoal, we can think of the entire WP7 application system as follows

As with most block diagrams, this is gross simplifications. However, I hope it helps to easily picture the entire system.

The application can be purely managed (written in say C # Or VB.net ). the application can only utilize services exposed by the developer platform and core services provided. NET Compact framework. the application can in no way directly use native
Code or talk to the OS (say call an Win32 API). It has to always go through the runtime infrastructure and is in a security sandbox.

The application manager is the loose term I am using to encompass everything that is used to manage the application including the host.

Windows Phone 8 (WP8) is a huge change from Windows Phone 7.x (WP7). From Perspective of a WP7 application running on a WP8 Device  the system looks as follows


Everything in green in this distrigot outright replaced with entire new codebase and the rest of the system other than the application was heavily modified to work with the new OS and the new managed runtime.

Shared windows Core

The OS moved away from windows compact embedded (wince) OS core that was used in WP7 to a new OS which shares it's core with the desktop Windows 8. this means that a bunch of things in the WP8 OS is shared with the desktop implementation, this includes des things
Like kernel, networking, driver framework and others. the shared core obviusly brings great value as innovations and features will more easily flow into ss the two form factors (device and desktop) and also reduce engineering redundancy on Microsoft side.
Some of the benefits are readily visible today like great multi-core support, winrt InterOP and others are more subtle.

Coreclr

. NET Compact framework (netcf) that was used in WP7 has a very different design philosophy and hence a completely different implementation from the desktop. net. I will have a follow up post on this but for now it suffices to note that. netcf is a very portable
Runtime that is designed to be very versatile and cross platform. desktop CLR on the other hand is more closely tied with windows and the processor architecture. it closely works with the OS and the underlying HW to give the maximum performance benefit
Managed code running on it.

With the new Windows RT which works on arm, desktop CLR was anyway updated to work on the ARM processor. So when the phone chose
To move to shared core it was an obvious choice to move the CLR as well. This gave the same benefits of shared innovation and reduced engineering redundancy.

The full desktop CLR is more heavy and provides functionality that is not really required by the phone scenarios and hence a lighter variant of it (which is built from the same source) called coreclr was chosen for WP8. coreclr is the evolution of the lightweight
Runtime that powered Silverlight. With the move to coreclr developers get a much faster runtime with extended feature set that includes des InterOP via winrt.

Backward compat

One of the simple statements made during all of these WP8 launch presentations was that applications in the store built for WP7 will work as is for WP8. this is a small statement but is a huge achievement and effort from the runtime implementation perspective.
Making apps work as is when the entire runtime, OS and chipset has changed is non-trivial to say the least. Our team worked very hard to make this possible.

One of the biggest things that played out to our benefit was that the WP7 apps were fully sandboxed and couldn't use any native code. this means that they didn't have any means of taking behavioral dependence on the OS APIs or underlying HW. the OS apis were
Used via the CLR and it cocould always add quirks to expose consistent behavior to the applications.

API compatibility
This required us to ensure that coreclr exposes the same API set as netcf. we ran varous automatic tools to manage the API surface area changes and retain meaningful API compat between WP7 and WP8. with a closed application store it was possible
Us To gather complete metrics on API usage and correctly prioritize engineering resources to ensure that majority of Applications continued to see the same API set in signature and semantics.

We also needed to ensure that the same APIs behave as closely as possible with that provided by netcf. we tested a lot of applications in the app store to get as close as we can and believe that we are at a place that shoshould allow most WP7 application's API
Usage to transparently fall over to the new runtime.

Runtime behavior changes
When a runtime changes there are behavioral changes that can expose pre-existing issues with applications. this includes des things like timing differences. even though these runtime behaviors are not supported ented, or in some cases especially called out
That user code shoshould not take dependence on them, some apps still did do that.

Couple of the examples we saw

  1. Taking dependence on finalization order
    Even though CLI specification clearly callout that finalization order in. net is not deterministic, code still took subtle dependency on them. in one particle case object F1 used a file and it's finalizer released it. later another object F2 opens the same
    File. with change in the runtime, the timing of GC changed so that at the time F2 tried to open the file, F1 which has been already collected hasn't yet had its finalizer run. hence the application crashed. we got in touch with the app developer and got
    Code moved to use the right dispose Pattern
  2. GC timing and changes in number of generations
    Application finalizers contrary to. Net guidelines modified other managed objects. Now changed GC timings and generation resulted in those objects to have already been collected and hence resulted in finalizer crashes
  3. Threading issues
    This was one of the painful ones. with the change in OS and hence thread schedtion and addition of multiple cores in the ARM CPU, a lot of subtle races and deadlocks in the applications got exposed. these were pre-existing issues where synchronization primitives
    Were not used correctly or some code relied on the Quanta based thread scheduling wince did. with move to WP8, threads run in parallel on different cores and scheduled in different order, this lead to various deadlocks and race driven crashes. again we had
    To get in touch With app developer to address these issues
  4. There were other cases where exact precision of floating point math was relied on. This resulted in a board game where pucks flew off from its surface
  5. Whether or not functions got inlined
  6. Order of static constructor initialization (especially in conjunction with function in-lining)

We addressed some of these issues where it was realistic to fix them in the runtime. for some of the others we got in touch with the application developers. obviusly all applications in the store and all of their features were not tested. so you shoshould try
To test your applications when you have access to WP8.

At one point we were all playing games on our phones telling our managers that I am compat TestingNeed for speedAnd I need to test till level 10

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.