Skip to content

Remove use of legacy inspector #6728

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

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions flutter-idea/src/io/flutter/FlutterBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,12 @@ settings.organize.imports.on.save=Organize imports on save
settings.flutter.version=Version:
settings.open.inspector.on.launch=Open Flutter Inspector view on app launch
settings.hot.reload.on.save=Perform hot reload on save
settings.enable.embedding.devtools=Enable embedding DevTools in the Flutter Inspector tool window
settings.enable.bazel.hot.restart=Enable Bazel hot restart (refreshes generated files)
settings.allow.tests.in.sources=<html>Allow files ending with <b>_test.dart</b> to be recognized as tests
settings.allow.tests.tooltip=The directory must be marked as a sources root, such as <b>lib</b>.
settings.font.packages=Font Packages
settings.show.all.configs=Show all possible run configurations for apps or tests, even if a created configuration already exists
settings.show.all.configs.tooltip=If there is a defined run configuration to watch a specific test and one to just run it, show both.
settings.enable.embedding.devtools.tooltip=Use the web-based DevTools inspector in the Flutter Inspector tool window.
settings.enable.androi.gradle.sync.tooltip=Provides advanced editing capabilities for Java and Kotlin code. Uses Gradle to find Android libraries then links them into the Flutter project.
settings.experiments=Experiments
settings.editor=Editor
Expand Down
11 changes: 1 addition & 10 deletions flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
</grid>
</children>
</grid>
<grid id="23e52" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="23e52" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand Down Expand Up @@ -270,15 +270,6 @@
<toolTipText value="Experimental features to graphically edit Flutter build methods."/>
</properties>
</component>
<component id="2032d" class="javax.swing.JCheckBox" binding="myEnableEmbeddedBrowsersCheckBox">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="io/flutter/FlutterBundle" key="settings.enable.embedding.devtools"/>
<toolTipText resource-bundle="io/flutter/FlutterBundle" key="settings.enable.embedding.devtools.tooltip"/>
</properties>
</component>
<component id="e902c" class="javax.swing.JCheckBox" binding="myShowAllRunConfigurationsInContextCheckBox">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public class FlutterSettingsConfigurable implements SearchableConfigurable {
private JCheckBox myIncludeAllStackTraces;
private JCheckBox mySyncAndroidLibrariesCheckBox;
private JCheckBox myEnableHotUiCheckBox;
private JCheckBox myEnableEmbeddedBrowsersCheckBox;
private JCheckBox myEnableBazelHotRestartCheckBox;

private JCheckBox myShowAllRunConfigurationsInContextCheckBox;
Expand Down Expand Up @@ -161,8 +160,6 @@ protected void textChanged(@NotNull final DocumentEvent e) {
// experimentsPanel.setVisible(FlutterUtils.isAndroidStudio());
mySyncAndroidLibrariesCheckBox.setVisible(FlutterUtils.isAndroidStudio());

myEnableEmbeddedBrowsersCheckBox.setVisible(true);

myEnableBazelHotRestartCheckBox.setVisible(WorkspaceCache.getInstance(myProject).isBazel());
}

Expand Down Expand Up @@ -249,10 +246,6 @@ public boolean isModified() {
return true;
}

if (settings.isEnableEmbeddedBrowsers() != myEnableEmbeddedBrowsersCheckBox.isSelected()) {
return true;
}

if (settings.isEnableBazelHotRestart() != myEnableBazelHotRestartCheckBox.isSelected()) {
return true;
}
Expand Down Expand Up @@ -323,7 +316,6 @@ public void apply() throws ConfigurationException {
settings.setVerboseLogging(myEnableVerboseLoggingCheckBox.isSelected());
settings.setSyncingAndroidLibraries(mySyncAndroidLibrariesCheckBox.isSelected());
settings.setEnableHotUi(myEnableHotUiCheckBox.isSelected());
settings.setEnableEmbeddedBrowsers(myEnableEmbeddedBrowsersCheckBox.isSelected());
settings.setEnableBazelHotRestart(myEnableBazelHotRestartCheckBox.isSelected());
settings.setAllowTestsInSourcesRoot(myAllowTestsInSourcesRoot.isSelected());
settings.setShowAllRunConfigurationsInContext(myShowAllRunConfigurationsInContextCheckBox.isSelected());
Expand Down Expand Up @@ -391,7 +383,6 @@ public void reset() {

myEnableHotUiCheckBox.setSelected(settings.isEnableHotUi());

myEnableEmbeddedBrowsersCheckBox.setSelected(settings.isEnableEmbeddedBrowsers());
myEnableBazelHotRestartCheckBox.setSelected(settings.isEnableBazelHotRestart());
myAllowTestsInSourcesRoot.setSelected(settings.isAllowTestsInSourcesRoot());

Expand Down
23 changes: 1 addition & 22 deletions flutter-idea/src/io/flutter/settings/FlutterSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,28 +319,7 @@ public boolean isEnableHotUiInCodeEditor() {
}

public boolean isEnableEmbeddedBrowsers() {
// For Big Sur users, change this setting to true if it's currently false and we haven't already set it to true.
if (SystemInfo.isMac && (SystemInfo.isOsVersionAtLeast("11.0") || SystemInfo.isOsVersionAtLeast("10.16")) &&
!getPropertiesComponent().getBoolean(enableEmbeddedBrowsersKey, true) &&
isChangeBigSurToTrue()) {
FlutterMessages.showInfo(
"Embedded DevTools Inspector",
"The embedded inspector is now supported for MacOS Big Sur and is enabled by default. To disable, go to Preferences > Flutter.",
null
);

// We do not want to set it back to true again in the future (e.g. if a user decides to set to false).
setChangeBigSurToTrue(false);
setEnableEmbeddedBrowsers(true);
return true;
}

return getPropertiesComponent().getBoolean(enableEmbeddedBrowsersKey, true);
}

public void setEnableEmbeddedBrowsers(boolean value) {
getPropertiesComponent().setValue(enableEmbeddedBrowsersKey, value, true);
fireEvent();
return true;
}

public boolean isEnableBazelHotRestart() {
Expand Down
93 changes: 14 additions & 79 deletions flutter-idea/src/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public FlutterView(@NotNull Project project) {

@VisibleForTesting
@NonInjectable
protected FlutterView(@NotNull Project project, JxBrowserManager jxBrowserManager, JxBrowserUtils jxBrowserUtils, InspectorGroupManagerService inspectorGroupManagerService, MessageBusConnection messageBusConnection) {
protected FlutterView(@NotNull Project project, @NotNull JxBrowserManager jxBrowserManager, JxBrowserUtils jxBrowserUtils, InspectorGroupManagerService inspectorGroupManagerService, MessageBusConnection messageBusConnection) {
myProject = project;
this.jxBrowserUtils = jxBrowserUtils;
this.jxBrowserManager = jxBrowserManager;
Expand Down Expand Up @@ -742,87 +742,22 @@ private void debugActiveHelper(FlutterApp app, @Nullable InspectorService inspec

toolWindow.setIcon(ExecutionUtil.getLiveIndicator(FlutterIcons.Flutter_13));

if (FlutterSettings.getInstance().isEnableEmbeddedBrowsers()) {
if (jxBrowserManager.getStatus().equals(JxBrowserStatus.INSTALLED)) {
// Reset the URL since we may have an outdated one from a previous app run.
embeddedBrowserOptional().ifPresent(EmbeddedBrowser::resetUrl);
if (jxBrowserManager.getStatus().equals(JxBrowserStatus.INSTALLED)) {
// Reset the URL since we may have an outdated one from a previous app run.
embeddedBrowserOptional().ifPresent(EmbeddedBrowser::resetUrl);
}
if (toolWindow.isVisible()) {
displayEmbeddedBrowser(app, inspectorService, toolWindow);
}
else {
if (toolWindowListener == null) {
toolWindowListener = new FlutterViewToolWindowManagerListener(myProject, toolWindow);
}
if (toolWindow.isVisible()) {
// If the window isn't visible yet, only executed embedded browser steps when it becomes visible.
toolWindowListener.updateOnWindowFirstVisible(() -> {
displayEmbeddedBrowser(app, inspectorService, toolWindow);
}
else {
if (toolWindowListener == null) {
toolWindowListener = new FlutterViewToolWindowManagerListener(myProject, toolWindow);
}
// If the window isn't visible yet, only executed embedded browser steps when it becomes visible.
toolWindowListener.updateOnWindowFirstVisible(() -> {
displayEmbeddedBrowser(app, inspectorService, toolWindow);
});
}

return;
});
}

listenForRenderTreeActivations(toolWindow);

addInspectorViewContent(app, inspectorService, toolWindow);

app.getVmService().addVmServiceListener(new VmServiceListenerAdapter() {
@Override
public void connectionOpened() {
onAppChanged(app);
}

@Override
public void received(String streamId, Event event) {
if (StringUtil.equals(streamId, VmService.EXTENSION_STREAM_ID)) {
if (StringUtil.equals("Flutter.Frame", event.getExtensionKind())) {
handleFlutterFrame(app);
}
}
}

@Override
public void connectionClosed() {
ApplicationManager.getApplication().invokeLater(() -> {
if (inspectorService != null) {
Disposer.dispose(inspectorService);
}

if (toolWindow.isDisposed()) return;
final ContentManager contentManager = toolWindow.getContentManager();
onAppChanged(app);
final PerAppState state = perAppViewState.remove(app);
if (state != null) {
if (state.content != null) {
contentManager.removeContent(state.content, true);
}
state.dispose();
}
if (perAppViewState.isEmpty()) {
// No more applications are running.
updateForEmptyContent(toolWindow);
}
});
}
});

onAppChanged(app);

app.addStateListener(new FlutterApp.FlutterAppListener() {
public void notifyAppRestarted() {
// When we get a restart finished event, queue up a notification to the flutter view
// actions. We don't notify right away because the new isolate can take a little
// while to start up. We wait until we get the first frame event, which is
// enough of an indication that the isolate and flutter framework are initialized
// to where they can receive service calls (for example, calls to restore various
// framework debugging settings).
final PerAppState state = getStateForApp(app);
if (state != null) {
state.sendRestartNotificationOnNextFrame = true;
}
}
});
}

private void displayEmbeddedBrowser(FlutterApp app, InspectorService inspectorService, ToolWindow toolWindow) {
Expand Down