Skip to content

Conversation

@dellis1972
Copy link
Contributor

There is a possilility that we might be locking up the UI thread
when logging CustomBuildEvents.. This happens in the
InstallPackageAssemblies task. Currently we only use

BuildEngine.LogCustomEvent

Which may well cause problems when called from a non UI thread.

So in keeping with the other Log methods available we should add
a new LogCustomBuildEvent. This will queue and marshall the data
to the UI Thread just like the other methods do.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also think about making the Log property non-private (protected) so there are build warnings if we accidentally use it: https://github.com/dellis1972/xamarin-android/blob/f7974f61258e48dd2c6a918eaa6ca7296148d8e7/src/Xamarin.Android.Build.Tasks/Tasks/AsyncTask.cs#L41

We could also think about making the AsyncTask.Log property throw if it is used as a way to force us to find them all. Maybe I can look into this down the road, probably don't want to do it in this PR.

@dellis1972
Copy link
Contributor Author

@jonathanpeppers the Obsolete should take care of that. It might be worth seeing if we can throw an exception.. I'd do that in a separate PR though.

@jonathanpeppers
Copy link
Member

@dellis1972 but if it's private any task that subclasses AsyncTask, won't have the warning, right?

Queue logMessageQueue =new Queue ();
Queue warningMessageQueue = new Queue ();
Queue errorMessageQueue = new Queue ();
Queue customMessageQueue = new Queue ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be using Queue<T>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queue<T> does not include a SyncRoot property which we need for threading. Now I can add a bunch of extra objects to handle that. Remember this code was sourced from the msbuild ToolTask. At the time it was safer to follow their lead rather than introduce possible unknowns.

#pragma warning restore 618
}

lock (customMessageQueue.SyncRoot) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like an opportunity for cleanup/a new helper method, as LogCustomBuildEvent() looks very similar to LogMessage() looks very similar to LogError() looks...

Particularly around the locking and message queuing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can rework this into a helper. Each queue still needs its own reset event though.


private void LogCustomData ()
{
lock (customMessageQueue.SyncRoot) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto this body: LogCustomData() looks like LogErrors() looks like LogWarnings()... Surely we can have a helper method for consistency.

@dellis1972
Copy link
Contributor Author

Build failure is our old BlockCopy error again :/

…Task

There is a possilility that we might be locking up the UI thread
when logging CustomBuildEvents.. This happens in the
`InstallPackageAssemblies` task. Currently we only use

	BuildEngine.LogCustomEvent

Which may well cause problems when called from a non UI thread.

So in keeping with the other Log methods available we should add
a new LogCustomBuildEvent. This will queue and marshall the data
to the UI Thread just like the other methods do.
@dellis1972 dellis1972 force-pushed the AddCustomBuildLogging branch from d1b2a7f to 797306a Compare December 5, 2017 13:02
@jonpryor jonpryor merged commit 136c90e into dotnet:master Dec 5, 2017
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Jan 22, 2020
Changes: https://github.com/xamarin/monodroid/compare/0f6725edfa09559afad58233d43f385122e31e8d...b2841feb5a69f9ccd3c480a9341fcb1da62af552

Context: https://build.azdo.io/3395342

  * xamarin/monodroid@b2841feb5: Bump to xamarin/android-sdk-installer/master@78c3d16 (dotnet#1065)
  * xamarin/monodroid@3c8601c55: [tools/msbuild] ported <GetPrimaryCpuAbi/> to AndroidAsyncTask (dotnet#1067)
  * xamarin/monodroid@ad8d0f348: Support for new typemaps (dotnet#1061)
dellis1972 pushed a commit that referenced this pull request Jan 27, 2020
* Bump to xamarin/monodroid@b2841feb

Changes: xamarin/monodroid@0f6725e...b2841fe

Context: https://build.azdo.io/3395342

  * xamarin/monodroid@b2841feb5: Bump to xamarin/android-sdk-installer@78c3d16 (#1065)
  * xamarin/monodroid@3c8601c55: [tools/msbuild] ported <GetPrimaryCpuAbi/> to AndroidAsyncTask (#1067)
  * xamarin/monodroid@ad8d0f348: Support for new typemaps (#1061)

* Bump to xamarin/monodroid@78d56588

Changes: xamarin/monodroid@b2841fe...78d5658

Bump to xamarin/androidtools@b01b4db

[Mono.AndroidTools] use pm list packages -f --show-versioncode

Co-authored-by: Jonathan Peppers <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants