Skip to content

Disable debug buttons in profile mode. #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions lib/timeline/timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,29 @@ class TimelineScreen extends Screen {
PButton resumeButton;

@override
void createContent(Framework framework, CoreElement mainDiv) {
void createContent(Framework framework, CoreElement mainDiv) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be a little concerned about making this method Async. I would expect a reasonable contract is that this method is not async.

FrameDetailsUI frameDetailsUI;

final Isolate isolate = await serviceInfo.service
.getIsolate(serviceInfo.isolateManager.selectedIsolate.id);

bool isProfileMode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a FlutterApp object that tracks whether the app is debug mode or not.


// Determine whether we are in profile mode. If evaluate successfully returns
// an InstanceRef, we are in debug mode. If evaluate throws an error, we are
// in profile mode. Expression '1+1' is arbitrary.
// TODO(kenzieschmoll): The VMService should expose the build mode (debug/profile).
try {
final dynamic evaluate = await serviceInfo.service.evaluate(
serviceInfo.isolateManager.selectedIsolate.id,
isolate.rootLib.id,
'1+1',
);
isProfileMode = !(evaluate is InstanceRef);
} catch (e) {
isProfileMode = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exception is thrown? Instead of catching all exceptions verify we got the expected one.

}

pauseButton = new PButton('Pause recording')
..small()
..primary()
Expand All @@ -60,13 +80,17 @@ class TimelineScreen extends Screen {
..disabled = true
..click(_resumeRecording);

final PButton trackWidgetBuildsButton = new PButton('Track widget builds')
..small();
final PButton perfOverlayButton = new PButton('Performance overlay')
..small();
final PButton repaintRainbowButton = new PButton('Repaint rainbow')
..small();
final PButton debugDrawButton = new PButton('Debug draw')..small();
PButton createButton(String text, bool shouldDisableForProfileMode) {
return new PButton(text)
..small()
..disabled = shouldDisableForProfileMode && isProfileMode
..tooltip = isProfileMode ? 'Unavailable on a profile build.' : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better is to create the UI right away with the button disabled and then enable it async when we verify the app is debug mode.

}

final PButton trackWidgetBuildsButton = createButton('Track widget builds', true);
final PButton perfOverlayButton = createButton('Performance overlay', false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be turned on and off by similar logic to VMServiceManager in the Java app instead of triggering based on whether we are in debug or profile mode. That is more robust as potentially flutter will support some or all of these options in profile mode.

final PButton repaintRainbowButton = createButton('Repaint rainbow', true);
final PButton debugDrawButton = createButton('Debug draw', true);

mainDiv.add(<CoreElement>[
createLiveChartArea(),
Expand Down Expand Up @@ -200,7 +224,10 @@ class TimelineScreen extends Screen {
final bool shouldBeRunning = !paused && isCurrentScreen;
final bool isRunning = !timelineFramesBuilder.isPaused;

if (shouldBeRunning && isRunning && !timelineFramesUI.hasStarted()) {
if (shouldBeRunning &&
isRunning &&
timelineFramesUI != null &&
!timelineFramesUI.hasStarted()) {
_startTimeline();
}

Expand Down