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

Commit e868475

Browse files
author
Kaushik Iska
committed
enable profiler for debug and profile modes
1 parent f582be2 commit e868475

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

shell/platform/darwin/ios/framework/Source/FlutterEngine.mm

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,19 @@ - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI {
452452
// initialized.
453453
fml::MessageLoop::EnsureInitializedForCurrentThread();
454454

455-
// TODO (kaushikiska): enable Profiler thread only in debug configurations.
455+
flutter::ThreadHost::Type threadHostType = flutter::ThreadHost::Type::UI |
456+
flutter::ThreadHost::Type::GPU |
457+
flutter::ThreadHost::Type::IO;
458+
bool profilerEnabled = false;
459+
#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG) || \
460+
(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_PROFILE)
461+
profilerEnabled = true;
462+
#endif
463+
if (profilerEnabled) {
464+
threadHostType = threadHostType | flutter::ThreadHost::Type::Profiler;
465+
}
456466
_threadHost = {threadLabel.UTF8String, // label
457-
flutter::ThreadHost::Type::UI | flutter::ThreadHost::Type::GPU |
458-
flutter::ThreadHost::Type::IO | flutter::ThreadHost::Type::Profiler};
467+
threadHostType};
459468

460469
// Lambda captures by pointers to ObjC objects are fine here because the
461470
// create call is
@@ -471,7 +480,9 @@ - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI {
471480
return std::make_unique<flutter::Rasterizer>(shell, shell.GetTaskRunners());
472481
};
473482

474-
[self startProfiler];
483+
if (profilerEnabled) {
484+
[self startProfiler];
485+
}
475486

476487
if (flutter::IsIosEmbeddedViewsPreviewEnabled()) {
477488
// Embedded views requires the gpu and the platform views to be the same.

0 commit comments

Comments
 (0)