Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

- Silent failure when opening Flutter projects without `.idea` directory in IntelliJ IDEA, by removing `FlutterProjectOpenProcessor` and migrating configuration logic to `FlutterInitializer`. (#8845)
- Gutter buttons not running tests with non-ASCII characters in their names. (#7985)
- Freeze from JX Browser close. (#8864)

## 90.0.0

Expand Down
33 changes: 17 additions & 16 deletions src/io/flutter/jxbrowser/EmbeddedBrowserEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
*/
package io.flutter.jxbrowser;

import com.intellij.openapi.application.ApplicationListener;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfo;
import io.flutter.utils.OpenApiUtils;
import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.PasswordStore;
Expand All @@ -22,7 +23,7 @@
import static com.teamdev.jxbrowser.engine.RenderingMode.HARDWARE_ACCELERATED;
import static com.teamdev.jxbrowser.engine.RenderingMode.OFF_SCREEN;

public class EmbeddedBrowserEngine {
public class EmbeddedBrowserEngine implements Disposable {
private static final @NotNull Logger LOG = PluginLogger.createLogger(EmbeddedBrowserEngine.class);
private final Engine engine;

Expand Down Expand Up @@ -60,22 +61,22 @@ public EmbeddedBrowserEngine() {
}
engine = temp;

ApplicationManager.getApplication().addApplicationListener(new ApplicationListener() {
@Override
public boolean canExitApplication() {
try {
if (engine != null && !engine.isClosed()) {
engine.close();
}
}

@Override
public void dispose() {
OpenApiUtils.safeExecuteOnPooledThread(() -> {
try {
if (engine != null && !engine.isClosed()) {
engine.close();
}
catch (Exception ex) {
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
LOG.info(ex);
} else {
LOG.info("Exception when closing JX Browser engine: " + ex.getMessage());
}
}
catch (Exception ex) {
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
LOG.info(ex);
} else {
LOG.info("Exception when closing JX Browser engine: " + ex.getMessage());
}
return true;
}
});
}
Expand Down
14 changes: 13 additions & 1 deletion src/io/flutter/jxbrowser/EmbeddedJxBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.flutter.settings.FlutterSettings;
import io.flutter.utils.AsyncUtils;
import io.flutter.utils.JxBrowserUtils;
import io.flutter.utils.OpenApiUtils;
import io.flutter.utils.ZoomLevelSelector;
import io.flutter.view.EmbeddedBrowser;
import io.flutter.view.EmbeddedTab;
Expand Down Expand Up @@ -98,7 +99,18 @@ public void loadUrl(String url) {

@Override
public void close() {
this.browser.close();
OpenApiUtils.safeExecuteOnPooledThread(() -> {
try {
this.browser.close();
}
catch (Exception ex) {
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
LOG.info(ex);
} else {
LOG.info("Exception when closing JX Browser instance: " + ex.getMessage());
}
}
Comment thread
pq marked this conversation as resolved.
});
}

@Override
Expand Down
15 changes: 8 additions & 7 deletions src/io/flutter/view/EmbeddedBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ public void projectClosing(@NotNull Project project) {
final Map<String, BrowserTab> tabs = windows.get(window);
for (final String tabName : tabs.keySet()) {
final BrowserTab tab = tabs.get(tabName);
if (tab.embeddedTab != null) {
try {
tab.embeddedTab.close();
final EmbeddedTab embeddedTab = tab.embeddedTab;
if (embeddedTab != null) {
try {
embeddedTab.close();
}
catch (Exception ex) {
logger().info(ex);
}
}
catch (Exception ex) {
logger().info(ex);
}
}
}
tabs.clear();
}
Expand Down
7 changes: 6 additions & 1 deletion src/io/flutter/widgetpreview/WidgetPreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ public void dispose() {
// Dispose the browser tab
final EmbeddedTab tab = browserTabRef.getAndSet(null);
if (tab != null) {
tab.close();
try {
tab.close();
}
catch (Exception ex) {
LOG.info(ex);
}
}
}
}
Loading