diff --git a/app/src/main/java/io/xpipe/app/core/AppProperties.java b/app/src/main/java/io/xpipe/app/core/AppProperties.java index f37f59480..d498da878 100644 --- a/app/src/main/java/io/xpipe/app/core/AppProperties.java +++ b/app/src/main/java/io/xpipe/app/core/AppProperties.java @@ -30,6 +30,7 @@ public class AppProperties { boolean image; boolean staging; boolean useVirtualThreads; + boolean debugThreads; Path dataDir; boolean showcase; @@ -50,6 +51,9 @@ public class AppProperties { useVirtualThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.useVirtualThreads")) .map(Boolean::parseBoolean) .orElse(true); + debugThreads = Optional.ofNullable(System.getProperty("io.xpipe.app.debugThreads")) + .map(Boolean::parseBoolean) + .orElse(false); dataDir = XPipeInstallation.getDataDir(); showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase")) .map(Boolean::parseBoolean) diff --git a/app/src/main/java/io/xpipe/app/util/ThreadHelper.java b/app/src/main/java/io/xpipe/app/util/ThreadHelper.java index d3eb01306..98945d63d 100644 --- a/app/src/main/java/io/xpipe/app/util/ThreadHelper.java +++ b/app/src/main/java/io/xpipe/app/util/ThreadHelper.java @@ -2,22 +2,29 @@ package io.xpipe.app.util; import io.xpipe.app.core.AppProperties; import io.xpipe.app.issue.ErrorEvent; +import io.xpipe.app.issue.TrackEvent; import io.xpipe.core.util.FailableRunnable; +import java.util.concurrent.atomic.AtomicInteger; + public class ThreadHelper { - public static Thread unstarted(Runnable r) { - return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(r) : Thread.ofPlatform().unstarted(r); + private static final AtomicInteger counter = new AtomicInteger(); + + private static Runnable wrap(Runnable r) { + return () -> { + if (AppProperties.get().isDebugThreads()) { + TrackEvent.trace("Started. Active threads: " + counter.incrementAndGet()); + } + r.run(); + if (AppProperties.get().isDebugThreads()) { + TrackEvent.trace("Finished. Active threads: " + counter.decrementAndGet()); + } + }; } - public static Thread unstartedFailable(FailableRunnable r) { - return unstarted(() -> { - try { - r.run(); - } catch (Throwable e) { - ErrorEvent.fromThrowable(e).handle(); - } - }); + public static Thread unstarted(Runnable r) { + return AppProperties.get().isUseVirtualThreads() ? Thread.ofVirtual().unstarted(wrap(r)) : Thread.ofPlatform().unstarted(wrap(r)); } public static Thread runAsync(Runnable r) { diff --git a/ext/base/src/main/java/io/xpipe/ext/base/browser/ChmodAction.java b/ext/base/src/main/java/io/xpipe/ext/base/browser/ChmodAction.java index 4e9ec5b37..60f3e35b1 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/browser/ChmodAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/browser/ChmodAction.java @@ -53,6 +53,6 @@ public class ChmodAction implements BranchAction { @Override public List getBranchingActions(OpenFileSystemModel model, List entries) { - return List.of(new Chmod("600"), new Chmod("644"), new Chmod("700"), new Chmod("777"), new Chmod("u+x"), new Chmod("a+x")); + return List.of(new Chmod("400"), new Chmod("600"), new Chmod("644"), new Chmod("700"), new Chmod("777"), new Chmod("u+x"), new Chmod("a+x")); } }