Browse Source
Fix random NRE inside `Compositor.CommitCore()` callback. (#19173)
* Prevent ContinueWith from scheduling some of rendering callbacks into UI thread. (#19170 fix)
* Add _pendingBatch null check
pull/19207/head
Egor Rudakov
7 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
7 additions and
5 deletions
-
src/Avalonia.Base/Media/MediaContext.Compositor.cs
-
src/Avalonia.Base/Rendering/Composition/CompositingRenderer.cs
-
src/Avalonia.Base/Rendering/Composition/Compositor.cs
|
|
|
@ -31,7 +31,7 @@ partial class MediaContext |
|
|
|
_pendingCompositionBatches[compositor] = commit; |
|
|
|
commit.Processed.ContinueWith(_ => |
|
|
|
_dispatcher.Post(() => CompositionBatchFinished(compositor, commit), DispatcherPriority.Send), |
|
|
|
TaskContinuationOptions.ExecuteSynchronously); |
|
|
|
CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); |
|
|
|
return commit; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Linq; |
|
|
|
using System.Numerics; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Collections; |
|
|
|
using Avalonia.Collections.Pooled; |
|
|
|
@ -187,7 +188,7 @@ internal class CompositingRenderer : IRendererWithCompositor, IHitTester |
|
|
|
{ |
|
|
|
_queuedSceneInvalidation = false; |
|
|
|
SceneInvalidated?.Invoke(this, new SceneInvalidatedEventArgs(_root, new Rect(_root.ClientSize))); |
|
|
|
}, DispatcherPriority.Input), TaskContinuationOptions.ExecuteSynchronously); |
|
|
|
}, DispatcherPriority.Input), CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Animation; |
|
|
|
using Avalonia.Animation.Easings; |
|
|
|
@ -114,7 +115,7 @@ namespace Avalonia.Rendering.Composition |
|
|
|
if (pending != null) |
|
|
|
pending.Processed.ContinueWith( |
|
|
|
_ => Dispatcher.Post(_triggerCommitRequested, DispatcherPriority.Send), |
|
|
|
TaskContinuationOptions.ExecuteSynchronously); |
|
|
|
CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); |
|
|
|
else |
|
|
|
_triggerCommitRequested(); |
|
|
|
} |
|
|
|
@ -202,10 +203,10 @@ namespace Avalonia.Rendering.Composition |
|
|
|
{ |
|
|
|
lock (_pendingBatchLock) |
|
|
|
{ |
|
|
|
if (_pendingBatch.Processed == t) |
|
|
|
if (_pendingBatch?.Processed == t) |
|
|
|
_pendingBatch = null; |
|
|
|
} |
|
|
|
}, TaskContinuationOptions.ExecuteSynchronously); |
|
|
|
}, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); |
|
|
|
_nextCommit = null; |
|
|
|
|
|
|
|
return commit; |
|
|
|
|