Windows Phone 8: Evolution of the Runtime and Application Compatibility

从Windows Phone 7到Windows Phone 8,系统经历了重大变革,包括从Windows Compact Embedded核心转向与桌面Windows 8共享核心,以及从.NET Compact Framework升级到CoreCLR,为开发者提供了更快的运行时和更多的功能。

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 diagram, we can think of the entire WP7 application system as followsimage

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

Essentially 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 by .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 managed the application including the host.

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

image

Everything in Green in this diagram got 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 things like kernel, networking, driver framework and others. The shared core obviously brings great value as innovations and features will more easily flow across 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 to 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 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 could 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 various automated 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 for 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 should 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 things like timing differences. Even though these runtime behaviors are not documented, or in some cases especially called out that user code should 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 calls out that finalization order in .NET is not deterministic, code still took subtle dependency on them. In one particular 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 the 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 scheduler 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. Obviously all applications in the store and all of their features were not tested. So you should 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 testing Need For Speed and I need to test till level 10 :)

转载于:https://www.cnblogs.com/ConfuciusPei/archive/2013/01/29/5118421.html

<think> 首先,用户的问题是:解决 'ERROR: files are incompatible: Runtime info and framework compatibility matrix are incompatible: No compatible kernel requirement found (kernel FCM version = 8)' 错误的方法。错误消息中提到了 "kernel FCM version = 8"。 从系统级指令,我需要: - 使用中文回答。 - 结构清晰,逐步解决问题。 - 确保回答真实可靠。 - 引用末尾添加引用标识。 - 生成相关问题。 - 所有数学表达式使用正确的LaTeX格式(但这里可能不涉及太多数学)。 用户提供了几个引用: - 引用[1]:描述了裁剪kernel时注释掉CONFIG_HID_SONY导致编译错误,错误是关于Runtime info和framework compatibility matrix不兼容,kernel FCM version = 6。 - 引用[2]:提到framework和vendor接口不匹配,错误是关于设备manifest和framework兼容性矩阵不一致。 - 引用[3]:添加NFS Kernel宏控时,整编Android时报错,要求CONFIG_NFS_FS设置为n但实际是y。 - 引用[4]:kernel需要支持IO命令操作,添加了CONFIG_DEVMEM等导致问题。 用户当前的错误是 "kernel FCM version = 8",这表明问题类似,但版本更高(FCM version 8)。FCM可能指的是Framework Compatibility Matrix。 关键点: - 错误的核心是内核配置与框架兼容性矩阵不匹配。 - 具体地说,运行时信息(runtime info)和框架兼容性矩阵(framework compatibility matrix)在kernel需求上不一致。 - 错误消息提示 "No compatible kernel requirement found",意思是找到一个兼容的内核要求。 在引用中,我们看到类似的错误: - 引用[1]:缺少CONFIG_HID_SONY。 - 引用[3]:CONFIG_NFS_FS应为n但却是y。 所以,解决方法是检查和调整内核配置以匹配框架兼容性矩阵的要求。 步骤总结: 1. **识别缺失或错误的配置**:错误消息通常会指定哪个配置缺失或有误。例如,在错误中可能会像引用[1]那样明确指出 "Missing config CONFIG_HID_SONY"。 2. **查阅框架兼容性矩阵**:框架兼容性矩阵定义了哪些内核配置是必需的或禁止的。 3. **修改内核配置**:在kernel的.config文件中添加、删除或修改配置项。 4. **重建和验证**:重新编译并检查错误是否修复。 在用户提供的错误中,"kernel FCM version = 8" 可能表示当前内核的FCM版本是8,但框架期望不同的版本或有特定要求。 具体到用户错误: - ERROR: files are incompatible: Runtime info and framework compatibility matrix are incompatible: No compatible kernel requirement found (kernel FCM version = 8) - 这表明运行时信息报告的内核FCM版本是8,但框架兼容性矩阵中找不到兼容的要求。 在Android构建系统中,VINTF (Vendor Interface) 检查确保供应商实现(vendor)和框架(framework)之间的兼容性。这包括内核配置。 常见原因和解决方法: - **原因1**:内核配置缺失或错误。框架兼容性矩阵要求特定配置必须设置(y或n),但实际配置不同。 - **解决方法**:检查错误日志以获取具体缺失的配置名。然后,在kernel配置中添加或修改该配置。 - **原因2**:FCM版本不匹配。框架兼容性矩阵可能有基于版本的特定要求。 - **解决方法**:确保内核配置符合目标FCM版本的要求。可能需要更新内核配置以匹配框架的期望。 - **原因3**:兼容性矩阵文件错误或过时。 - **解决方法**:检查设备特定的兼容性矩阵文件(如DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE)并确保它们正确引用内核配置。 从引用[2]中,有建议: - 更新过时的HAL到最新版本。 - 检查设备manifest或FCM文件中的拼写错误。 - 对于新平台HAL,添加到FCM文件中。 - 对于设备特定HAL,添加到DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE或DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE。 对于用户错误:"No compatible kernel requirement found (kernel FCM version = 8)",这可能意味着框架兼容性矩阵中没有定义针对FCM版本8的内核要求。或者,运行时信息报告的内核配置与矩阵中的要求不匹配。 可能的步骤: 1. **检查完整错误日志**:错误消息可能包含更多细节,如具体缺失的配置项。类似引用[1]中的 "Missing config CONFIG_HID_SONY"。 2. **确认FCM版本**:确保内核配置的目标FCM版本与框架期望一致。Android系统可能有不同的兼容性级别。 3. **更新兼容性矩阵**:如果需要,更新设备特定的兼容性矩阵文件以包括内核要求。 4. **调整内核配置**:基于框架要求修改内核.config文件。 在回答中,我应该: - 结构清晰:分步解释。 - 参考提供的引用:在末尾添加引用标识如 [^1]。 - 生成相关问题:在最后添加相关问题列表。 - 使用中文。 回答结构: 1. **理解错误**:解释错误含义。 2. **常见原因**:列出可能原因。 3. **解决步骤**:提供详细的解决步骤。 4. **附加建议**:基于引用给出建议。 5. **相关问题**:生成相关问题。 相关问题生成: - 基于错误主题,如: 1. 如何调试Android构建中的VINTF兼容性错误? 2. 什么是框架兼容性矩阵(FCM)? 3. 如何更新内核配置以满足特定FCM版本要求? 4. 常见的kernel配置错误有哪些? 5. 如何优化Android构建过程以避免此类错误? 确保回答真实可靠:基于Android开发知识。错误类似于VINTF验证失败。 最终回答大纲: - 开头:简述错误。 - 原因分析。 - 解决步骤。 - 结尾:引用和问题。 </think> ### 解决 'ERROR: files are incompatible: Runtime info and framework compatibility matrix are incompatible: No compatible kernel requirement found (kernel FCM version = 8)' 错误的方法 您在Android构建过程中遇到的错误表明运行时信息(runtime info)和框架兼容性矩阵(framework compatibility matrix)在kernel需求上不兼容,具体表现为内核的FCM(Framework Compatibility Matrix)版本号为8,但框架找不到兼容的内核要求。这通常发生在裁剪或修改内核配置(如Kconfig选项)后,导致内核设置与Android框架的兼容性规范不一致。以下是基于引用信息和Android开发最佳实践的详细解决方法,帮助您逐步修复问题。 #### 错误原因分析 - **核心问题**:内核配置(如`.config`文件中的宏控选项)与框架兼容性矩阵的要求不匹配。框架兼容性矩阵定义了特定FCM版本(这里是8)下必须启用或禁用的内核配置项(如 `CONFIG_XXX=y` 或 `CONFIG_XXX=n`)。如果实际内核配置不符合这些要求,VINTF(Vendor Interface)检查会失败,引发此错误。 - 例如,引用[1]中注释 `CONFIG_HID_SONY` 导致缺失配置错误,引用[3]中 `CONFIG_NFS_FS` 值应为 `n` 但实际为 `y`,都会触发类似兼容性问题[^1][^3]。 - **关键因素**: - **FCM版本不匹配**:内核报告的FCM版本为8,但设备框架或兼容性矩阵文件可能未正确定义该版本的kernel requirements。 - **配置项缺失或值错误**:错误日志通常包含具体缺失或值错误的配置项(如 "Missing config CONFIG_XXX" 或 "required n but found y")。 - **兼容性矩阵文件错误**:设备特定的兼容性矩阵文件(如 `DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE`)可能过时或未包含必要的内核要求[^2]。 #### 逐步解决方法 按照以下步骤操作,确保操作基于完整错误日志(检查 `ninja` 输出或构建日志文件): 1. **检查完整错误日志,确认缺失或错误的配置项** - 构建日志中通常会指定具体是哪个内核配置导致问题。查找类似以下格式的行: ```log For kernel requirements at matrix level 8, Missing config CONFIG_XXX ``` 或 ```log For config CONFIG_XXX, value = y but required n ``` - 如果错误未明确提示,运行 `make` 或 `m` 命令时使用 `-j1` 参数(如 `make -j1 droid`)以获取更详细的输出。 - **操作示例**:假如日志显示 "Missing config CONFIG_EXAMPLE",则问题配置是 `CONFIG_EXAMPLE`。 2. **修改内核配置以满足框架要求** - 打开内核配置文件(通常位于 `kernel/arch/<架构>/configs/<设备>.config` 或 `kernel/configs/android-<版本>.config`)。 - 添加或修改配置项: - 如果错误要求 **启用** 配置(如 "required y"),添加 `CONFIG_XXX=y`。 - 如果要求 **禁用** 配置(如 "required n"),添加 `# CONFIG_XXX is not set`。 - 确保配置项的值与FCM版本8的要求一致。 - **示例操作**: - 基于引用[4],如果添加了 `CONFIG_DEVMEM` 导致问题,您可能需要调整值(如从 `y` 改为 `n`)或添加缺失项[^4]。 - 例如,针对 FCM 版本 8,添加: ```config CONFIG_REQUIRED_OPTION=y # 启用必需项 # CONFIG_FORBIDDEN_OPTION is not set # 禁用禁止项 ``` 3. **更新兼容性矩阵文件** - 如果修改内核配置无效,检查设备特定的兼容性矩阵文件: - 文件路径通常在设备 makefile 中定义,如 `DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE`。 - 添加缺失的内核要求到矩阵文件中: ```xml <compatibility-matrix version="8.0"> <kernel> <config> <key>CONFIG_REQUIRED_OPTION</key> <value type="tristate">y</value> </config> </kernel> </compatibility-matrix> ``` - 参考引用[2]的建议,更新过时的HAL或修复拼写错误,如果矩阵文件未正确定义FCM版本8的内核要求,手动添加[^2]。 4. **验证并重建** - 清理构建缓存:运行 `make clean` 或 `m clean`。 - 重新生成配置:使用 `make menuconfig`(在内核目录)或设备特定的配置工具。 - 重新编译:启动完整构建(如 `m` 或 `make droid`)。 - 验证修复:检查构建日志是否包含兼容性错误。如果错误依旧,重复步骤1-3以确认所有要求已满足。 #### 附加建议 - **预防措施**: - 在裁剪内核前,查阅Android兼容性定义文档(CDD)或设备框架文档,了解FCM版本8的具体要求。 - 使用工具如 `checkvintf` 主动验证兼容性:运行 `checkvintf --dump` 分析运行时信息和矩阵文件。 - 参考引用[3]的案例,确保新添加的内核宏控(如NFS支持)与框架兼容矩阵一致[^3]。 - **常见陷阱**: - 如果内核FCM版本自动升级(如从6到8),但兼容性矩阵未更新,会导致此错误。确保设备树和内核版本同步[^1][^2]。 - 对于设备特定HAL,引用[2]建议添加到 `DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE` 以避免框架不匹配[^2]。 通过以上步骤,您应该能修复兼容性错误。如果问题持续,请提供完整错误日志片段以便进一步分析。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值