Repository navigation
Closed
Description
Steps to Reproduce
- Make a
DispatchQueuewithDispatchQualityOfService.Backgroundas an attribute, like so -
var qos = new DispatchQueue.Attributes {
QualityOfService = DispatchQualityOfService.Background
};
thumbnailQueue = new DispatchQueue("ThumbnailQueue", qos);
- A
UITraitCollectionlike -thumbnailTraitCollection = new UITraitCollection(); - Call -
thumbnailQueue.DispatchAsync(() => {
Console.WriteLine($"first -------- {Thread.CurrentThread.ManagedThreadId}");
traitCollection.PerformAsCurrentTraitCollection(() => {
Console.WriteLine("second --------");
DispatchQueue.MainQueue.DispatchAsync(() => {
Console.WriteLine("third --------");
});
});
});
Expected Behavior
According to the docs , this method can be called from any thread in the app. So we expect all the print statements to be executed.
Actual Behavior
However, we get an error after the first print statement. The thread can be seen to be a non-main thread (thread id > 0), after which we get the following error -
2019-08-28 09:57:34.646206-0400 PencilKitDraw[22664:67993222] first -------- 5
=================================================================
Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Basic Fault Adddress Reporting
=================================================================
Memory around native instruction pointer (0x108a0c984):0x108a0c974 47 20 5d c3 0f 1f 84 00 00 00 00 00 55 48 89 e5 G ].........UH..
0x108a0c984 8b 47 20 a9 00 00 00 02 75 0c a9 00 00 00 10 75 .G .....u......u
0x108a0c994 26 48 8b 07 5d c3 48 8d 3d 04 74 1b 00 48 8d 35 &H..].H.=.t..H.5
0x108a0c9a4 81 6f 1b 00 48 8d 0d f5 6f 1b 00 ba 77 03 00 00 .o..H...o...w...
=================================================================
Native stacktrace:
=================================================================
0x1089251dd - /Users/pramit/Library/Developer/CoreSimulator/Devices/4C03B40A-DEC7-4300-A35E-5D25F6FEF9E4/data/Containers/Bundle/Application/526A4320-8465-43A4-8B52-EC3A991EAD0D/PencilKitDraw.app/PencilKitDraw : mono_dump_native_crash_info
0x108919845 - /Users/pramit/Library/Developer/CoreSimulator/Devices/4C03B40A-DEC7-4300-A35E-5D25F6FEF9E4/data/Containers/Bundle/Application/526A4320-8465-43A4-8B52-EC3A991EAD0D/PencilKitDraw.app/PencilKitDraw : mono_handle_native_crash
0x10892b938 - /Users/pramit/Library/Developer/CoreSimulator/Devices/4C03B40A-DEC7-4300-A35E-5D25F6FEF9E4/data/Containers/Bundle/Application/526A4320-8465-43A4-8B52-EC3A991EAD0D/PencilKitDraw.app/PencilKitDraw : mono_sigsegv_signal_handler_debug
0x7fff511bab5d - /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_platform.dylib : _sigtramp
0x600003f122c0 - Unknown
0x1089188fe - /Users/pramit/Library/Developer/CoreSimulator/Devices/4C03B40A-DEC7-4300-A35E-5D25F6FEF9E4/data/Containers/Bundle/Application/526A4320-8465-43A4-8B52-EC3A991EAD0D/PencilKitDraw.app/PencilKitDraw : mono_handle_exception_internal
0x1089179d9 - /Users/pramit/Library/Developer/CoreSimulator/Devices/4C03B40A-DEC7-4300-A35E-5D25F6FEF9E4/data/Containers/Bundle/Application/526A4320-8465-43A4-8B52-EC3A991EAD0D/PencilKitDraw.app/PencilKitDraw : mono_handle_exception
0x10889cf0f - /Users/pramit/Library/Developer/CoreSimulator/Devices/4C03B40A-DEC7-4300-A35E-5D25F6FEF9E4/data/Containers/Bundle/Application/526A4320-8465-43A4-8B52-EC3A991EAD0D/PencilKitDraw.app/PencilKitDraw : mono_amd64_throw_exception
0x10af4d5b0 - Unknown
0x10e69f7cb - Unknown
0x7fff50fa8566 - /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_lane_serial_drain
0x7fff50fa8f9c - /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_lane_invoke
0x7fff50fb306c - /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib : _dispatch_workloop_worker_thread
0x7fff511c2611 - /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
0x7fff511c23fd - /Applications/Xcode11-beta6.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_pthread.dylib : start_wqthread
=================================================================
Managed Stacktrace:
=================================================================
=================================================================
This was found while trying to port a sample from swift to C#. The swift code is -
thumbnailQueue.async {
traitCollection.performAsCurrent {
let image = drawing.image(from: thumbnailRect, scale: thumbnailScale)
DispatchQueue.main.async {
self.updateThumbnail(image, at: index)
}
}
}
Here it seems to work, but not in C#
Environment
=== Visual Studio Enterprise 2019 for Mac ===
Version 8.2.4 (build 45)
Installation UUID: 612da519-82b8-4c9f-8264-532cb9056204
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.14.0.85 (d16-2-fix-mac-updates / 86973979)
Package version: 600000327
=== Mono Framework MDK ===
Runtime:
Mono 6.0.0.327 (2019-02/f8ea05bddcb) (64-bit)
Package version: 600000327
=== NuGet ===
Version: 5.1.0.6013
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.12
2.1.11
SDK: /usr/local/share/dotnet/sdk/2.1.701/Sdks
SDK Versions:
2.1.701
2.1.700
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/Current/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.11
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Xamarin Designer ===
Version: 16.2.0.414
Hash: a1c119d5f
Branch: remotes/origin/d16-2-xcode11
Build date: 2019-08-20 22:38:28 UTC
=== Apple Developer Tools ===
Xcode 11.0 (14921.5)
Build 11M392q
=== Xamarin.Mac ===
Version: 5.99.3.5 (Visual Studio Enterprise)
Hash: dd394471
Branch: xcode11
Build date: 2019-08-21 07:29:09-0400
=== Xamarin.iOS ===
Version: 12.99.3.5 (Visual Studio Enterprise)
Hash: dd394471
Branch: xcode11
Build date: 2019-08-21 07:29:08-0400
=== Xamarin.Android ===
Version: 9.5.0.27 (Visual Studio Enterprise)
Commit: xamarin-android/d16-3/16c4494
Android SDK: /Users/pramit/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
None installed
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.2
SDK Build Tools Version: 28.0.3
Build Information:
Mono: mono/mono/2019-02@e6f5369c2d2
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333
=== Microsoft Mobile OpenJDK ===
Java SDK: /Users/pramit/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android Device Manager ===
Version: 1.2.0.60
Hash: 686c817
Branch: remotes/origin/d16-2
Build date: 2019-08-20 15:19:18 UTC
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 802040045
Git revision: 7da3e8d5e4b3bf8f0d4cf83f92d60c82094502b2
Build date: 2019-08-21 17:33:58+00
Build branch: release-8.2-xcode11
Xamarin extensions: 12c306582cf9fe4ef451e9b27422c416d11c6491
=== Operating System ===
Mac OS X 10.14.6
Darwin 18.7.0 Darwin Kernel Version 18.7.0
Thu Jun 20 18:42:21 PDT 2019
root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
Build Logs
https://gist.github.com/prmallic/394066cdc51d3724175bb87ae76cc170
Activity
spouliot commentedon Aug 28, 2019
I suspect it crash because we throw an exception into that queue and it seems likely (that we throw) as there’s no
[ThreadSafe]attribute on this API[UIKit] Fix threading issue in the selector performAsCurrentTraitColl…
[UIKit] Fix threading issue in the selector performAsCurrentTraitColl…
rolfbjarne commentedon Sep 3, 2019
This was fixed with fb225bb.