Testing out Cycle 9 with my app and NSUrlSessionHandler is crashing the app on Xamarin.iOS 10.4.0.54:
"Unhandled Exception: Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** -propertyForKey: only defined for abstract class. Define -[System_Net_Http_NSUrlSessionHandler_WrappedNSInputStream propertyForKey:]!"
It's fine with Xamarin.iOS 10.3.1.7. Only crashing when using the NSUrlSession. Managed and CFNetwork handlers don't crash. Only tested on iOS Simulator, with iOS 10.2.
Created attachment 19001 [details]
Crash log with stacktrace
Created attachment 19002 [details]
@Tom I have a good idea what the issue is. However it passed (at least) our dev unit tests and part of QA ones (QA is not complete on C9) so I'd like to have more details so we can add this case to our test suite.
Can you share with us the code to reproduce the issue ? thanks
@Manuel, our internal subclass does not override all the required members, see https://developer.apple.com/reference/foundation/nsstream?language=objc
Created attachment 19009 [details]
Crash test case
This is enough to crash it:
var content = new StringContent("", Encoding.UTF8, "application/json");
var client = new HttpClient();
await client.PostAsync("https://www.xamarin.com/", content);
Test project attached
Pr for with a fix can be found here: https://github.com/xamarin/xamarin-macios/pull/1435
Will comment once it lands.
1. As per comment0 I am successfully able to reproduce this issue with the mentioned version of Xamarin.iOS 10.4.0.54 at my end.
Getting Error: "NSUrlSessionHandlerCrash[2976:35957] Unhandled managed exception:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** -propertyForKey: only defined for abstract class. Define -[System_Net_Http_NSUrlSessionHandler_WrappedNSInputStream propertyForKey:]!"
Application Output: https://gist.github.com/Shruti360/86e1cdd6fbbef84f0bc1da1f348647df
Envt Info and IDE Log: https://gist.github.com/shrutis360/f0edc766b1694976be6b2462479dd201
2. As per comment6, I tried to verify the issue on Cycle 9 and Master build of XI and observed that issue still persist.
Build Output: https://gist.github.com/Shruti360/51daea457a703cf27ad8bf2076d1a384
Application Output: https://gist.github.com/Shruti360/cc04c46bfae421b968d24535ebe25bde
C9 Envt Info and IDE Logs: https://gist.github.com/shrutis360/98374027a2a6a2853742c777fcfd2c5d
Master Envt Info and IDE Logs: https://gist.github.com/shrutis360/0e5f4598e9d8586fe7fa3add2518f216
Hence, marking this issue as Reopened.
@Shruti nice catch. You have the linker enabled (in the simulator) which is different from the attachment (but @Manuel should have tried it on device too).
What happens is that the code that solve the issue is not used (by the app) so the linker removes it (but iOS itself wants to call into it). I'll fix this.
The PR (from comment #5) only called the "abstract" native implementation (that simply assert). What was needed is an override that returns false (and null) for both API.
It seems that using the PR with the test case that PostAsync hang (instead of asserting). That made it look like it was fine.
I'm looking into why that happened since the build bots are still down. It's not linker related, but maybe it's because the partial static registrar could be used on sim/dont link?
It seems to be a debugger/UI "issue". The debugger execution is stopped (like a breakpoint). If resumed then we get the abort in the application output.
* the app screen is black;
* the editor does not change (file / source location);
* the call stack pad is empty; and
* we don't get any dialog (or other visual clue) that the process is stopped
it's easy to think the execution has completed successfully (and kill the app).
The behaviour seems to happen only with a prebuilt simlauncher, i.e. if linking or giving mtouch other options (e.g. `--registrar:static`) then the abort happens without a break.
PR cycle9 https://github.com/xamarin/xamarin-macios/pull/1451
cycle9 build -> https://github.com/xamarin/xamarin-macios/commit/9af9671e46df7f16df04b5e580fc13a8d9fdda50 (to verify)
PR master https://github.com/xamarin/xamarin-macios/pull/1452
I have checked this issue following by comment9 and 10 with the Cycle9 build mentioned in comment12 and observed that the issue is working fine now.
*OK Tested on iOS Simulator, with iOS 10.2, 10.0 and iPhone 7 (physical device) with iOS 10.2.
Build Output: https://gist.github.com/Shruti360/c0f8cbf0face96f362f8ce9a6ce2401a
Application Output: https://gist.github.com/Shruti360/9ed7ca9803934971251f96c82a9fa8c9
Envt Info and IDE Logs: https://gist.github.com/shrutis360/340a837df58b358bb90f9f8bce9b355e
I will close this issue once the fix is verified on Master as well.
@Sebastien, Please commit the fix on Master.
PR was merged https://github.com/xamarin/xamarin-macios/commit/77a92500a5e20884e64eb853204bf24b579f4e91
I have checked this issue with the latest build of Master XI and observed that this issue is fixed now.
Build Output: https://gist.github.com/Shruti360/99cc9550b5ee7bb276c7eb6f9cee8f74
Application Output: https://gist.github.com/Shruti360/30865e66902909a9e164884404a9199b
Envt and IDE Logs: https://gist.github.com/shrutis360/ad7a44853cdd02f4d71173f0f17b8f8b
Hence, marking this issue as verified fixed.