0

Xamarinフォームで、カスタムアニメーションやその他のアニメーションの連続数や同時アニメーション数について、何らかの制限がありますか?Xamarin Forms Animationオーバーロードバグ?

protected void ShowAlertMessage(string message) 
    { 
     lblAlertMessage.Text = message; 

     this.AbortAnimation("AlertShow"); // crash happens with and without this... 

     new Animation { 
      { 0, 0.1, new Animation(v => AlertView.Opacity = v, 0.0, 1.0) }, 
      { 0.1, 0.6, new Animation(v => AlertView.Opacity = v, 1.0, 1.0) }, 
      { 0.6, 1.0, new Animation(v => AlertView.Opacity = v, 1.0, 0) }, 
     }.Commit(this, "AlertShow", length: 3000); 
    } 

アニメーション自体は正常に動作します:

は、ここで私が扱ってるかの簡単な例です。 AlertViewビューはフェードインし、持続してからフェードアウトします。私はアニメーションが完了した後、再び関数を呼び出し、それは正常に動作します。私は、AlertViewが実行中のアニメーションの途中にある間に関数を再度呼びます。それでもアニメーションは再開します。しかし、ShowAlertMessage()をすばやく高速に呼び出すボタンをマッシュした場合、iPhoneエミュレータは次のスタックトレースでクラッシュします(私はすべてを含んでいます...新しいスレッドが発生したときに何かが起きているようですカバーの下で開始...):

2017-06-24 12:20:37.595 RootTuner.iOS[19386:887418] critical: Stacktrace: 

2017-06-24 12:20:37.596 RootTuner.iOS[19386:887418] critical: at <unknown> <0xffffffff> 
2017-06-24 12:20:37.596 RootTuner.iOS[19386:887418] critical: at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_float (intptr,intptr,single) [0x0000b] in <58a9bd8a3cbb4d0092bc0a767ff66c0f>:0 
2017-06-24 12:20:37.597 RootTuner.iOS[19386:887418] critical: at CoreAnimation.CALayer.set_Opacity (single) [0x0000b] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/build/ios/native/CoreAnimation/CALayer.g.cs:1714 
2017-06-24 12:20:37.597 RootTuner.iOS[19386:887418] critical: at Xamarin.Forms.Platform.iOS.VisualElementTracker/<>c__DisplayClass23_0.<OnUpdateNativeControl>b__0() [0x0015a] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:178 
2017-06-24 12:20:37.597 RootTuner.iOS[19386:887418] critical: at Xamarin.Forms.Platform.iOS.CADisplayLinkTicker.StartThread() [0x00025] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\CADisplayLinkTicker.cs:60 
2017-06-24 12:20:37.598 RootTuner.iOS[19386:887418] critical: at System.Threading.ThreadHelper.ThreadStart_Context (object) [0x00014] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68 
2017-06-24 12:20:37.598 RootTuner.iOS[19386:887418] critical: at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957 
2017-06-24 12:20:37.598 RootTuner.iOS[19386:887418] critical: at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904 
2017-06-24 12:20:37.598 RootTuner.iOS[19386:887418] critical: at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) [0x0002b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:893 
2017-06-24 12:20:37.599 RootTuner.iOS[19386:887418] critical: at System.Threading.ThreadHelper.ThreadStart() [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105 
2017-06-24 12:20:37.599 RootTuner.iOS[19386:887418] critical: at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x0004f] in <2f4074c3120b4d80802e10af84b67d41>:0 
2017-06-24 12:20:37.599 RootTuner.iOS[19386:887418] critical: 
Native stacktrace: 

2017-06-24 12:20:37.606 RootTuner.iOS[19386:887418] critical: 0 RootTuner.iOS      0x000000010fdfc501 mono_handle_native_crash + 257 
2017-06-24 12:20:37.607 RootTuner.iOS[19386:887418] critical: 1 RootTuner.iOS      0x000000010fe095d0 mono_sigsegv_signal_handler + 288 
2017-06-24 12:20:37.607 RootTuner.iOS[19386:887418] critical: 2 libsystem_platform.dylib   0x000000011bbfbbba _sigtramp + 26 
2017-06-24 12:20:37.607 RootTuner.iOS[19386:887418] critical: 3 ???         0x0000000000000000 0x0 + 0 
2017-06-24 12:20:37.607 RootTuner.iOS[19386:887418] critical: 4 QuartzCore       0x000000011dc0a9ab _ZL18CAAnimation_setterP11CAAnimationj12_CAValueTypePKv + 169 
2017-06-24 12:20:37.608 RootTuner.iOS[19386:887418] critical: 5 QuartzCore       0x000000011dc03d5a -[CAAnimation setDelegate:] + 30 
2017-06-24 12:20:37.608 RootTuner.iOS[19386:887418] critical: 6 UIKit        0x0000000114057c39 -[UIViewAnimationState setAnimationAttributes:correctZeroDuration:skipDelegateAssignment:customCurve:] + 1094 
2017-06-24 12:20:37.609 RootTuner.iOS[19386:887418] critical: 7 UIKit        0x0000000114054475 -[UIViewAnimationState animationForLayer:forKey:forView:] + 1195 
2017-06-24 12:20:37.609 RootTuner.iOS[19386:887418] critical: 8 UIKit        0x0000000114055178 -[UIViewAnimationState actionForLayer:forKey:forView:] + 99 
2017-06-24 12:20:37.609 RootTuner.iOS[19386:887418] critical: 9 UIKit        0x000000011408052e +[UIView(Animation) _defaultUIViewActionForLayer:forKey:] + 111 
2017-06-24 12:20:37.609 RootTuner.iOS[19386:887418] critical: 10 UIKit        0x000000011485e8ec -[UIView(UIKitManual) actionForLayer:forKey:] + 119 
2017-06-24 12:20:37.610 RootTuner.iOS[19386:887418] critical: 11 QuartzCore       0x000000011dbda4bc -[CALayer actionForKey:] + 437 
2017-06-24 12:20:37.610 RootTuner.iOS[19386:887418] critical: 12 QuartzCore       0x000000011dbd5ade _ZL12actionForKeyP7CALayerPN2CA11TransactionEP8NSString + 76 
2017-06-24 12:20:37.610 RootTuner.iOS[19386:887418] critical: 13 QuartzCore       0x000000011dbd5a6c _ZN2CA5Layer12begin_changeEPNS_11TransactionEjRP11objc_object + 140 
2017-06-24 12:20:37.611 RootTuner.iOS[19386:887418] critical: 14 QuartzCore       0x000000011dbd5e04 _ZN2CA5Layer6setterEj12_CAValueTypePKv + 164 
2017-06-24 12:20:37.611 RootTuner.iOS[19386:887418] critical: 15 QuartzCore       0x000000011dbe1351 -[CALayer setOpacity:] + 43 
2017-06-24 12:20:37.611 RootTuner.iOS[19386:887418] critical: 16 RootTuner.iOS      0x000000010ffbe429 xamarin_dyn_objc_msgSend + 217 
2017-06-24 12:20:37.611 RootTuner.iOS[19386:887418] critical: 17 ???         0x00000001351767f4 0x0 + 5185693684 
2017-06-24 12:20:37.611 RootTuner.iOS[19386:887418] critical: 18 ???         0x00000001357292f4 0x0 + 5191668468 
2017-06-24 12:20:37.611 RootTuner.iOS[19386:887418] critical: 19 ???         0x000000013572747c 0x0 + 5191660668 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 20 RootTuner.iOS      0x000000010fe0c585 mono_jit_runtime_invoke + 1301 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 21 RootTuner.iOS      0x000000010fec6b88 do_runtime_invoke + 88 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 22 RootTuner.iOS      0x000000010ff0d41a start_wrapper + 538 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 23 RootTuner.iOS      0x000000010ff91fed inner_start_thread + 189 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 24 libsystem_pthread.dylib    0x000000011bc0daab _pthread_body + 180 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 25 libsystem_pthread.dylib    0x000000011bc0d9f7 _pthread_body + 0 
2017-06-24 12:20:37.612 RootTuner.iOS[19386:887418] critical: 26 libsystem_pthread.dylib    0x000000011bc0d1fd thread_start + 13 
2017-06-24 12:20:37.613 RootTuner.iOS[19386:887418] critical: 
================================================================= 
Got a SIGSEGV while executing native code. This usually indicates 
a fatal error in the mono runtime or one of the native libraries 
used by your application. 
================================================================= 

私は間違って何をしていますか?これは、単純な.FadeTo()および.ScaleTo()メソッドを使用して他の状況で同じことを行います。アニメーションは機能しますが、あまりにも多くの場合、システムがクラッシュします。

私は、iOS用にVisual Studio for Mac(Community)7.0.1コンパイルを使用しています。より多くの仕様が必要な場合は教えてください。アニメーション「ベストプラクティス」が欠けていることを期待しています。

答えて

0

私は2つの保護手段でこれを管理しました。

最初のものはロック私のアニメーションと、あなたの要件に応じて、1つが実行中にすべてのアニメーションを終了します。たとえば:

private bool isAnimating = false; 


     private bool isAnimating = false; 
     private object myObject = new object(); 
     private void RunAnimation() 
     { 
      if (isAnimating) return; 
      lock (myObject) 
      { 
       isAnimating = true; 
       try 
       { 
        //my animation 
       } 
       finally 
       { 
        isAnimating = false; 
       } 
      } 

     } 

第二のセーフガード私はアニメーションを使用する場合キャッチにすべての例外で、フォールバック状態を提供(アイテムを可視または例えば隠されている)があり

private bool isAnimating = false; 
private object myObject = new object(); 
private void RunAnimation() 
{ 
    if (isAnimating) return; 
    lock (myObject) 
    { 
     isAnimating = true; 
     try 
     { 
      //my animation 
     } 
     catch (Exception) 
     { 
      //set opacity = 1, visible = true.... 
     } 
     finally 
     { 
      isAnimating = false; 
     } 
    } 
} 

あなたは

を行きます
+0

こんにちはダニエル - 応答ありがとう!私はあなたの提案を試み、すべてのアニメーションをロックし、潜在的な例外をキャッチしましたが、残念ながらそれはまだクラッシュします。 try/catch/finallyブロックはシステムエラーを捕捉しないため、アニメーションの内部動作を処理しながらiOSフードの下でクラッシュします。 - あなたの提案に関する質問 - 現在のアニメーションが終了するまで、より多くのアニメーションが起こらないように(isAnimating)条件が設定されている場合、同時に複数のアニメーションをどのように扱いますか? –

+0

私は別のビューでそれを試しました。同じやり方 - 何度もアニメーションを再開した後にクラッシュすることがあります(中断の有無にかかわらず)。私が最後に試したとき、私はそれが墜落する前に100回以上アニメーションを打つ。それは非常に予測不可能です。 「ネイティブコードを実行しているときにSIGSEGVを取得するたびに、これは通常、モノラルランタイムまたはアプリケーションで使用されるネイティブライブラリの致命的なエラーを示しています。私は完全なstacktraceを含めるために私の元の投稿を編集しています。 –

+0

FadeToメソッドを使用して、不透明度をアニメーション化することができます。多分あなたの問題を解決するでしょう。 – Daniel