-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Controls Disappear When WebView is Used with Hardware Acceleration Disabled #28934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dc09bd9
d7d3c72
bdf5747
54166b5
be4093f
41cfc1a
3e38ad7
3d3c0f0
f3c1568
a4cfc33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 28798, "Controls Disappear When WebView is Used with Hardware Acceleration Disabled in Android", PlatformAffected.Android)] | ||
| public partial class Issue28798 : ContentPage | ||
| { | ||
| public Issue28798() | ||
| { | ||
| var grid = new Grid | ||
| { | ||
| HeightRequest = 500, | ||
| Background = Colors.Green, | ||
| WidthRequest = 300 | ||
| }; | ||
|
|
||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
|
|
||
| var label = new Label | ||
| { | ||
| Text = "Test", | ||
| Background = Colors.Red, | ||
| AutomationId = "TestLabel" | ||
| }; | ||
| Grid.SetRow(label, 0); | ||
| grid.Children.Add(label); | ||
|
|
||
| var button = new Button | ||
| { | ||
| Text = "button", | ||
| Background = Colors.Blue | ||
| }; | ||
| Grid.SetRow(button, 1); | ||
| grid.Children.Add(button); | ||
|
|
||
| var webView = new WebView | ||
| { | ||
| Source = "https://example.com/", | ||
| BackgroundColor = Colors.Transparent, | ||
| HeightRequest = 300, | ||
| WidthRequest = 300 | ||
| }; | ||
| Grid.SetRow(webView, 2); | ||
| grid.Children.Add(webView); | ||
|
|
||
| Content = grid; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #if ANDROID | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| internal class Issue28798 : _IssuesUITest | ||
| { | ||
| public Issue28798(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "Controls Disappear When WebView is Used with Hardware Acceleration Disabled in Android"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.WebView)] | ||
| public void ControlsShouldRemainVisibleWithWebViewWhenHardwareAccelerationIsDisabled() | ||
mattleibow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| App.WaitForElement("TestLabel"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,11 @@ protected override AWebView CreatePlatformView() | |
| platformView.Settings.DomStorageEnabled = true; | ||
| platformView.Settings.SetSupportMultipleWindows(true); | ||
|
|
||
| if (OperatingSystem.IsAndroidVersionAtLeast(23) && Context?.ApplicationInfo?.Flags.HasFlag(Android.Content.PM.ApplicationInfoFlags.HardwareAccelerated) == false) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The activities can have different hardware acceleration settings that override the app-level setting, but in out case, I think checking at app level is enough. |
||
| { | ||
| platformView.SetLayerType(Android.Views.LayerType.Software, null); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Optional) Could be nice to log this: |
||
|
|
||
| return platformView; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.