Bug 28352 - Unhandled Key Not Found Exception During 'HandleTweenerUpdated' on iOS and Windows Phone
Summary: Unhandled Key Not Found Exception During 'HandleTweenerUpdated' on iOS and Wi...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-23 22:27 UTC by troywillmot
Modified: 2015-11-30 21:03 UTC (History)
11 users (show)

Tags: AC
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 FIXED

Description troywillmot 2015-03-23 22:27:01 UTC
I am not able to reproduce this consistently (hence no repro attached) but it happens occasionally in my app. I get an intermittent unhandled exception of type System.Collections.Generic.KeyNotFoundException with the following stack trace.

   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Xamarin.Forms.AnimationExtensions.HandleTweenerUpdated(Object o, EventArgs args)
   at Xamarin.Forms.Tweener.<Start>b__0(Int64 step)
   at Xamarin.Forms.Ticker.SendSignals(Int32 timestep)
   at Xamarin.Forms.WinPhoneTicker.<.ctor>b__1(Object sender, EventArgs args)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


I do have a 'looping animation' running in the background. It's possible the form is being popped from the stack while the animation is running and that is causing it? Animation code is something along the lines of;

var t = DoAnimation();

private async Task DoAnimation()
{
  await LogoImage.FadeTo(0.1, 1000, Easing.Linear);
  if (!connected)
    await LogoImage.FadeTo(1.0, 2000, Easing.Linear);

  if (!connected)
    DoAnimation()
}
Comment 1 Andy 2015-04-28 19:28:33 UTC
This happens to me on iOS as well. The issue is that the iOS code for Xamarin forms is not checking for existence in the AnimationExtensions.animations dictionary from which it is retrieving. The fix is quite simple if you just use TryGetValue when fetching that animation info.

This crash is possible in Xamarin.Forms.Core  AnimationExtensions.HandlewTweenerUpdated and AnimationExtensions.HandlewTweenerFinished.

Here is a crash report stack that we get regularly Xamarin.Forms 1.4.1x 
  at System.Collections.Generic.Dictionary`2[System.String,Xamarin.Forms.AnimationExtensions+Info].get_Item (System.String key) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.AnimationExtensions.HandleTweenerUpdated (System.Object o, System.EventArgs args) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Tweener.<Start>b__0 (Int64 step) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Ticker.SendSignals (Int32 timestep) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.CADisplayLinkTicker.<EnableTimer>b__0 () [0x00000] in <filename unknown>:0 
  at Foundation.NSActionDispatcher.Apply () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00000] in <filename unknown>:0 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0
Comment 2 troywillmot 2015-04-29 02:34:20 UTC
I think this most often happens when there is an animation running on a page and you navigate to another (either back, or pushasync or pushmodalasync).
Comment 3 Andy 2015-04-29 12:28:12 UTC
Yes that does tend to be when it happens. But, if you want a button to tween, such as a back button, there is really no avoiding this issue.
Comment 4 Andy 2015-04-30 13:58:37 UTC
Can the Xamarin Team please give us an acknowledgement of this issue?
Comment 5 Jason Smith [MSFT] 2015-05-18 16:40:45 UTC
Thank you I see the issue
Comment 6 Andy 2015-06-11 12:16:43 UTC
What is the estimated Forms version that will have a fix for this?
Comment 7 Rui Marinho 2015-07-15 07:36:43 UTC
Should be fixed  in 1.4.4-pre2
Comment 8 troywillmot 2015-07-15 08:00:54 UTC
Thank you, excellent work.
Comment 9 Andy 2015-08-11 14:01:33 UTC
This crash is still happening. I see the same dictionary read without checking the key in Xamarin Forms 1.4.4.6392 AnimationExtensions.HandleTweenerUpdated
Comment 12 Andy 2015-11-30 19:50:52 UTC
This is fixed in Xamarin.Forms 1.5.1.6471   Yay!
Comment 13 troywillmot 2015-11-30 20:03:01 UTC
It's taken a while, but I am happy to see it fixed. Thank you very much.