Skip to content
Closed

D15 1 #518

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "external/Java.Interop"]
path = external/Java.Interop
url = https://github.com/xamarin/java.interop.git
branch = master
branch = d15-1
[submodule "external/mono"]
path = external/mono
url = https://github.com/mono/mono.git
Expand Down
2 changes: 1 addition & 1 deletion Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Condition=" '$(DoNotLoadOSProperties)' != 'True' "
/>
<PropertyGroup>
<ProductVersion>7.1.99</ProductVersion>
<ProductVersion>7.2.0</ProductVersion>
<AutoProvision Condition=" '$(AutoProvision)' == '' ">False</AutoProvision>
<AutoProvisionUsesSudo Condition=" '$(AutoProvisionUsesSudo)' == '' ">False</AutoProvisionUsesSudo>
<HostOS Condition=" '$(HostOS)' == '' And '$(OS)' == 'Windows_NT' ">Windows</HostOS>
Expand Down
2 changes: 1 addition & 1 deletion external/mono
Submodule mono updated 100 files
37 changes: 19 additions & 18 deletions src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ string EncodeUrl (Uri url)
while (true) {
URL java_url = new URL (EncodeUrl (redirectState.NewUrl));
URLConnection java_connection = java_url.OpenConnection ();
HttpURLConnection httpConnection = await SetupRequestInternal (request, java_connection);
HttpResponseMessage response = await ProcessRequest (request, java_url, httpConnection, cancellationToken, redirectState);
HttpURLConnection httpConnection = await SetupRequestInternal (request, java_connection).ConfigureAwait (continueOnCapturedContext: false);;
HttpResponseMessage response = await ProcessRequest (request, java_url, httpConnection, cancellationToken, redirectState).ConfigureAwait (continueOnCapturedContext: false);;
if (response != null)
return response;

Expand All @@ -235,6 +235,19 @@ Task DisconnectAsync (HttpURLConnection httpConnection)
return Task.Run (() => httpConnection?.Disconnect ());
}

Task ConnectAsync (HttpURLConnection httpConnection, CancellationToken ct)
{
return Task.Run (() => {
try {
using (ct.Register (() => httpConnection?.Disconnect ()))
httpConnection?.Connect ();
} catch {
ct.ThrowIfCancellationRequested ();
throw;
}
}, ct);
}

async Task <HttpResponseMessage> DoProcessRequest (HttpRequestMessage request, URL javaUrl, HttpURLConnection httpConnection, CancellationToken cancellationToken, RequestRedirectionState redirectState)
{
if (Logger.LogNet)
Expand All @@ -247,30 +260,18 @@ Task DisconnectAsync (HttpURLConnection httpConnection)
cancellationToken.ThrowIfCancellationRequested ();
}

CancellationTokenSource waitHandleSource = new CancellationTokenSource();
try {
if (Logger.LogNet)
Logger.Log (LogLevel.Info, LOG_APP, $" connecting");

CancellationToken linkedToken = CancellationTokenSource.CreateLinkedTokenSource(waitHandleSource.Token, cancellationToken).Token;
await Task.WhenAny (
httpConnection.ConnectAsync (),
Task.Run (()=> {
linkedToken.WaitHandle.WaitOne();
if (Logger.LogNet)
Logger.Log(LogLevel.Info, LOG_APP, $"Wait handle task finished");
}))
.ConfigureAwait(false);
await ConnectAsync (httpConnection, cancellationToken).ConfigureAwait (continueOnCapturedContext: false);
if (Logger.LogNet)
Logger.Log (LogLevel.Info, LOG_APP, $" connected");
} catch (Java.Net.ConnectException ex) {
if (Logger.LogNet)
Logger.Log (LogLevel.Info, LOG_APP, $"Connection exception {ex}");
// Wrap it nicely in a "standard" exception so that it's compatible with HttpClientHandler
throw new WebException (ex.Message, ex, WebExceptionStatus.ConnectFailure, null);
} finally{
//If not already cancelled, cancel the WaitOne through the waitHandleSource to prevent an orphaned thread
waitHandleSource.Cancel();
}

if (cancellationToken.IsCancellationRequested) {
Expand Down Expand Up @@ -541,7 +542,7 @@ void CopyHeaders (HttpURLConnection httpConnection, HttpResponseMessage response
/// <param name="conn">Pre-configured connection instance</param>
protected virtual Task SetupRequest (HttpRequestMessage request, HttpURLConnection conn)
{
return Task.Factory.StartNew (AssertSelf);
return Task.Run (AssertSelf);
}

/// <summary>
Expand Down Expand Up @@ -645,9 +646,9 @@ void AppendEncoding (string encoding, ref List <string> list)
}

HandlePreAuthentication (httpConnection);
await SetupRequest (request, httpConnection);
await SetupRequest (request, httpConnection).ConfigureAwait (continueOnCapturedContext: false);;
SetupRequestBody (httpConnection, request);

return httpConnection;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace MonoDroid.Tuner
class MonoDroidMarkStep : MarkStep
{
const string RegisterAttribute = "Android.Runtime.RegisterAttribute";
const string ICustomMarshalerName = "System.Runtime.InteropServices.ICustomMarshaler";

// If this is one of our infrastructure methods that has [Register], like:
// [Register ("hasWindowFocus", "()Z", "GetHasWindowFocusHandler")],
Expand Down Expand Up @@ -142,6 +143,15 @@ protected override TypeDefinition MarkType (TypeReference reference)
if (type.Module.Assembly.Name.Name == "System.Core")
ProcessSystemCore (type);

if (type.HasMethods && type.HasInterfaces && type.Implements (ICustomMarshalerName)) {
foreach (MethodDefinition method in type.Methods) {
if (method.Name == "GetInstance" && method.IsStatic && method.HasParameters && method.Parameters.Count == 1 && method.ReturnType.FullName == ICustomMarshalerName && method.Parameters.First ().ParameterType.FullName == "System.String") {
MarkMethod (method);
break;
}
}
}

return type;
}

Expand Down
54 changes: 34 additions & 20 deletions src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
using Microsoft.Build.Utilities;
Expand Down Expand Up @@ -89,6 +90,8 @@ bool ManifestIsUpToDate (string manifestFile)

bool RunAapt (string commandLine)
{
var stdout_completed = new ManualResetEvent (false);
var stderr_completed = new ManualResetEvent (false);
var psi = new ProcessStartInfo () {
FileName = GenerateFullPathToTool (),
Arguments = commandLine,
Expand All @@ -99,26 +102,37 @@ bool RunAapt (string commandLine)
WindowStyle = ProcessWindowStyle.Hidden,
};

var proc = new Process ();
proc.OutputDataReceived += (sender, e) => {
LogEventsFromTextOutput (e.Data, MessageImportance.Normal);
};
proc.ErrorDataReceived += (sender, e) => {
LogEventsFromTextOutput (e.Data, MessageImportance.Normal);
};
proc.StartInfo = psi;
proc.Start ();
proc.BeginOutputReadLine ();
proc.BeginErrorReadLine ();
Token.Register (() => {
try {
proc.Kill ();
} catch (Exception) {
}
});
LogDebugMessage ("Executing {0}", commandLine);
proc.WaitForExit ();
return proc.ExitCode == 0;
using (var proc = new Process ()) {
proc.OutputDataReceived += (sender, e) => {
if (e.Data != null)
LogEventsFromTextOutput (e.Data, MessageImportance.Normal);
else
stdout_completed.Set ();
};
proc.ErrorDataReceived += (sender, e) => {
if (e.Data != null)
LogEventsFromTextOutput (e.Data, MessageImportance.Normal);
else
stderr_completed.Set ();
};
proc.StartInfo = psi;
proc.Start ();
proc.BeginOutputReadLine ();
proc.BeginErrorReadLine ();
Token.Register (() => {
try {
proc.Kill ();
} catch (Exception) {
}
});
LogDebugMessage ("Executing {0}", commandLine);
proc.WaitForExit ();
if (psi.RedirectStandardError)
stderr_completed.WaitOne (TimeSpan.FromSeconds (30));
if (psi.RedirectStandardOutput)
stdout_completed.WaitOne (TimeSpan.FromSeconds (30));
return proc.ExitCode == 0;
}
}

bool ExecuteForAbi (string cmd, string currentResourceOutputFile)
Expand Down
38 changes: 28 additions & 10 deletions src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ IEnumerable<Config> GetAotConfigs ()

bool RunAotCompiler (string assembliesPath, string aotCompiler, string aotOptions, string assembly, CancellationToken token)
{
var stdout_completed = new ManualResetEvent (false);
var stderr_completed = new ManualResetEvent (false);
var psi = new ProcessStartInfo () {
FileName = aotCompiler,
Arguments = aotOptions + " \"" + assembly + "\"",
Expand All @@ -453,16 +455,32 @@ bool RunAotCompiler (string assembliesPath, string aotCompiler, string aotOption
LogDebugMessage ("[AOT] MONO_PATH=\"{0}\" MONO_ENV_OPTIONS=\"{1}\" {2} {3}",
psi.EnvironmentVariables ["MONO_PATH"], psi.EnvironmentVariables ["MONO_ENV_OPTIONS"], psi.FileName, psi.Arguments);

var proc = new Process ();
proc.OutputDataReceived += OnAotOutputData;
proc.ErrorDataReceived += OnAotErrorData;
proc.StartInfo = psi;
proc.Start ();
proc.BeginOutputReadLine ();
proc.BeginErrorReadLine ();
token.Register (() => { try { proc.Kill (); } catch (Exception) {} });
proc.WaitForExit ();
return proc.ExitCode == 0;
using (var proc = new Process ()) {
proc.OutputDataReceived += (s, e) => {
if (e.Data != null)
OnAotOutputData (s, e);
else
stdout_completed.Set ();
};
proc.ErrorDataReceived += (s, e) => {
if (e.Data != null)
OnAotErrorData (s, e);
else
stderr_completed.Set ();
};
proc.StartInfo = psi;
proc.Start ();
proc.BeginOutputReadLine ();
proc.BeginErrorReadLine ();
token.Register (() => { try { proc.Kill (); } catch (Exception) { } });
proc.WaitForExit ();
if (psi.RedirectStandardError)
stderr_completed.WaitOne (TimeSpan.FromSeconds (30));
if (psi.RedirectStandardOutput)
stdout_completed.WaitOne (TimeSpan.FromSeconds (30));
return proc.ExitCode == 0;
}
GC.Collect ();
}

void OnAotOutputData (object sender, DataReceivedEventArgs e)
Expand Down
Loading