|
71 | 71 | TRACE_EVENT0("flutter", "IOSSurface::CancelFrame");
|
72 | 72 | FML_CHECK(platform_views_controller_ != nullptr);
|
73 | 73 | platform_views_controller_->CancelFrame();
|
74 |
| - // Committing the current transaction as |BeginFrame| will create a nested |
75 |
| - // CATransaction otherwise. |
76 |
| - [CATransaction commit]; |
| 74 | + if ([[NSThread currentThread] isMainThread]) { |
| 75 | + // Committing the current transaction as |BeginFrame| will create a nested |
| 76 | + // CATransaction otherwise. |
| 77 | + [CATransaction commit]; |
| 78 | + } |
77 | 79 | }
|
78 | 80 |
|
79 | 81 | // |ExternalViewEmbedder|
|
|
84 | 86 | TRACE_EVENT0("flutter", "IOSSurface::BeginFrame");
|
85 | 87 | FML_CHECK(platform_views_controller_ != nullptr);
|
86 | 88 | platform_views_controller_->SetFrameSize(frame_size);
|
87 |
| - [CATransaction begin]; |
| 89 | + if ([[NSThread currentThread] isMainThread]) { |
| 90 | + [CATransaction begin]; |
| 91 | + } |
88 | 92 | }
|
89 | 93 |
|
90 | 94 | // |ExternalViewEmbedder|
|
|
102 | 106 | TRACE_EVENT0("flutter", "IOSSurface::PostPrerollAction");
|
103 | 107 | FML_CHECK(platform_views_controller_ != nullptr);
|
104 | 108 | PostPrerollResult result = platform_views_controller_->PostPrerollAction(raster_thread_merger);
|
105 |
| - if (result == PostPrerollResult::kSkipAndRetryFrame) { |
| 109 | + if (result == PostPrerollResult::kSkipAndRetryFrame && [[NSThread currentThread] isMainThread]) { |
106 | 110 | // Commit the current transaction if the frame is dropped.
|
107 | 111 | [CATransaction commit];
|
108 | 112 | }
|
|
129 | 133 | bool submitted =
|
130 | 134 | platform_views_controller_->SubmitFrame(std::move(context), ios_context_, std::move(frame));
|
131 | 135 |
|
132 |
| - if (submitted) { |
| 136 | + if (submitted && [[NSThread currentThread] isMainThread]) { |
133 | 137 | TRACE_EVENT0("flutter", "IOSSurface::DidSubmitFrame");
|
134 | 138 | [CATransaction commit];
|
135 | 139 | }
|
|
0 commit comments