Bug 47733 - Sprite limit in CocosSharp game on iOS
Summary: Sprite limit in CocosSharp game on iOS
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-23 15:25 UTC by interactivegames
Modified: 2017-08-29 18:13 UTC (History)
7 users (show)

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

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 or GitHub 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 NORESPONSE

Description interactivegames 2016-11-23 15:25:50 UTC
We have a game running in a CocosSharpView that works fine in Android, but on iOS it crashes with the following exception:

System.ArgumentException: Destination array is not long enough to copy all the items in the collection. Check array index and length.

It seems to happen on iOS when we have too many sprites added to the scene at once. We did a separate test and found that it would throw the same exception when we added 256 sprites to the scene, but not when adding 255 sprites to the scene.

The full error is below:

Unhandled Exception:

System.ArgumentException: Destination array is not long enough to copy all the items in the collection. Check array index and length.

2016-11-23 09:00:44.436 <PROJECT_NAME>iOS[303:69817] 
Unhandled Exception:
0   <PROJECT_NAME>iOS                 0x000faf4b setup_stack_trace + 134
1   <PROJECT_NAME>iOS                 0x000f98c9 mono_handle_exception_internal + 1806
2   <PROJECT_NAME>iOS                 0x000f91b7 mono_handle_exception + 30
3   <PROJECT_NAME>iOS                 0x000f2673 mono_arm_throw_exception + 130
4   <PROJECT_NAME>iOS                 0x0055366c throw_exception + 64
at System.Collections.Generic.Dictionary`2/KeyCollection<TKey_REF, TValue_REF>.CopyTo (TKey_REF[],int) <0x00084>
at CocosSharp.CCScheduler.Update (single) <IL 0x00135, 0x009b8>
at CocosSharp.CCGameView.Update (Microsoft.Xna.Framework.GameTime) <IL 0x00043, 0x002d8>
at CocosSharp.CCGameView.Tick () <IL 0x000e4, 0x006fc>
at CocosSharp.CCGameView.OnUpdateFrame (OpenTK.FrameEventArgs) <IL 0x00008, 0x000a4>
at CocosSharp.CCGameView.RunIteration (Foundation.NSTimer) <IL 0x0000a, 0x000d8>
at Foundation.NSTimerActionDispatcher.Fire (Foundation.NSTimer) 
[0x00000] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/src/Foundation/NSAction.cs:108
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0x00100>
13  <PROJECT_NAME>iOS                 0x001035f5 mono_jit_runtime_invoke + 1652
14  <PROJECT_NAME>iOS                 0x0014c7a5 do_runtime_invoke + 78
15  <PROJECT_NAME>iOS                 0x0014c73b mono_runtime_invoke + 138
16  <PROJECT_NAME>iOS                 0x02112e57 _ZL30native_to_managed_trampoline_8P11objc_objectP13objc_selectorPP11_MonoMethodP7NSTimerPKcS9_S9_ + 348
17  <PROJECT_NAME>iOS                 0x02112cf7 -[__Xamarin_NSTimerActionDispatcher xamarinFireSelector:] + 80
18  Foundation                          0x1f9c84b9 __NSFireTimer + 62
19  CoreFoundation                      0x1f05f357 <redacted> + 14
20  CoreFoundation                      0x1f05f029 <redacted> + 896
21  CoreFoundation                      0x1f05e9e1 <redacted> + 220
22  CoreFoundation                      0x1f
05ccc5 <redacted> + 1364
23  CoreFoundation                      0x1efac073 CFRunLoopRunSpecific + 486
24  CoreFoundation                      0x1efabe81 CFRunLoopRunInMode + 104
25  GraphicsServices                    0x20758bfd GSEventRunModal + 156
26  UIKit                               0x2416682f <redacted> + 574
27  UIKit                               0x24160f61 UIApplicationMain + 150
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00110>
at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at <PROJECT_NAME>.iOS.Application.Main (string[]) [0x00001] in c:\Xamarin Projects\<PROJECT_NAME>\<PROJECT_NAME>\<PROJECT_NAME>.iOS\Main.cs:17
at (wrapper runtime-invoke) object.runtime_invoke_dyna
mic (intptr,intptr,intptr,intptr) <0x00100>
33  <PROJECT_NAME>iOS                 0x001035f5 mono_jit_runtime_invoke + 1652
34  <PROJECT_NAME>iOS                 0x0014c7a5 do_runtime_invoke + 78
35  <PROJECT_NAME>iOS                 0x0014dfbd mono_runtime_exec_main + 608
36  <PROJECT_NAME>iOS                 0x0014dcab mono_runtime_run_main + 630
37  <PROJECT_NAME>iOS                 0x000f1fdf mono_jit_exec + 162
38  <PROJECT_NAME>iOS                 0x001c2274 xamarin_main + 2508
39  <PROJECT_NAME>iOS                 0x0212fadb main + 112
40  libdyld.dylib                       0x1e77650b <redacted> + 2
2016-11-23 09:00:44.453 <PROJECT_NAME>iOS[303:69817] Unhandled managed exception:
Destination array is not long enough to copy all the items in the collection. Check array index and length. (System.ArgumentException)
  at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) [0x00000] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:72 
  at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].CopyTo (TKey[] array, System.Int32 index) [0x00039] in <cc958e60dbab45a48329f27123804526>:0 
  at CocosSharp.CCScheduler.Update (System.Single dt) [0x0012f] in <d22a66e3b335442dbe64fcd8fba4589f>:0 
  at CocosSharp.CCGameView.Update (Microsoft.Xna.Framework.GameTime time) [0x00042] in <d22a66e3b335442dbe64fcd8fba4589f>:0 
  at CocosSharp.CCGameView.Tick () [0x000dd] in <d22a66e3b335442dbe64fcd8fba4589f>:0 
  at CocosSharp.CCGameView.OnUp
dateFrame (OpenTK.FrameEventArgs e) [0x00007] in <d22a66e3b335442dbe64fcd8fba4589f>:0 
  at CocosSharp.CCGameView.RunIteration (Foundation.NSTimer timer) [0x00008] in <d22a66e3b335442dbe64fcd8fba4589f>:0 
  at Foundation.NSTimerActionDispatcher.Fire (Foundation.NSTimer timer) [0x00000] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/src/Foundation/NSAction.cs:108 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at <PROJECT_NAME>.iOS.Application.Main (System.String[] args) [0x00001] in c:\Xamarin Projects\mi_cros
sword_app\<PROJECT_NAME>\<PROJECT_NAME>.iOS\Main.cs:17 
2016-11-23 09:00:44.455 <PROJECT_NAME>iOS[303:69817] critical: Stacktrace:

2016-11-23 09:00:44.455 <PROJECT_NAME>iOS[303:69817] critical: 
Native stacktrace:
2016-11-23 09:00:44.702 <PROJECT_NAME>iOS[303:69817] critical: 	0   <PROJECT_NAME>iOS                 0x000fa071 mono_handle_native_sigsegv + 240
2016-11-23 09:00:44.702 <PROJECT_NAME>iOS[303:69817] critical: 	1   libsystem_platform.dylib            0x1e8fc26d _sigtramp + 24
2016-11-23 09:00:44.702 <PROJECT_NAME>iOS[303:69817] critical: 	2   libsystem_pthread.dylib             0x1e90217b pthread_kill + 62
2016-11-23 09:00:44.702 <PROJECT_NAME>iOS[303:69817] critical: 	3   libsystem_c.dylib                   0x1e7df309 abort + 108
2016-11-23 09:00:44.703 <PROJECT_NAME>iOS[303:69817] critical: 	4   <PROJECT_NAME>iOS                 0x001b5448 _ZL20print_all_exceptionsP10MonoObject + 0
2016-11-23 09:00:44.703 <PROJECT_NAME>iOS[303:69817] critical: 	5   <PROJECT_NAME>iOS                 0x000fa6a7 mono_invoke_unhandled_exception_hook + 74
2016-11-23 09:00:44.703 <PROJECT_NAME>iOS[303:69817] critical: 	6   <PROJECT_NAME>iOS                 0x000f9ddb mono_handle_exception_internal + 3104
2016-11-23 09:00:44.703 <PROJECT_NAME>iOS[303:69817] critical: 	7   <PROJECT_NAME>iOS                 0x000f91b7 mono_handle_exception + 30
2016-11-23 09:00:44.703 <PROJECT_NAME>iOS[303:69817] critical: 	8   <PROJECT_NAME>iOS                 0x000f2673 mono_arm_throw_exception + 130
2016-11-23 09:00:44.703 <PROJECT_NAME>iOS[303:69817] critical: 	9   <PROJECT_NAME>iOS                 0x0055366c throw_exception + 64
2016-11-23 09:00:44.704 <PROJECT_NAME>iOS[303:69817] critical: 	10  <PROJECT_NAME>iOS                 0x002d0a44 System_Collections_Generic_Dictionary_2_KeyCollection_TKey_REF_TValue_REF_CopyTo_TKey_REF___int + 132
2016-11-23 09:00:44.704 <PROJECT_NAME>iOS[303:69817] critical: 	11  <PROJECT_NAME>iOS                 0x01a3c47c CocosSharp_CCScheduler_Update_single + 2488
2016-11-23 09:00:44.704 <PROJECT_NAME>iOS[303:69817] critical: 	12  <PROJECT_NAME>iOS                 0x01832a6c CocosSharp_CCGameView_Update_Microsoft_Xna_Framework_GameTime + 728
2016-11-23 09:00:44.704 <PROJECT_NAME>iOS[303:69817] critical: 	13  <PROJECT_NAME>iOS                 0x018325cc CocosSharp_CCGameView_Tick + 1788
2016-11-23 09:00:44.704 <PROJECT_NAME>iOS[303:69817] critical: 	14  <PROJECT_NAME>iOS                 0x01835fc8 CocosSharp_CCGameView_OnUpdateFrame_OpenTK_FrameEventArgs + 164
2016-11-23 09:00:44.705 <PROJECT_NAME>iOS[303:69817] critical: 	15  <PROJECT_NAME>iOS                 0x01835a3c CocosSharp_CCGameView_RunIteration_Foundation_NSTimer + 216
2016-11-23 09:00:44.705 <PROJECT_NAME>iOS[303:69817] critical: 	16  <PROJECT_NAME>iOS                 0x00ec7b40 Foundation_NSTimerActionDispatcher_Fire_Foundation_NSTimer + 52
2016-11-23 09:00:44.705 <PROJECT_NAME>iOS[303:69817] critical: 	17  <PROJECT_NAME>iOS                 0x0051eb5c wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 256
2016-11-23 09:00:44.705 <PROJECT_NAME>iOS[303:69817] critical: 	18  <PROJECT_NAME>iOS                 0x001035f5 mono_jit_runtime_invoke + 1652
2016-11-23 09:00:44.706 <PROJECT_NAME>iOS[303:69817] critical: 	19  <PROJECT_NAME>iOS                 0x0014c7a5 do_runtime_invoke + 78
2016-11-23 09:00:44.706 <PROJECT_NAME>iOS[303:69817] critical: 	20  <PROJECT_NAME>iOS                 0x0014c73b mono_runtime_invoke + 138
2016-11-23 09:00:44.706 <PROJECT_NAME>iOS[303:69817] critical: 	21  <PROJECT_NAME>iOS                 0x02112e57 _ZL30native_to_managed_trampoline_8P11objc_objectP13objc_selectorPP11_MonoMethodP7NSTimerPKcS9_S9_ + 348
2016-11-23 09:00:44.706 <PROJECT_NAME>iOS[303:69817] critical: 	22  <PROJECT_NAME>iOS                 0x02112cf7 -[__Xamarin_NSTimerActionDispatcher xamarinFireSelector:] + 80
2016-11-23 09:00:44.706 <PROJECT_NAME>iOS[303:69817] critical: 	23  Foundation                          0x1f9c84b9 __NSFireTimer + 62
2016-11-23 09:00:44.706 <PROJECT_NAME>iOS[303:69817] critical: 	24  CoreFoundation                      0x1f05f357 <redacted> + 14
2016-11-23 09:00:44.707 <PROJECT_NAME>iOS[303:69817] critical: 	25  CoreFoundation                      0x1f05f029 <redacted> + 896
2016-11-23 09:00:44.707 <PROJECT_NAME>iOS[303:69817] critical: 	26  CoreFoundation                      0x1f05e9e1 <redacted> + 220
2016-11-23 09:00:44.707 <PROJECT_NAME>iOS[303:69817] critical: 	27  CoreFoundation                      0x1f05ccc5 <redacted> + 1364
2016-11-23 09:00:44.707 <PROJECT_NAME>iOS[303:69817] critical: 	28  CoreFoundation                      0x1efac073 CFRunLoopRunSpecific + 486
2016-11-23 09:00:44.707 <PROJECT_NAME>iOS[303:69817] critical: 	29  CoreFoundation                      0x1efabe81 CFRunLoopRunInMode + 104
2016-11-23 09:00:44.708 <PROJECT_NAME>iOS[303:69817] critical: 	30  GraphicsServices                    0x20758bfd GSEventRunModal + 156
2016-11-23 09:00:44.708 <PROJECT_NAME>iOS[303:69817] critical: 	31  UIKit                               0x2416682f <redacted> + 574
2016-11-23 09:00:44.708 <PROJECT_NAME>iOS[303:69817] critical: 	32  UIKit                               0x24160f61 UIApplicationMain + 150
2016-11-23 09:00:44.708 <PROJECT_NAME>iOS[303:69817] critical: 	33  <PROJECT_NAME>iOS                 0x00f219ac wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 272
2016-11-23 09:00:44.708 <PROJECT_NAME>iOS[303:69817] critical: 	34  <PROJECT_NAME>iOS                 0x00e8bd68 UIKit_UIApplication_Main_string___intptr_intptr + 52
2016-11-23 09:00:44.708 <PROJECT_NAME>iOS[303:69817] critical: 	35  <PROJECT_NAME>iOS                 0x00e8bd28 UIKit_UIApplication_Main_string___string_string + 204
2016-11-23 09:00:44.709 <PROJECT_NAME>iOS[303:69817] critical: 	36  <PROJECT_NAME>iOS                 0x001c2ed8 <PROJECT_NAME>_iOS_Application_Main_string__ + 152
2016-11-23 09:00:44.709 <PROJECT_NAME>iOS[303:69817] critical: 	37  <PROJECT_NAME>iOS                 0x0051eb5c wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 256
2016-11-23 09:00:44.709 <PROJECT_NAME>iOS[303:69817] critical: 	38  <PROJECT_NAME>iOS                 0x001035f5 mono_jit_runtime_invoke + 1652
2016-11-23 09:00:44.709 <PROJECT_NAME>iOS[303:69817] critical: 	39  <PROJECT_NAME>iOS                 0x0014c7a5 do_runtime_invoke + 78
2016-11-23 09:00:44.709 <PROJECT_NAME>iOS[303:69817] critical: 	40  <PROJECT_NAME>iOS                 0x0014dfbd mono_runtime_exec_main + 608
2016-11-23 09:00:44.710 <PROJECT_NAME>iOS[303:69817] critical: 	41  <PROJECT_NAME>iOS                 0x0014dcab mono_runtime_run_main + 630
2016-11-23 09:00:44.710 <PROJECT_NAME>iOS[303:69817] critical: 	42  <PROJECT_NAME>iOS                 0x000f1fdf mono_jit_exec + 162
2016-11-23 09:00:44.710 <PROJECT_NAME>iOS[303:69817] critical: 	43  <PROJECT_NAME>iOS                 0x001c2274 xamarin_main + 2508
2016-11-23 09:00:44.710 <PROJECT_NAME>iOS[303:69817] critical: 	44  <PROJECT_NAME>iOS                 0x0212fadb main + 112
2016-11-23 09:00:44.710 <PROJECT_NAME>iOS[303:69817] critical: 	45  libdyld.dylib                       0x1e77650b <redacted> + 2
2016-11-23 09:00:44.710 <PROJECT_NAME>iOS[303:69817] critical: 
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
The app has been terminated.
Comment 1 Alexander Köplinger [MSFT] 2017-05-31 16:38:26 UTC
Moving to Xamarin.iOS
Comment 2 Jon Douglas [MSFT] 2017-07-24 20:57:09 UTC
To help investigate this issue, do you perhaps have a sample project demonstrating this behavior with > 255 sprites? This will help our engineers pinpoint what's going on whether that's in CocosSharp or Xamarin.iOS. Based on the stack provided it looks CocosSharp based, but we will need to confirm this behavior. Please upload a sample project demonstrating this behavior. Please start with a File -> New Project to minimize the test case.

Thank you for the report!
Comment 3 Vincent Dondain [MSFT] 2017-08-29 18:13:44 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!