This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
This repository was archived by the owner on May 1, 2024. It is now read-only.
[Bug] [iOS] ActivityIndicator rendering broken on iOS 11 #14119
Copy link
Copy link
Closed
Labels
Description
Description
- Activity indicator rendering is broken with Xamarin.Forms 5.0 on iOS 11 devices.
- iOS 10 or lower may also be affected, which I did not check.
- Rendering works as expected on iOS 12+.
Steps to Reproduce
Run the following app on iOS 11 device or simulator:
public class App : Application
{
public App()
{
MainPage = new ContentPage
{
Content = new StackLayout
{
Orientation = StackOrientation.Vertical,
Children = {
new BoxView {
VerticalOptions = LayoutOptions.FillAndExpand,
},
new ActivityIndicator {
HorizontalOptions = LayoutOptions.Center,
IsRunning = true,
},
new BoxView {
VerticalOptions = LayoutOptions.FillAndExpand,
}
}
}
};
}
}
Expected Behavior
Activity indicator is rendered as usual (background is visible behind the activity indicator).
Actual Behavior
Area covered by the indicator is black.
Basic Information
- Version with issue: 5.0.0.2012 (and probably most/all 5.0 versions)
- Last known good version: 4.8.0.1821
Environment
Show/Hide Visual Studio info
=== Visual Studio Community 2019 for Mac ===
Version 8.8 (build 2913)
Installation UUID: 4a873394-294a-4e0e-928f-e087cba2fb74
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)
Package version: 612000093
=== Mono Framework MDK ===
Runtime:
Mono 6.12.0.93 (2020-02/620cf538206) (64-bit)
Package version: 612000093
=== Xamarin Designer ===
Version: 16.8.0.495
Hash: 1a7425b8f
Branch: remotes/origin/d16-8
Build date: 2020-10-20 10:51:14 UTC
=== Roslyn (Language Service) ===
3.8.0-5.20515.7+713efb0e68d34ab75faaf709e071e5c2d8d4ed0e
=== NuGet ===
Version: 5.8.0.6860
=== .NET Core SDK ===
SDK: /usr/local/share/dotnet/sdk/5.0.100/Sdks
SDK Versions:
5.0.100
3.1.102
3.0.101
2.1.505
2.1.504
2.1.302
2.1.4
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks
=== .NET Core Runtime ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
5.0.0
3.1.2
3.0.1
2.1.23
2.1.15
2.1.14
2.1.9
2.1.8
2.1.2
2.0.5
=== .NET Core 3.1 SDK ===
SDK: 3.1.102
=== Xamarin.Profiler ===
'/Applications/Xamarin Profiler.app' not found
=== Updater ===
Version: 11
=== Apple Developer Tools ===
Xcode 12.3 (17715)
Build 12C33
=== Xamarin.Mac ===
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.
=== Xamarin.Android ===
Version: 11.1.0.17 (Visual Studio Community)
Commit: xamarin-android/d16-8/c0e2b8e
Android SDK: /Users/work/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
7.1 (API level 25)
8.0 (API level 26)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.6
SDK Build Tools Version: 29.0.3
Build Information:
Mono: be2226b
Java.Interop: xamarin/java.interop/d16-8@79d9533
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc
=== Microsoft OpenJDK for Mobile ===
Java SDK: /Users/work/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android SDK Manager ===
Version: 16.8.0.32
Hash: 01a7774
Branch: remotes/origin/d16-8
Build date: 2020-10-13 23:32:30 UTC
=== Android Device Manager ===
Version: 16.8.0.45
Hash: fc0af5f
Branch: remotes/origin/d16-8
Build date: 2020-10-13 23:32:54 UTC
=== Xamarin.iOS ===
Version: 14.4.1.3 (Visual Studio Community)
Hash: e30c41de3
Branch: d16-8
Build date: 2020-10-20 22:18:50-0400
=== Build Information ===
Release ID: 808002913
Git revision: c6189b3851aed1e1aadbef5807d54bd5bb505e5e
Build date: 2020-11-05 07:07:20-05
Build branch: release-8.8
Xamarin extensions: c6189b3851aed1e1aadbef5807d54bd5bb505e5e
=== Operating System ===
Mac OS X 10.15.7
Darwin 19.6.0 Darwin Kernel Version 19.6.0
Tue Jan 12 22:13:05 PST 2021
root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64
Screenshots
Xamarin.Forms 5.0.0.2012, iOS 11.4 simulator:
Xamarin.Forms 4.8.0.1821, iOS 11.4 simulator:
Reproduction Link
ActivityIndicatorWorking4.8.zip
ActivityIndicatorBroken5.0.zip
Workaround
-
I suspect this is caused by the following change: [iOS] ActivityIndicator starting animation only when attached to superview #11339
-
A possible workaround is using a custom renderer which reverts part of this change. This also reverts the bugfix, so it is only usable if the bugfix is not needed.
-
Adjust the version check if you need to support iOS versions lower than 11.
public class ActivityIndicatorRenderer : Xamarin.Forms.Platform.iOS.ActivityIndicatorRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
{
bool isIos11 = UIDevice.CurrentDevice.CheckSystemVersion(11, 0) && !UIDevice.CurrentDevice.CheckSystemVersion(12, 0);
if (e.NewElement != null && Control == null && isIos11)
SetNativeControl(new UIActivityIndicatorView(RectangleF.Empty) { ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray });
base.OnElementChanged(e);
}
}
gheorghedarle and greg84