-
Notifications
You must be signed in to change notification settings - Fork 344
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,29 @@ class TimelineScreen extends Screen { | |
PButton resumeButton; | ||
|
||
@override | ||
void createContent(Framework framework, CoreElement mainDiv) { | ||
void createContent(Framework framework, CoreElement mainDiv) async { | ||
FrameDetailsUI frameDetailsUI; | ||
|
||
final Isolate isolate = await serviceInfo.service | ||
.getIsolate(serviceInfo.isolateManager.selectedIsolate.id); | ||
|
||
bool isProfileMode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
@@ -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.' : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(), | ||
|
@@ -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(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
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.