【发布时间】:2019-05-03 08:44:23
【问题描述】:
目前我正在开发一个使用 auf UNO 平台的移动应用程序。为了显示 3D 模型,我使用了 WebView 控件和一些 ThreeJS JavaScript 代码。这适用于 UWP 和 WASM。 (WASM 构建中 WebView 的解决方法也可以在 StackOverflow 上找到 here。) 然而,Android 版本让我头疼:HTML 页面加载,调试输出显示 WebGL 脚本部分正在执行,但用户界面没有显示任何内容。
我已经确定(在我看来)使用了正确的 WebView 控件。此外,我使用从“Play Store”(版本 74.x.x.x)下载的“Chrome”中的替代 WebView 进行了测试。 WebView 的 HTTP 用户代理是正确的,所以 WebView 是根据 Android 系统的开发者设置使用的。 Activity 和 AndroidManifest 文件中的硬件加速都设置为“TRUE”。
我还使用开箱即用的“Android-XAML-App”进行了非常简单的测试。立方体几乎立即显示出来。
MainView.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:WebViewTestAndroid"
x:Class="WebViewTestAndroid.MainPage">
<Grid>
<WebView Source="https://threejs.org/examples/?q=cube#webgl_geometry_cube" />
</Grid>
</ContentPage>
这是 UNO 主页无法正常工作的示例。页面正在加载,但未显示 3D 立方体。
MainPage.xaml
<Page
x:Class="UnoWebViewTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoWebViewTest"
xmlns:ios="http://uno.ui/ios"
xmlns:android="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:wasm="http://uno.ui/wasm"
mc:Ignorable="d ios android xamarin wasm"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<android:WebView Source="https://threejs.org/examples/?q=cube#webgl_geometry_cube" />
</Grid>
</Page>
我比较了清单文件,但到目前为止我还没有得出可以进一步调查的结论。 我希望 UNO 使用的是原生 Android WebView 控件,但可能缺少某些设置或者它甚至不是同一个控件?
【问题讨论】:
-
Uno repo 中 WebGL 内容未显示的问题:github.com/nventive/Uno/issues/851
标签: c# android xamarin android-webview uno-platform