xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 514 forks source link

Xamarin iOS UI hangs on calling userInputEvent.WaitOne() API after invoking a new UI #4862

Closed vittalpai closed 6 years ago

vittalpai commented 6 years ago

Steps to Reproduce

  1. Create a Xamarin form application . 2.Invoke a UI from Main thread using BeginInvokeOnMainThread followed by a wait for user input using an API userInputEvent.WaitOne(); 3.Run the application and click on a button so that it will invoke the UI .

Expected Behavior

The UI has to navigate from Main UI to new UI which is called using BeginInvokeOnMainThread

Actual Behavior

The UI gets freezed after the api call “userInputEvent”.

Environment


=== Visual Studio Community 2017 for Mac ===

Version 7.4.2 (build 12)
Installation UUID: d7d592b3-3f7b-4c6d-9bd5-f1fbf82e9cf2
Runtime:
    Mono 5.8.1.0 (2017-10/6bf3922f3fd) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 508010000

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    2.0.5
    2.0.0
SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
SDK Versions:
    2.1.4
    2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.2.0.16 (Visual Studio Community)
Android SDK: /Users/shubha/Library/Android/sdk
    Supported Android versions:
        4.2 (API level 17)
        4.3 (API level 18)
        4.4 (API level 19)
        5.0 (API level 21)
        5.1 (API level 22)
        6.0 (API level 23)
        7.0 (API level 24)
        7.1 (API level 25)
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.2
SDK Build Tools Version: 26.0.3

Java SDK: /usr
java version “1.8.0_131”
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 9.4.1 (14161)
Build 9F2000

=== Xamarin.Mac ===

Version: 4.2.1.28 (Visual Studio Community)

=== Xamarin.iOS ===

Version: 11.9.1.24 (Visual Studio Community)
Hash: f62de472
Branch: xcode9.3
Build date: 2018-03-29 19:30:53-0400

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 704020012
Git revision: 0d8e3f0a4d683771f17959739956fa09c7ba21e3
Build date: 2018-03-30 10:45:17-04
Xamarin addins: 958839ea56ab1e331caf7c92b6ad50fb9e6ee9d2
Build lane: monodevelop-lion-d15-6

=== Operating System ===

Mac OS X 10.13.5
Darwin 17.6.0 Darwin Kernel Version 17.6.0
   Tue May  8 15:22:16 PDT 2018
   root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Internet of Things (IoT) development (Preview) 7.1

Build Logs

Example Project (If Possible)

MFTestApp.zip

rolfbjarne commented 6 years ago

It looks like your zip is incomplete: it doesn't contain MFTestApp\MFTestApp.iOS\MFTestApp.iOS.csproj, referenced by the solution. Could you update it?

shubhaprasad commented 6 years ago

@rolfbjarne Since the app size was bigger only the part of the app containing the code which is causing the issue was shared . Here is a box link where the sample app can be downloaded from https://ibm.box.com/s/k234t5jmnlq62iwzipeok58dhskbdw9n .

rolfbjarne commented 6 years ago

Your project still doesn't build, because it references assemblies that are not included:

<Reference Include="MobileFirst.iOS">
  <HintPath>..\..\..\mfp-windows-sdk-8.0.2018090406-zip\IBM.MobileFirstPlatformFoundation.8.0.2018090406\lib\xamarinios\MobileFirst.iOS.dll</HintPath>
</Reference>
<Reference Include="MobileFirst.iOS.JSONStore">
  <HintPath>..\..\..\mfp-windows-sdk-8.0.2018090406-zip\IBM.MobileFirstPlatformFoundation.8.0.2018090406\lib\xamarinios\MobileFirst.iOS.JSONStore.dll</HintPath>
</Reference>
<Reference Include="MobileFirst.Xamarin.iOS">
  <HintPath>..\..\..\mfp-windows-sdk-8.0.2018090406-zip\IBM.MobileFirstPlatformFoundation.8.0.2018090406\lib\xamarinios\MobileFirst.Xamarin.iOS.dll</HintPath>
</Reference>
<Reference Include="Worklight.Core">
  <HintPath>..\..\..\mfp-windows-sdk-8.0.2018090406-zip\IBM.MobileFirstPlatformFoundation.8.0.2018090406\lib\xamarinios\Worklight.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
  <HintPath>..\..\..\..\Documents\github-repos\mfp-client-windows\worklight-windows8\worklight-windows8\Newtonsoft.Json.dll</HintPath>
</Reference>

However, the problem seems to be that HandleChallenge is called on the main thread, then you queue something to be executed on the main thread, and immediately wait for it to finish executing, which will never happen, because you're blocking the main thread.

The solution is to not block the main thread.