Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0c121d3

Browse files
authored
Revert "Use a Pbuffer surface when the onscreen surface is not available for snapshotting on Android (#27141)" (#27607)
This reverts commit a1180b1.
1 parent b678f43 commit 0c121d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+106
-985
lines changed

BUILD.gn

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ group("flutter") {
121121
public_deps += [ "//flutter/testing/scenario_app" ]
122122
}
123123

124-
if (is_android && flutter_runtime_mode == "profile" &&
125-
current_cpu == "arm64") {
126-
public_deps += [ "//flutter/testing/android_background_image" ]
127-
}
128-
129124
# Compile all unittests targets if enabled.
130125
if (enable_unittests) {
131126
public_deps += [

ci/firebase_testlab.py

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@
1919

2020

2121
def RunFirebaseTest(apk, results_dir):
22-
# game-loop tests are meant for OpenGL apps.
23-
# This type of test will give the application a handle to a file, and
24-
# we'll write the timeline JSON to that file.
25-
# See https://firebase.google.com/docs/test-lab/android/game-loop
26-
# Pixel 4. As of this commit, this is a highly available device in FTL.
27-
process = subprocess.Popen(
28-
[
29-
'gcloud',
30-
'--project', 'flutter-infra',
31-
'firebase', 'test', 'android', 'run',
32-
'--type', 'game-loop',
33-
'--app', apk,
34-
'--timeout', '2m',
35-
'--results-bucket', bucket,
36-
'--results-dir', results_dir,
37-
'--device', 'model=flame,version=29',
38-
],
39-
stdout=subprocess.PIPE,
40-
stderr=subprocess.STDOUT,
41-
universal_newlines=True,
42-
)
43-
return process
22+
try:
23+
# game-loop tests are meant for OpenGL apps.
24+
# This type of test will give the application a handle to a file, and
25+
# we'll write the timeline JSON to that file.
26+
# See https://firebase.google.com/docs/test-lab/android/game-loop
27+
# Pixel 4. As of this commit, this is a highly available device in FTL.
28+
subprocess.check_output([
29+
'gcloud',
30+
'--project', 'flutter-infra',
31+
'firebase', 'test', 'android', 'run',
32+
'--type', 'game-loop',
33+
'--app', apk,
34+
'--timeout', '2m',
35+
'--results-bucket', bucket,
36+
'--results-dir', results_dir,
37+
'--device', 'model=flame,version=29',
38+
])
39+
except subprocess.CalledProcessError as ex:
40+
print(ex.output)
41+
# Recipe will retry return codes from firebase that indicate an infra
42+
# failure.
43+
sys.exit(ex.returncode)
4444

4545

4646
def CheckLogcat(results_dir):
@@ -87,25 +87,13 @@ def main():
8787
git_revision = subprocess.check_output(
8888
['git', 'rev-parse', 'HEAD'], cwd=script_dir).strip()
8989

90-
results = []
9190
for apk in apks:
9291
results_dir = '%s/%s/%s' % (os.path.basename(apk), git_revision, args.build_id)
93-
process = RunFirebaseTest(apk, results_dir)
94-
results.append((results_dir, process))
95-
96-
for results_dir, process in results:
97-
for line in iter(process.stdout.readline, ""):
98-
print(line.strip())
99-
return_code = process.wait()
100-
if return_code != 0:
101-
print('Firebase test failed ' + returncode)
102-
sys.exit(process.returncode)
103-
104-
print('Checking logcat for %s' % results_dir)
92+
93+
RunFirebaseTest(apk, results_dir)
10594
CheckLogcat(results_dir)
10695
# scenario_app produces a timeline, but the android image test does not.
10796
if 'scenario' in apk:
108-
print('Checking timeline for %s' % results_dir)
10997
CheckTimeline(results_dir)
11098

11199
return 0

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ FILE: ../../../flutter/shell/common/shell_unittests.cc
725725
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.cc
726726
FILE: ../../../flutter/shell/common/skia_event_tracer_impl.h
727727
FILE: ../../../flutter/shell/common/skp_shader_warmup_unittests.cc
728-
FILE: ../../../flutter/shell/common/snapshot_surface_producer.h
729728
FILE: ../../../flutter/shell/common/switches.cc
730729
FILE: ../../../flutter/shell/common/switches.h
731730
FILE: ../../../flutter/shell/common/thread_host.cc
@@ -933,8 +932,6 @@ FILE: ../../../flutter/shell/platform/android/surface/android_surface.cc
933932
FILE: ../../../flutter/shell/platform/android/surface/android_surface.h
934933
FILE: ../../../flutter/shell/platform/android/surface/android_surface_mock.cc
935934
FILE: ../../../flutter/shell/platform/android/surface/android_surface_mock.h
936-
FILE: ../../../flutter/shell/platform/android/surface/snapshot_surface_producer.cc
937-
FILE: ../../../flutter/shell/platform/android/surface/snapshot_surface_producer.h
938935
FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.cc
939936
FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.h
940937
FILE: ../../../flutter/shell/platform/common/accessibility_bridge.cc

shell/common/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ source_set("common") {
8989
"shell_io_manager.h",
9090
"skia_event_tracer_impl.cc",
9191
"skia_event_tracer_impl.h",
92-
"snapshot_surface_producer.h",
9392
"switches.cc",
9493
"switches.h",
9594
"thread_host.cc",

shell/common/platform_view.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void PlatformView::SetViewportMetrics(const ViewportMetrics& metrics) {
6767

6868
void PlatformView::NotifyCreated() {
6969
std::unique_ptr<Surface> surface;
70+
7071
// Threading: We want to use the platform view on the non-platform thread.
7172
// Using the weak pointer is illegal. But, we are going to introduce a latch
7273
// so that the platform view is not collected till the surface is obtained.
@@ -181,9 +182,4 @@ void PlatformView::UpdateAssetResolverByType(
181182
delegate_.UpdateAssetResolverByType(std::move(updated_asset_resolver), type);
182183
}
183184

184-
std::unique_ptr<SnapshotSurfaceProducer>
185-
PlatformView::CreateSnapshotSurfaceProducer() {
186-
return nullptr;
187-
}
188-
189185
} // namespace flutter

shell/common/platform_view.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class PlatformView {
6262
/// Metal, Vulkan) specific. This is usually a sign to the
6363
/// rasterizer to set up and begin rendering to that surface.
6464
///
65-
/// @param[in] surface The surface
65+
/// @param[in] surface The surface
6666
///
6767
virtual void OnPlatformViewCreated(std::unique_ptr<Surface> surface) = 0;
6868

@@ -796,22 +796,6 @@ class PlatformView {
796796
std::unique_ptr<AssetResolver> updated_asset_resolver,
797797
AssetResolver::AssetResolverType type);
798798

799-
//--------------------------------------------------------------------------
800-
/// @brief Creates an object that produces surfaces suitable for raster
801-
/// snapshotting. The rasterizer will request this surface if no
802-
/// on screen surface is currently available when an application
803-
/// requests a snapshot, e.g. if `Scene.toImage` or
804-
/// `Picture.toImage` are called while the application is in the
805-
/// background.
806-
///
807-
/// Not all backends support this kind of surface usage, and the
808-
/// default implementation returns nullptr. Platforms should
809-
/// override this if they can support GPU operations in the
810-
/// background and support GPU resource context usage.
811-
///
812-
virtual std::unique_ptr<SnapshotSurfaceProducer>
813-
CreateSnapshotSurfaceProducer();
814-
815799
protected:
816800
PlatformView::Delegate& delegate_;
817801
const TaskRunners task_runners_;
@@ -820,7 +804,8 @@ class PlatformView {
820804
SkISize size_;
821805
fml::WeakPtrFactory<PlatformView> weak_factory_;
822806

823-
// This is the only method called on the raster task runner.
807+
// Unlike all other methods on the platform view, this is called on the
808+
// raster task runner.
824809
virtual std::unique_ptr<Surface> CreateRenderingSurface();
825810

826811
private:

shell/common/rasterizer.cc

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,11 @@ sk_sp<SkImage> Rasterizer::DoMakeRasterSnapshot(
258258
sk_sp<SkImage> result;
259259
SkImageInfo image_info = SkImageInfo::MakeN32Premul(
260260
size.width(), size.height(), SkColorSpace::MakeSRGB());
261-
262-
std::unique_ptr<Surface> pbuffer_surface;
263-
Surface* snapshot_surface = nullptr;
264-
if (surface_ && surface_->GetContext()) {
265-
snapshot_surface = surface_.get();
266-
} else if (snapshot_surface_producer_) {
267-
pbuffer_surface = snapshot_surface_producer_->CreateSnapshotSurface();
268-
if (pbuffer_surface && pbuffer_surface->GetContext())
269-
snapshot_surface = pbuffer_surface.get();
270-
}
271-
272-
if (!snapshot_surface) {
261+
if (surface_ == nullptr || surface_->GetContext() == nullptr) {
273262
// Raster surface is fine if there is no on screen surface. This might
274263
// happen in case of software rendering.
275-
sk_sp<SkSurface> sk_surface = SkSurface::MakeRaster(image_info);
276-
result = DrawSnapshot(sk_surface, draw_callback);
264+
sk_sp<SkSurface> surface = SkSurface::MakeRaster(image_info);
265+
result = DrawSnapshot(surface, draw_callback);
277266
} else {
278267
delegate_.GetIsGpuDisabledSyncSwitch()->Execute(
279268
fml::SyncSwitch::Handlers()
@@ -282,14 +271,12 @@ sk_sp<SkImage> Rasterizer::DoMakeRasterSnapshot(
282271
result = DrawSnapshot(surface, draw_callback);
283272
})
284273
.SetIfFalse([&] {
285-
FML_DCHECK(snapshot_surface);
286-
auto context_switch =
287-
snapshot_surface->MakeRenderContextCurrent();
274+
auto context_switch = surface_->MakeRenderContextCurrent();
288275
if (!context_switch->GetResult()) {
289276
return;
290277
}
291278

292-
GrRecordingContext* context = snapshot_surface->GetContext();
279+
GrRecordingContext* context = surface_->GetContext();
293280
auto max_size = context->maxRenderTargetSize();
294281
double scale_factor = std::min(
295282
1.0, static_cast<double>(max_size) /
@@ -307,19 +294,19 @@ sk_sp<SkImage> Rasterizer::DoMakeRasterSnapshot(
307294

308295
// When there is an on screen surface, we need a render target
309296
// SkSurface because we want to access texture backed images.
310-
sk_sp<SkSurface> sk_surface =
297+
sk_sp<SkSurface> surface =
311298
SkSurface::MakeRenderTarget(context, // context
312299
SkBudgeted::kNo, // budgeted
313300
image_info // image info
314301
);
315-
if (!sk_surface) {
302+
if (!surface) {
316303
FML_LOG(ERROR)
317304
<< "DoMakeRasterSnapshot can not create GPU render target";
318305
return;
319306
}
320307

321-
sk_surface->getCanvas()->scale(scale_factor, scale_factor);
322-
result = DrawSnapshot(sk_surface, draw_callback);
308+
surface->getCanvas()->scale(scale_factor, scale_factor);
309+
result = DrawSnapshot(surface, draw_callback);
323310
}));
324311
}
325312

@@ -713,11 +700,6 @@ void Rasterizer::SetExternalViewEmbedder(
713700
external_view_embedder_ = view_embedder;
714701
}
715702

716-
void Rasterizer::SetSnapshotSurfaceProducer(
717-
std::unique_ptr<SnapshotSurfaceProducer> producer) {
718-
snapshot_surface_producer_ = std::move(producer);
719-
}
720-
721703
void Rasterizer::FireNextFrameCallbackIfPresent() {
722704
if (!next_frame_callback_) {
723705
return;

shell/common/rasterizer.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "flutter/fml/time/time_point.h"
2525
#include "flutter/lib/ui/snapshot_delegate.h"
2626
#include "flutter/shell/common/pipeline.h"
27-
#include "flutter/shell/common/snapshot_surface_producer.h"
2827

2928
namespace flutter {
3029

@@ -99,7 +98,7 @@ class Rasterizer final : public SnapshotDelegate {
9998
/// currently only created by the shell (which also sets itself up
10099
/// as the rasterizer delegate).
101100
///
102-
/// @param[in] delegate The rasterizer delegate.
101+
/// @param[in] delegate The rasterizer delegate.
103102
///
104103
Rasterizer(Delegate& delegate);
105104

@@ -350,17 +349,6 @@ class Rasterizer final : public SnapshotDelegate {
350349
void SetExternalViewEmbedder(
351350
const std::shared_ptr<ExternalViewEmbedder>& view_embedder);
352351

353-
//----------------------------------------------------------------------------
354-
/// @brief Set the snapshot surface producer. This is done on shell
355-
/// initialization. This is non-null on platforms that support taking
356-
/// GPU accelerated raster snapshots in the background.
357-
///
358-
/// @param[in] producer A surface producer for raster snapshotting when the
359-
/// onscreen surface is not available.
360-
///
361-
void SetSnapshotSurfaceProducer(
362-
std::unique_ptr<SnapshotSurfaceProducer> producer);
363-
364352
//----------------------------------------------------------------------------
365353
/// @brief Returns a pointer to the compositor context used by this
366354
/// rasterizer. This pointer will never be `nullptr`.
@@ -446,7 +434,6 @@ class Rasterizer final : public SnapshotDelegate {
446434
private:
447435
Delegate& delegate_;
448436
std::unique_ptr<Surface> surface_;
449-
std::unique_ptr<SnapshotSurfaceProducer> snapshot_surface_producer_;
450437
std::unique_ptr<flutter::CompositorContext> compositor_context_;
451438
// This is the last successfully rasterized layer tree.
452439
std::unique_ptr<flutter::LayerTree> last_layer_tree_;

shell/common/rasterizer_unittests.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class MockDelegate : public Rasterizer::Delegate {
3030
MOCK_CONST_METHOD0(GetTaskRunners, const TaskRunners&());
3131
MOCK_CONST_METHOD0(GetIsGpuDisabledSyncSwitch,
3232
std::shared_ptr<const fml::SyncSwitch>());
33-
MOCK_METHOD0(CreateSnapshotSurface, std::unique_ptr<Surface>());
3433
};
3534

3635
class MockSurface : public Surface {

shell/common/shell.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,6 @@ bool Shell::Setup(std::unique_ptr<PlatformView> platform_view,
634634
// Set the external view embedder for the rasterizer.
635635
auto view_embedder = platform_view_->CreateExternalViewEmbedder();
636636
rasterizer_->SetExternalViewEmbedder(view_embedder);
637-
rasterizer_->SetSnapshotSurfaceProducer(
638-
platform_view_->CreateSnapshotSurfaceProducer());
639637

640638
// The weak ptr must be generated in the platform thread which owns the unique
641639
// ptr.

0 commit comments

Comments
 (0)