Bug 22195 - Crash with InvalidCastException CADisplayLink/NSTimer thrown by UIApplication.Main
Summary: Crash with InvalidCastException CADisplayLink/NSTimer thrown by UIApplication...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.5
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-08-19 05:19 UTC by pierre
Modified: 2016-12-22 19:06 UTC (History)
16 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
EAGLView class modified to use default run cicle (10.61 KB, text/plain)
2014-08-21 08:33 UTC, David Ávila Membrives
Details
OGA Test Project (12.00 KB, application/octet-stream)
2014-08-25 11:20 UTC, Shruti
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description pierre 2014-08-19 05:19:45 UTC
System.InvalidCastException: Unable to cast object of type 'MonoTouch.CoreAnimation.CADisplayLink' (Objective-C type: 'CADisplayLink') to type 'MonoTouch.Foundation.NSTimer'.

Additional information:

	Selector: runIteration:

	Method: OpenTK.Platform.iPhoneOS.CADisplayLinkTimeSource:RunIteration (MonoTouch.Foundation.NSTimer)
Comment 1 Zoltan Varga 2014-08-19 19:28:43 UTC
-> x.ios
Comment 2 Virgile Bello 2014-08-21 00:11:13 UTC
Note: only happens in Debug, not Release.
Comment 3 David Ávila Membrives 2014-08-21 08:33:46 UTC
Created attachment 7754 [details]
EAGLView class modified to use default run cicle
Comment 4 David Ávila Membrives 2014-08-21 08:35:32 UTC
Hi,

We have suffering the same bug, easy steps to reproduce:
- Create a new OpenGL for iOS project using the template.
- Modify EAGLView.cs class to remove all references of CADisplayLink displayLink and launch the Render cycle using the Run() method (I have attached the EAGLView.cs file).

Our log trace is the same as mentioned above:

 Exception:

System.InvalidCastException: Unable to cast object of type 'MonoTouch.CoreAnimation.CADisplayLink' (Objective-C type: 'CADisplayLink') to type 'MonoTouch.Foundation.NSTimer'.
Additional information:
	Selector: runIteration:
	Method: OpenTK.Platform.iPhoneOS.CADisplayLinkTimeSource:RunIteration (MonoTouch.Foundation.NSTimer)

2014-08-21 14:14:12.178 LauncheriOS[3307:60b] Unhandled managed exception: Unable to cast object of type 'MonoTouch.CoreAnimation.CADisplayLink' (Objective-C type: 'CADisplayLink') to type 'MonoTouch.Foundation.NSTimer'.
Additional information:
	Selector: runIteration:
	Method: OpenTK.Platform.iPhoneOS.CADisplayLinkTimeSource:RunIteration (MonoTouch.Foundation.NSTimer)
 (System.InvalidCastException)
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:39 
  at LauncherIOS.Program.Main (System.String[] args) [0x00001] in f:\GroupM\Git\LauncherIOS\Program.cs:12 
Debugging session ended.
The program 'Mono' has exited with code 0 (0x0).
Comment 5 Shruti 2014-08-22 12:02:37 UTC
I have checked this issue with attached EAGLView.cs file and able to reproduce it.

Screencast : http://screencast.com/t/GaqtU1nIe

Supplement Info :
XVS Log : https://gist.github.com/shrutis360/c316f4e98679b4de74df
VS Output Log : https://gist.github.com/shrutis360/4b2e012d16c2526954f4
Build Host Log : https://gist.github.com/Shruti360/3a219379b629a2c857a5

Envrionment Info :

XVS build version 3.5.39.0
X.iOS version 7.4.0.104
Comment 6 Sebastien Pouliot 2014-08-22 14:23:52 UTC
Miguel fixed and backport (as it is a regression) this in
monotouch-7.4.0-branch 3991e99ddad845a70b3f4ba03a9bb2e799a29542
Comment 7 Sadik Ali 2014-08-25 04:08:16 UTC
I have checked this issue with latest builds. But faced same issue again.

Environment Info :

XVS build version 3.5.49.0
X.iOS version 7.4.0.106

Hence, I am reopening this issue.

Please let me know if this issue is fixed with any other build.
Comment 8 Sebastien Pouliot 2014-08-25 10:03:43 UTC
@Sadik, please always state which version of iOS was used and if you used the simulator or devices.

a. It seems to work fine for me, can you attach your sample ?

and

b. can you confirm this bug using a Mac/XS (not Win/VS) and XI 7.4.0.106 ?


@Gouri can you confirm it works or not ?
Comment 9 Shruti 2014-08-25 11:20:41 UTC
Created attachment 7788 [details]
OGA Test Project

We have checked this on Win/Mac both, Status is given below :

Windows :
We have checked this issue on window because this issue is raised for windows. Here, we are getting issue as described in Comment 4 & 5 resp. Screencast regarding same : http://screencast.com/t/VxFPtsAG 

Mac :
This is working fine on Mac.

Note : We have test this issue with same project attached here with name "OGA Test Project". We have added EAGLView class code in this project (given in comment 3).

Environment Info :

Windows:
Microsoft Visual Studio Professional 2013
Xamarin  3.5.49.0 

Mac :
 === Xamarin Studio ===

Version 5.3 (build 434)
Installation UUID: 449f40dd-b3f1-4028-9a6b-cca0d1a2307d
Runtime:
 Mono 3.8.0 ((no/62a857e)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 308000007

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.Mac ===

Version: 1.10.0.9 (Starter Edition)

=== Xamarin.Android ===

Version: 4.16.0 (Trial Edition)
Android SDK: /Users/360logicaxamarinmacmini/Desktop/android-sdk-macosx_AndÃsdk
 Supported Android versions:
  1.6    (API level 4)
  2.1    (API level 7)
  2.2    (API level 8)
  2.3    (API level 10)
  3.1    (API level 12)
  3.2    (API level 13)
  4.0    (API level 14)
  4.0.3  (API level 15)
  4.1    (API level 16)
  4.2    (API level 17)
  4.3    (API level 18)
  4.4    (API level 19)
  4.4.87 (API level 20)
  4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.iOS ===

Version: 7.4.0.106 (Trial Edition)
Hash: 3991e99
Branch: 
Build date: 2014-08-22 13:09:34-0400

=== Build Information ===

Release ID: 503000434
Git revision: 9b508e2173c6a211fa020d9743a86b484b5ed0d2
Build date: 2014-08-21 12:41:28-04
Xamarin addins: 69708b283b171ea053d0edfbf09d98457d21fbee

=== Operating System ===

Mac OS X 10.8.4
Darwin 360Logicas-Mac-mini.local 12.4.0 Darwin Kernel Version 12.4.0
    Sun Mar 10 18:01:10 PDT 2013
    root:xnu-2050.24.6~1/RELEASE_X86_64 x86_64

Device/Simulator Detail :
iPhone 5C Version 7.1, iPhone 4S 7.0

Simulator : iPhone Retina (3.5 inch) iOS 7.1

This Bug is reported for windows, So on this behalf we changing bug status as confirmed.
Comment 10 Shruti 2014-08-25 11:21:53 UTC
Changing status of the bug.
Comment 11 Sebastien Pouliot 2014-08-25 11:32:22 UTC
works on mac -> VS

I assume there's soemthing wrong with `sync` ? or 
a wrong .dll is being copied ?
Comment 12 GouriKumari 2014-08-25 11:37:37 UTC
Updates to Comment#8:
> @Gouri can you confirm it works or not ?

I verified with XS 5.3 and Xamarin.iOS 7.4.0.106.pkg. I could successfully
deploy an OpenGL application on device, after replacing EAGLView class with the
one given in this bug report.

Logs:
Build Log: https://gist.github.com/GouriKumari/0016ecac196feaaf98f8
ApplicationOutput: https://gist.github.com/GouriKumari/0bd7dbf0ede50f55bf8e

Supplemental Info:
I could reproduce this bug with  current Xamarin.iOS beta 7.4.0.104.pkg and XS
5.3
Screenshot of Exception: http://screencast.com/t/8cuVqvml5auj
Build Log: https://gist.github.com/GouriKumari/26a8dbadebc22e5bf42b

Test Env:
Xamarin Studio
Version 5.3 (build 427)
Installation UUID: 5ed3a124-4b77-4c6f-beb9-c830fd815e2a
Runtime:
    Mono 3.8.0 ((no/62a857e)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 308000007

Apple Developer Tools
Xcode 6.0 (6256.16)
Build 6A280e

Xamarin.iOS
Version: 7.4.0.104 (Enterprise Edition) (Bug occurs with this build)
Hash: 63b403b
Branch: 
Version: 7.4.0.106 (Enterprise Edition) ( (Bug fixed/not occurring with this
build)
Hash: 3991e99d
Comment 13 Virgile Bello 2014-08-27 05:31:35 UTC
Any chance this gets fixed and pushed soon (in stable)?

We were planning to release our SDK soon, but difficult to do if nothing can be debugged on iOS.
Even a workaround would be great!

Thanks
Comment 14 David Ávila Membrives 2014-08-28 02:18:20 UTC
Hi Virgile Bello,

As a workarround, you can copy the CADisplayLink stuff that is used in the OpenGL template for iOS.
Comment 15 Joaquin Jares 2015-10-19 09:40:52 UTC
According to c12, this bug seems to be resolved. Marked as NEEDINFO for confirmation.
Comment 16 Emanuel 2016-12-22 19:06:26 UTC
Marking this bug as resolved fixed since there was no comments in a while.