Skip to content

Commit 82f2933

Browse files
author
Jonah Williams
authored
[CP] Fix pink images when returning from background on iOS (#170846)
Includes: * flutter/flutter#169596 * flutter/flutter#169378 Fix image decode errors on iOS that could occur if a push notification triggered image decoding while the app is backgrounded.
1 parent 6fba244 commit 82f2933

25 files changed

Lines changed: 167 additions & 30 deletions

engine/src/flutter/ci/licenses_golden/excluded_files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
../../../flutter/impeller/renderer/backend/gles/test
191191
../../../flutter/impeller/renderer/backend/gles/unique_handle_gles_unittests.cc
192192
../../../flutter/impeller/renderer/backend/metal/allocator_mtl_unittests.mm
193+
../../../flutter/impeller/renderer/backend/metal/context_mtl_unittests.mm
193194
../../../flutter/impeller/renderer/backend/metal/swapchain_transients_mtl_unittests.mm
194195
../../../flutter/impeller/renderer/backend/metal/texture_mtl_unittests.mm
195196
../../../flutter/impeller/renderer/backend/vulkan/allocator_vk_unittests.cc

engine/src/flutter/impeller/playground/backend/metal/playground_impl_mtl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PlaygroundImplMTL final : public PlaygroundImpl {
3838
std::shared_ptr<ContextMTL> context_;
3939
std::shared_ptr<fml::ConcurrentMessageLoop> concurrent_loop_;
4040
std::shared_ptr<SwapchainTransientsMTL> swapchain_transients_;
41-
std::shared_ptr<const fml::SyncSwitch> is_gpu_disabled_sync_switch_;
41+
std::shared_ptr<fml::SyncSwitch> is_gpu_disabled_sync_switch_;
4242

4343
// |PlaygroundImpl|
4444
std::shared_ptr<Context> GetContext() const override;
@@ -50,6 +50,9 @@ class PlaygroundImplMTL final : public PlaygroundImpl {
5050
std::unique_ptr<Surface> AcquireSurfaceFrame(
5151
std::shared_ptr<Context> context) override;
5252

53+
// |PlaygroundImpl|
54+
void SetGPUDisabled(bool disabled) const override;
55+
5356
PlaygroundImplMTL(const PlaygroundImplMTL&) = delete;
5457

5558
PlaygroundImplMTL& operator=(const PlaygroundImplMTL&) = delete;

engine/src/flutter/impeller/playground/backend/metal/playground_impl_mtl.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,8 @@
138138
return fml::Status();
139139
}
140140

141+
void PlaygroundImplMTL::SetGPUDisabled(bool disabled) const {
142+
is_gpu_disabled_sync_switch_->SetSwitch(disabled);
143+
}
144+
141145
} // namespace impeller

engine/src/flutter/impeller/playground/playground.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,4 +526,8 @@ Playground::VKProcAddressResolver Playground::CreateVKProcAddressResolver()
526526
return impl_->CreateVKProcAddressResolver();
527527
}
528528

529+
void Playground::SetGPUDisabled(bool value) const {
530+
impl_->SetGPUDisabled(value);
531+
}
532+
529533
} // namespace impeller

engine/src/flutter/impeller/playground/playground.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ class Playground {
122122
std::function<void*(void* instance, const char* proc_name)>;
123123
VKProcAddressResolver CreateVKProcAddressResolver() const;
124124

125+
/// @brief Mark the GPU as unavilable.
126+
///
127+
/// Only supported on the Metal backend.
128+
void SetGPUDisabled(bool disabled) const;
129+
125130
protected:
126131
const PlaygroundSwitches switches_;
127132

engine/src/flutter/impeller/playground/playground_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class PlaygroundImpl {
4040

4141
virtual Playground::VKProcAddressResolver CreateVKProcAddressResolver() const;
4242

43+
virtual void SetGPUDisabled(bool disabled) const {}
44+
4345
protected:
4446
const PlaygroundSwitches switches_;
4547

engine/src/flutter/impeller/renderer/backend/gles/command_buffer_gles.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ bool CommandBufferGLES::IsValid() const {
2929
}
3030

3131
// |CommandBuffer|
32-
bool CommandBufferGLES::OnSubmitCommands(CompletionCallback callback) {
32+
bool CommandBufferGLES::OnSubmitCommands(bool block_on_schedule,
33+
CompletionCallback callback) {
3334
const auto result = reactor_->React();
3435
if (callback) {
3536
callback(result ? CommandBuffer::Status::kCompleted

engine/src/flutter/impeller/renderer/backend/gles/command_buffer_gles.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class CommandBufferGLES final : public CommandBuffer {
3232
bool IsValid() const override;
3333

3434
// |CommandBuffer|
35-
bool OnSubmitCommands(CompletionCallback callback) override;
35+
bool OnSubmitCommands(bool block_on_schedule,
36+
CompletionCallback callback) override;
3637

3738
// |CommandBuffer|
3839
void OnWaitUntilCompleted() override;

engine/src/flutter/impeller/renderer/backend/metal/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impeller_component("metal_unittests") {
7272

7373
sources = [
7474
"allocator_mtl_unittests.mm",
75+
"context_mtl_unittests.mm",
7576
"swapchain_transients_mtl_unittests.mm",
7677
"texture_mtl_unittests.mm",
7778
]

engine/src/flutter/impeller/renderer/backend/metal/command_buffer_mtl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class CommandBufferMTL final : public CommandBuffer {
3434
bool IsValid() const override;
3535

3636
// |CommandBuffer|
37-
bool OnSubmitCommands(CompletionCallback callback) override;
37+
bool OnSubmitCommands(bool block_on_schedule,
38+
CompletionCallback callback) override;
3839

3940
// |CommandBuffer|
4041
void OnWaitUntilCompleted() override;

0 commit comments

Comments
 (0)