Skip to content

Show notification on error with deep link - #5207

Merged
helin24 merged 4 commits into
flutter:masterfrom
helin24:deep-link
Jan 26, 2021
Merged

helin24 merged 4 commits into
flutter:masterfrom
helin24:deep-link

Conversation

@helin24

@helin24 helin24 commented Jan 25, 2021 •

Copy link
Copy Markdown
Member

When an app throws a render overflow error and sends a URL with a deep link to DevTools, we want to parse the widget ID and open in the embedded DevTools window (if the user has enabled this).

Jan-25-2021 15-36-02

I think we were under the impression that navigating to the same URL but with one param changed should not cause a full page refresh, but I haven't found a way to avoid this.

Fixes #5198

Comment on lines +59 to +66
final String searchFor = "inspectorRef=";
final String[] split = url.split("&");
for (String part : split) {
if (part.startsWith(searchFor)) {
return part.substring(searchFor.length());
}
}
return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

instead of doing a string search, should we do URI parsing instead and then grab the query param value at 'inspectorRef'?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Weirdly I can't seem to get a query string from the URL. e.g.

final URI uri = new URI(urlString);
final String[] paramPairs = uri.getQuery() // this is null

maybe because of the # after the port? I'm not sure. Certainly it would be nicer to use more standard parsing, if anyone has suggestions on this.

return;
}

if (StringUtil.equals("DevToolsDeepLinkProperty", property.getType()) && FlutterSettings.getInstance().isEnableEmbeddedBrowsers()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

when we see a DevToolsDeepLinkProperty does this early return guarantee that we don't show the deep link url in the intellij console?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, the early return skips printing in the console. I could add a short description like "Click on notification to inspect widget" or something like that.

final Notification notification = new Notification(
FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID,
"Inspect this widget",
"Click below to inspect this exception-causing widget in Flutter DevTools",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@csells @InMatrix for input on verbiage

@DanTup sent an example over to me that looked like this:
Screen Shot 2021-01-25 at 2 14 15 PM

I think we should try to use consistent wording between the two IDEs, and I actually like how in this screenshot it just grabs the error message directly from the error, so it's consistent with console output as well.

For the button text, I like "Inspect widget"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated to look like this:
Screen Shot 2021-01-25 at 3 32 42 PM

There's a title as well as the button, let me know if any of you have preferences there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe change the title text to "Inspect error-causing widget"?

this wording matches what the error message says. For example,

The relevant error-causing widget was:
  Column
  file:///Users/kenzieschmoll/develop/flutter_vignettes/vignettes/spending_tracker/lib/demo.dart:64:26

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, like this?

Screen Shot 2021-01-25 at 3 57 02 PM

I'll land with the current lame URL parsing and make updates in a later PR if there's a nicer way.

@InMatrix InMatrix Jan 26, 2021 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm late to the party. The verbiage looks fine. I like the icon in the VS Code version more than the Flutter icon in the IntelliJ version, which signals that this notification is related to an error. For the IntelliJ version, can we go without a title for the message to match the simplicity of the VS Code version?

A related question: how are we handling multiple exceptions thrown at the same time? Will the user get a bunch of notifications at once? For example, this Missing Material Widget error will also generate a RenderFlex Overflow error from the red warning screen on device.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm making another change for the length of time this notification is shown, so I can make the other adjustments there too.

If there are multiple exceptions, they'll show up stacked like this:
Screen Shot 2021-01-26 at 2 00 22 PM

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Will the first error get displayed at the top of the stack or the bottom? The first error is usually relevant to the user's code in my experience.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm it's the most recent error that gets displayed. When "1 more" is clicked, there's a list shown of all the notifications with their timestamps:
Screen Shot 2021-01-27 at 11 55 39 AM

It may be the IntelliJ default to show the most recent at the top so that new notifications aren't missed. I can check whether this can be adjusted for a particular group of errors.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for checking. I think we need to try it over a few example errors and determine what makes sense. Flutter framework often throws secondary exceptions down the pipeline caused by the primary error the user can fix in their own code. Maybe there are other filtering strategies we can employ.

@kenzieschmoll kenzieschmoll left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm_army

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open embedded DevTools Inspector to error-causing widget for Flutter render overflow errors

3 participants