There is a deadlock between the framework lock and the GC lock; resolve this
by making sure we don't execute managed code while holding the framework lock.
The framework lock was introduced in
xamarin/maccore@4a0748b1d8, and from analyzing
that commit message, it seems we're safe as long as nobody retains/releases
NSObjects (in way that makes the retainCount jump to or from 1) while the GC
runs.
Calling `xamarin_unregister_nsobject` does not affect the retain count of the
object; thus it's not necessary to keep the lock during the call to
`xamarin_unregister_nsobject`.
https://bugzilla.xamarin.com/show_bug.cgi?id=599944a0748b1d8
When we fail to create an InputAudioQueue, we need to free the local GCHandle
we previously created, not the instance GCHandle where we'd put the local
GCHandle in case of success.
This fixes bug #59911 to throw the correct (invalid parameter) exception (and
not leak the local GCHandle either).
https://bugzilla.xamarin.com/show_bug.cgi?id=59911
The media library permission API (to either query the permission status or ask
for permission) was introduced in iOS 9.3, so we need to make sure to not call
it on earlier iOS versions.
If running on older iOS versions, then just don't do anything (unless we're
asked to ignore tests that put up permission dialogs, in which case ignore the
test, since that's the safe approach).
https://bugzilla.xamarin.com/show_bug.cgi?id=59995
commit spouliot/Touch.Unit@b5b227e80b
Author: Rolf Bjarne Kvinge <rolf@xamarin.com>
Date: Wed Oct 4 11:45:32 2017 +0200
[TouchRunner] Improve logging output.
When asked to write logs to a TCP host:port, and given multiple hostnames, we
try to connect to all of them to see which hostname works.
This logic does not necessarily work when asked to write to a http host:port
(it would have to be implemented), which means that when given multiple
hostnames, we'd enter a special case, not connecting to anything, and soon
throwing a NullReferenceException.
So refactor the logic slightly: we now only try to select the hostname when
asked to write to a TCP host:port; when asked to write to a HTTP host:port we
just select the first hostname (which is still better than throwing a NRE).
We also don't unnecessarily try to resolve hostnames when asked to write logs
to a file, and make absolutely sure there's no way to not have a log to write
to by writing to Console.Out if we can't do anything else.
In 1690ccbc99 (when merging the Xcode 9 branch
into master), llvm was accidentally debumped from
mono/llvm@6aa74ae572 to
mono/llvm@975e3a6903.
So rebump (and one commit further, to match what we're using in the d15-4
branch).
* [tests][mtouch] Add support for reading binary plists.
Some plists in Xcode 9 are now binary plists (instead of just plain xml files
like they were in previous versions of Xcode). This causes trouble for some of
our tests, so make sure we handle binary plists as well.
Fixes these failures:
1. Xamarin.MTouch.MT0091(tvOS,"tvOS") : System.Xml.XmlException : Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.Throw (System.String res) [0x00000] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () [0x0012c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x002d4] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlLoader.Load (System.Xml.XmlDocument doc, System.Xml.XmlReader reader, System.Boolean preserveWhitespace) [0x000a6] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) [0x0002e] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at Xamarin.Tests.Configuration.GetPListStringValue (System.String plist, System.String key) [0x00028] in <44c95c7e3d1e488ab633a77d9a794653>:0
at Xamarin.MTouch.MT0091 (Xamarin.Profile profile, System.String name) [0x000ae] in <44c95c7e3d1e488ab633a77d9a794653>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <400071ddcfe64ed8a3531490bb763536>:0
2. Xamarin.MTouch.MT0091(iOS,"iOS") : System.Xml.XmlException : Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.Throw (System.String res) [0x00000] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () [0x0012c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x002d4] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlLoader.Load (System.Xml.XmlDocument doc, System.Xml.XmlReader reader, System.Boolean preserveWhitespace) [0x000a6] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) [0x0002e] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
at Xamarin.Tests.Configuration.GetPListStringValue (System.String plist, System.String key) [0x00028] in <44c95c7e3d1e488ab633a77d9a794653>:0
at Xamarin.MTouch.MT0091 (Xamarin.Profile profile, System.String name) [0x000ae] in <44c95c7e3d1e488ab633a77d9a794653>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <400071ddcfe64ed8a3531490bb763536>:0
* [tests] The MSBuild tests now need a reference to StringUtils.
Fix tests causing trouble for the AOT compiler by not building those tests on
device (they're testing error conditions in the simulator, which means it's
acceptable to exclude these tests for device builds).
This fixes an AOT-compiler assert:
> * Assertion at /Users/builder/data/lanes/1381/d264709b/source/xamarin-macios/external/mono/mono/metadata/marshal.c:8497, condition `sig->param_count == invoke_sig->param_count + 1' not met
due to invalid [MonoPInvokeCallback] attributes.
mono_set_pending_exception is a private mono symbol, which means we won't find
it when using the system mono (as a dynamic library). In that case, we'd
abort.
Instead try to call mono_raise_exception, and hope for the best. It will leak
somewhat, but that's still better than asserting.
This changes the generated wrapper function from:
```c
MONO_API void
mono_set_pending_exception (MonoException * exc)
{
if (mono_set_pending_exception_func == NULL)
xamarin_assertion_message ("Could not load mono_set_pending_exception\n");
return mono_set_pending_exception_func (exc);
}
```
to
```c
MONO_API void
mono_set_pending_exception (MonoException * exc)
{
if (mono_set_pending_exception_func == NULL)
return mono_raise_exception (exc);
return mono_set_pending_exception_func (exc);
}
```
Also this only applies to Xamarin.Mac apps that use the system mono (such as VSfM).
https://bugzilla.xamarin.com/show_bug.cgi?id=59979
* [msbuild] Improved logic for obtaining local IP addresses for WiFi debug
* If we can't resolve the local host, connect to microsoft.com and use LocalEndPoint
* Use UDP instead of TCP to avoid network latency
Exclude tests whose category is !BITCODE when running on watchOS/Release. This
also requires a minor update to xharness to add a BITCODE conditional
compilation flag to generated watchOS/Release projects configurations.
This partially fixes#59947 (the fix will be complete once we bump to mono/2017-08).
https://bugzilla.xamarin.com/show_bug.cgi?id=59947
* [HealthKit] Update to Xcode 9 GM
* Add new xcode 9 beta APIs
* Fix PR comments
Marking SyncVersion as an int based on SpeedySloth sample from Apple:
guard let version = route.metadata?[HKMetadataKeySyncVersion] as? NSNumber else {
print("Route does not have a sync version for route \(route)")
return
}
if version.intValue == 1 {
self.makeWorkoutRouteSlothy(workout: workout, route: route)
}
* Didn't save after deleting the FIXME
* Fix build issue
* Fix introspection tests
* Add new enum values to HKQuantityType.ToKey
* QuantityTypeIdentifierTest needs xcode version check for new enum types
* Change BlockLiteral.SetupBlock to keep a reference to the delegate passed as the trampoline.
Change BlockLiteral.SetupBlock to keep a reference to the delegate passed as
the trampoline, so that it's safer for normal users (crashes due to incorrect
usage are rare and random, and as such they're also hard to track down).
Additionally introduce a BlockLiteral.SetupBlockUnsafe method, that still has
the old behavior, so that we can use it in our own (reviewed) code.
* [ObjCRuntime] Add some validation to BlockLiteral.SetupBlock.
* Use BlockLiteral.SetupBlockUnsafe instead of .SetupBlock
Use SetupBlockUnsafe in our own code, because we know our own code is using it
correctly (by passing a trampoline stored in a static field, so that the GC
doesn't free it).
* [tests] Fix xammac tests build.
* [xharness] Don't list unusable devices.
* [xharness] Show the list of candidate devices in the html report.
* [xharness] Prioritize devices depending on the interface speed.
* [xharness] Simplify code a bit.
Logs are TextWriters by themselves, so no need to get a StreamWriter to pass
to API that takes TextWriter, when we can just pass the log instance itself.
This makes it possible to timestamp external process output (because
Log.Timestamp is honored instead of bypassed).
* [xharness] Timestamp install logs.
So that we get exact numbers of how long it takes to install on watch (and if
the watch installation stalls, or just times out because it takes too long).
Always wait for processes to exit, even if they're killed.
Also make absolutely sure that we can safely handle any exception when getting
the ExitCode, no matter what.
https://bugzilla.xamarin.com/show_bug.cgi?id=57846
* [ios11-b1] CoreGraphics bindings
* Updated with feedback from Sebastien
* Fix build, optimize checks
* Add version information
* Address comments
* Tests
* Remove Apply code, add special code for typo
* [CoreGraphics] Add comma after last enum value.
* [CoreGraphics] No need to bind CGColorSpaceGetName.
* [CoreGraphics] Add new field in Xcode 9 beta 5.
* [CoreGraphics] Move kCGPDFContextAccessPermissions to the correct dictionary container and implement the corresponding manual code.
* [CoreGraphics] Adjust nullability acceptance based on new attributes for CGColorSpace.CreateCalibratedGray/RGB functions.
* [CoreGraphics] Bind CGColorSpaceCreateLab, introduced in Xcode 9 beta 5.
* [CoreGraphics] Adjust CGColorSpaceCreateWithICCData and CGColorSpaceCreateWithICCProfile bindings according to Xcode 9 beta 2.
Apple introduced CGColorSpaceCreateWithICCData in b1, and made
CGColorSpaceCreateWithICCProfile a typedef to CGColorSpaceCreateWithICCData.
Apple reversed the typedef in b2 (probably because it creates broken
executables when targetting earlier versions of macOS, since those executables
would use CGColorSpaceCreateWithICCData, which would not exist), and instead
made CGColorSpaceCreateWithICCProfile a normal deprecated method.
So copy this logic in our bindings: deprecate CreateICCProfile, and introduce
CreateICCProfile, with two overloads for NSData and CGDataProvider (since
that's what's accepted according to the documentation).
* [CoreGraphics] Add CGContextPDF constructors to make parity between different overloads.
There are two types of CGContextPDF constructors: the first argument is either
an NSUrl or a CGDataConsumer. Previously the NSUrl type had more overloads,
and also allowed a null CGRect for the second argument. With the overloads are
identical between the two types of CGContextPDF constructors.
Existing constructors:
CGContextPDF (NSUrl, CGRect, CGPDFInfo)
CGContextPDF (NSUrl, CGRect)
CGContextPDF (NSUrl, CGPDFInfo)
CGContextPDF (NSUrl)
CGContextPDF (CGDataConsumer, CGRect, CGPDFInfo)
Added constructors:
CGContextPDF (CGDataConsumer, CGRect)
CGContextPDF (CGDataConsumer, CGPDFInfo)
CGContextPDF (CGDataConsumer)
Additionally the code has been fixed to not throw NullReferenceExceptions if
null is passed for any of the values and instead pass on any null values to
the native `CGPDFContextCreate` method (since `CGPDFContextCreate`'s arguments
are all `__nullable`).
* [tests] Add and improve existing tests for new and some existing CoreGraphics API.
* Undo accidental whitespace noise.
* [tests] Remove random characters in assert message.
* [CoreGraphics] Improve argument exception messages in CGColorSpace according to review.
* [CoreGraphics] Use 'Icc' instead of 'ICC' for new API, and also make the change for XAMCORE_4_0.
* [CoreGraphics] Fix availability attribute for High Sierra.
* [tests] Update monotouch-test after API changes.
csc does not allow unsafe code in iterators:
AudioUnit/AudioUnit.cs(1725,13): error CS1629: Unsafe code may not appear in iterators
AudioUnit/AudioUnit.cs(1725,33): error CS1629: Unsafe code may not appear in iterators
AudioUnit/AudioUnit.cs(1723,19): error CS1629: Unsafe code may not appear in iterators
It looks like mcs incorrectly allows this (https://bugzilla.xamarin.com/show_bug.cgi?id=56616).
So change the code to remove unsafe usage in iterators.
* [AVFoundation] AVFoundation API Enhancements
Changes in AVFoundation
===================
AVCaptureSynchronizedDataCollection:
* Obsoletes `From` method because the name does not makes sense in the current context.
* Obsoletes `ObjectForKeyedSubscript` in favor of a C# indexer.
* Adds `GetSynchronizedData` to replace obsoleted `From` method`.
AVCaptureSynchronizedData:
* Adds `[Abstract]` in XAMCORE_4_0 because it is an abstract superclass.
AVCaptureDevice:
* Adds strong typed API to `GetAuthorizationStatus` and `RequestAccessForMediaType`
using `AVAuthorizationMediaType` enum holding the only possible values.
AVCaptureDepthDataOutput:
* AVCaptureDepthDataOutput needs its default .ctor, there is no other way
to instantiate this class.
Test
====
A test exercising the new API lives here:
4715069b2b/AVCaptureDataOutputSynchronizerTest/AVCaptureDataOutputSynchronizerTest/ViewController.cs
The API needs an iPhone 7+, 8+ or X in order to run.
* Fix casing typos
AVCapturePhotoOutput:
* Adds missing members `DepthDataDeliverySupported` and `DepthDataDeliveryEnabled`
from `AVCapturePhotoOutputDepthDataDeliverySupport` category.
AVCaptureDevice:
* Adds missing members `ActiveDepthDataFormat`, `MinAvailableVideoZoomFactor` and
`MaxAvailableVideoZoomFactor` from `AVCaptureDeviceDepthSupport` category.
The registrar requires the availability attributes to work properly, which is
non-trivial when the linker is being used, because the linker runs before the
registrar, and will remove availability attributes.
For this reason we store the availability attributes separately when the
linker removes them so that the registrar can still find them, but
unfortunately it's not enough to store the CustomAttribute instance, because
it may end up crippled: if the attribute type itself is removed by the linker,
then it's not possible to get the attribute type from the CustomAttribute
instance, because 'attribute.Constructor.DeclaringType' returns null (the
linker sets the declaring type of the constructor to null).
Solution: store the attribute type separately; now we use a Tuple of
CustomAttribute and TypeReference.
Fixes this ugly exception:
System.NullReferenceException: Object reference not set to an instance of an object
at XamCore.Registrar.Registrar.RegisterAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00146] in /work/maccore/master/xamarin-macios/src/ObjCRuntime/Registrar.cs:2316
at XamCore.Registrar.StaticRegistrar.Generate (System.Collections.Generic.IEnumerable`1[T] assemblies, System.String header_path, System.String source_path) [0x00035] in /work/maccore/master/xamarin-macios/tools/common/StaticRegistrar.cs:4197
at Xamarin.Bundler.RunRegistrarTask.Execute () [0x00001] in /work/maccore/master/xamarin-macios/tools/mtouch/BuildTasks.mtouch.cs:154
Re-based from Miguel's PR #2476 including reviewers feedback.
[1] https://github.com/xamarin/xamarin-macios/pull/2476
* [spritekit] Add GKSceneRootNodeType to SKScene too and adjust intro tests
* [tests][intro][macos] Don't skip protocol checks for SceneKit on 64 bits