Skip to content

Crash in NSUrlSessionHandler.cs (RemoveNotification) #6691

Closed

Description

@softlion

I just get a crash in NSUrlSessionHandler.cs line 191

System.Net.Http.NSUrlSessionHandler.RemoveNotification
/Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.110/src/Xamarin.iOS/Foundation/NSUrlSessionHandler.cs:191,5

The crash message is "can not remove null observer". I checked your source code and there is a null check but it is not synced. Maybe there is a parallel call which calls this method twice.

Steps to Reproduce

Random :(

Expected Behavior

No crash

Actual Behavior

Crash

Environment

VS 2019 Windows 16.2.0
Xamarin iOS 12.14.0.110

Activity

  1. mandel-macaque commented on Jul 31, 2019

    @mandel-macaque
    Contributor

    Hello! Thanks for the reporting it, we though we fixed it when we fixed the race condition in the notification centre, and therefore closed #6537 without merging it. Now that we know it happens (it is a very strange case, but I new it was possible) I have reopened the PR with the fix within the handler. Everything should be more robust now.

  2. added this to the Future milestone on Jul 31, 2019
  3. softlion commented on Jul 31, 2019

    @softlion
    Author

    Ok, so it will go to the stable channel in vnext in 2 months ?

  4. mandel-macaque commented on Jul 31, 2019

    @mandel-macaque
    Contributor

    @softlion once I land it in master, I'll do a back port to d16-3, which will be in the next preview if you want to test ASAP. If you click on the commits, we generate packages for you to test too also.

    @dalexsoto do we have exact dates about the next preview?

  5. uwe-neuronation commented on Sep 2, 2019

    @uwe-neuronation

    We also see that bug from time to time.

    Parameter name: observer (System.ArgumentNullException)
      at Foundation.NSNotificationCenter.RemoveObserver (Foundation.NSObject observer) <0x103644b10 + 0x00084> in <c7623ebd6c5c49808d04bacb43da90c0#6b0f8e63beac175a9a14f7f46fe4675e>:0 
      at System.Net.Http.NSUrlSessionHandler.RemoveNotification () <0x1035f4890 + 0x0003b> in <c7623ebd6c5c49808d04bacb43da90c0#6b0f8e63beac175a9a14f7f46fe4675e>:0 
      at System.Net.Http.NSUrlSessionHandler.RemoveInflightData (Foundation.NSUrlSessionTask task, System.Boolean cancel) <0x1035f49e8 + 0x000ef> in <c7623ebd6c5c49808d04bacb43da90c0#6b0f8e63beac175a9a14f7f46fe4675e>:0 
      at System.Net.Http.NSUrlSessionHandler+NSUrlSessionHandlerDelegate.DidCompleteWithError (Foundation.NSUrlSession session, Foundation.NSUrlSessionTask task, Foundation.NSError error) <0x1035f5350 + 0x000db> in <c7623ebd6c5c49808d04bacb43da90c0#6b0f8e63beac175a9a14f7f46fe4675e>:0
    

    Is it already fixed? I have Xamarin.iOS Version: 12.14.0.114 (Visual Studio Community 2019 for Mac Version 8.2.5 (build 5))
    With which version does the fix come?

  6. uwe-neuronation commented on Sep 4, 2019

    @uwe-neuronation

    Does someone found a workaround for that? Can I catch the exception somehow?
    shall I downgrade Xamarin.iOS ?

  7. uwe-neuronation commented on Sep 5, 2019

    @uwe-neuronation

    I did update Xamarin.iOS to 12.16.1.17
    Now the error message changed a bit, but it still crashes the app.

    Unhandled managed exception: Value cannot be null.
    Parameter name: observer (System.ArgumentNullException)
      at System.Net.Http.NSUrlSessionHandler.RemoveNotification () <0x101417564 + 0x0008c> in <c32c9857806543038a06ded0744ec25a#f32e183476668aa100c30689548ba707>:0 
      at System.Net.Http.NSUrlSessionHandler.RemoveInflightData (Foundation.NSUrlSessionTask task, System.Boolean cancel) <0x1014176d0 + 0x0010f> in <c32c9857806543038a06ded0744ec25a#f32e183476668aa100c30689548ba707>:0 
      at System.Net.Http.NSUrlSessionHandler+NSUrlSessionHandlerDelegate.DidCompleteWithError (Foundation.NSUrlSession session, Foundation.NSUrlSessionTask task, Foundation.NSError error) <0x1014180ac + 0x000c3> in <c32c9857806543038a06ded0744ec25a#f32e183476668aa100c30689548ba707>:0
    
  8. mandel-macaque commented on Sep 5, 2019

    @mandel-macaque
    Contributor

    Hello, I believe this is a duplicate and was fixed in #6537

    Closing the issue. Can you please check with this build: https://bosstoragemirror.blob.core.windows.net/wrench/jenkins/master/8a4c85863a5678a7ab8a105c4112d4564c862a74/857/package/xamarin.ios-12.15.0.320.pkg

  9. ngraef commented on Sep 6, 2019

    @ngraef

    Thanks, @mandel-macaque. xamarin.ios-12.15.0.320 seems to have fixed the issue for me.

  10. uwe-neuronation commented on Sep 10, 2019

    @uwe-neuronation

    Same for me, I tested xamarin.ios-12.15.0.320 and it seems to be ok. But the problem happens only to some NSUrlSessionHandler, so I'm not 100% sure.
    Thanks, @mandel-macaque

    When will this go to stable or preview?

  11. ghost locked as resolved and limited conversation to collaborators on May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions