Skip to content

Conversation

@alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Jan 22, 2026

Description

EIM download was getting stuck on POSIX when launched with IDE.
The issue seemed to consistent on EIM v0.6 but with v0.7 i am unable to reproduce. I have added the changes anyway since it seems to be a better approach to launch and monitor the process without actually launching it as a standard process with java and monitoring that we were already doing that on windows now implemented with AppleScript on mac and sh on linux for bash

Fixes # (IEP-1686)

Type of change

Please delete options that are not relevant.

  • Bug fix (can be a breaking change which fixes an issue)

How has this been tested?

Try launching and downloading on POSIX and windows and see if you are able to successfully install the tools

Test Configuration:

  • ESP-IDF Version: any
  • OS (Windows,Linux and macOS): all

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • New centralized, cross‑platform app launcher with OS‑specific launch strategies, PID reporting, and improved macOS installer (.dmg) handling.
  • Bug Fixes

    • More robust process lifecycle management, safer download/URL handling, improved cleanup during launches, and expanded error/interrupt handling for greater reliability.

✏️ Tip: You can customize this high-level summary in your review settings.

@alirana01 alirana01 self-assigned this Jan 22, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Replaces direct Process-based EIM launching with a LaunchResult-driven service and OS-specific launcher strategies. EimLoader delegates launches to EimLaunchService; wait/closure handling now operates on LaunchResult. New utilities (LaunchResult, ProcessWaiter, ProcessUtils) and platform strategies (Windows, macOS, Linux) added; MANIFEST exports updated.

Changes

Cohort / File(s) Summary
Core loader & download flow
bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/EimLoader.java
Replaced direct Process handling with delegation to EimLaunchService; public API signatures updated to use LaunchResult; closure waiting now accepts LaunchResult; improved URL/URI handling and added download cleanup.
Launch service & factory
bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/launch/EimLaunchService.java, .../EimLauncherFactory.java
New EimLaunchService delegates to OS-specific strategy chosen by EimLauncherFactory. Validates inputs and exposes launch + wait APIs.
Platform strategies
bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/launch/strategies/*
Added EimLauncherStrategy interface and concrete strategies: WindowsEimLauncherStrategy, MacOsEimLauncherStrategy, LinuxEimLauncherStrategy, plus AbstractLoggingLauncherStrategy for shared console logging. Strategies return LaunchResult and implement wait logic.
Launch result & process helpers
bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/launch/LaunchResult.java, .../ProcessUtils.java, .../ProcessWaiter.java
New LaunchResult abstraction (OptionalLong pid, execPath, details). ProcessUtils helpers for reading/parsing output and quoting. ProcessWaiter polls by PID or execPath to implement wait semantics.
UI consumers updated
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/EimButtonLaunchListener.java, bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/EspressifToolStartup.java
Replaced launchEim(...)launchEimWithResult(...) usage and updated waitForEimClosure(...) calls to pass LaunchResult. Minor exception handling adjustments.
Bundle exports & manifest
bundles/com.espressif.idf.core/META-INF/MANIFEST.MF, bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF
Exported new package com.espressif.idf.core.tools.launch; added org.eclipse.ui.intro dependency in UI MANIFEST.
sequenceDiagram
    participant UI as UI (button/startup)
    participant Service as EimLaunchService
    participant Strategy as EimLauncherStrategy (OS-specific)
    participant OS as Operating System / Process
    participant Waiter as ProcessWaiter

    UI->>Service: launch(eimPath)
    Service->>Strategy: strategy.launch(eimPath)
    Strategy->>OS: spawn process (osascript/powershell/nohup)
    OS-->>Strategy: stdout (pid or details)
    Strategy-->>Service: LaunchResult(pid?, execPath, details)
    Service-->>UI: LaunchResult
    UI->>Service: waitForExit(LaunchResult)
    Service->>Strategy: strategy.waitForExit(LaunchResult, monitor)
    Strategy->>Waiter: waitByPid or waitByExecPath
    Waiter-->>Strategy: IStatus (OK/CANCEL/ERROR)
    Strategy-->>Service: IStatus
    Service-->>UI: completion callback run
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

macos, arm64

Suggested reviewers

  • AndriiFilippov
  • kolipakakondal

Poem

🐇 I dug a tunnel in the code today,

From Processes to LaunchResult I made way.
I hop on mac, on win, on linux ground,
New strategies hum, new PIDs are found.
Hooray! the launcher sings — the rabbit bounds away.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'IEP-1686: Fix for eim download getting stuck' accurately describes the main change: resolving an issue where EIM downloads were hanging. It clearly references the issue number and the core problem being addressed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/EspressifToolStartup.java (1)

379-399: Guard against invalid PID after launch failure

If launchEim throws, eimPid remains -1 and waitForEimClosure still runs, which can fire the callback even though EIM never launched. Gate the wait on a valid PID (and log/notify on failure) to avoid opening the manager prematurely.

🐛 Proposed fix
 long eimPid = -1;
 String appToLaunch = filePath;
 try
 {
   if (filePath.endsWith(".dmg"))
   {
     appToLaunch = eimLoader.installAndLaunchDmg(Paths.get(filePath));
   }

   idfEnvironmentVariables.addEnvVariable(IDFEnvironmentVariables.EIM_PATH, appToLaunch);
   eimPid = eimLoader.launchEim(appToLaunch);
 }
 catch (
   IOException
   | InterruptedException e)
 {
   Logger.log(e);
 }

-eimLoader.waitForEimClosure(eimPid, () -> {
+if (eimPid > 0)
+{
+  eimLoader.waitForEimClosure(eimPid, () -> {
     if (toolInitializer.isOldEspIdfConfigPresent() && !toolInitializer.isOldConfigExported())
     {
       Logger.log("Old configuration found and not converted");
       handleOldConfigExport();
     }
     try
     {
       eimJson = toolInitializer.loadEimJson();
     }
     catch (EimVersionMismatchException e)
     {
       Logger.log(e);
       MessageDialog.openError(Display.getDefault().getActiveShell(), e.msgTitle(), e.getMessage());
       return;
     }
     openEspIdfManager(eimJson);
-});
+  });
+}
+else
+{
+  Logger.log("EIM launch failed; skipping wait/refresh.");
+}
bundles/com.espressif.idf.core/src/com/espressif/idf/core/tools/EimLoader.java (1)

414-446: Use the method parameter in isWindowsProcessAlive

isWindowsProcessAlive(long pid) compares against eimPid instead of pid, which will be wrong if the method is reused with a different PID.

✅ Proposed fix
-                if (line.contains(String.valueOf(eimPid)))
+                if (line.contains(String.valueOf(pid)))
                 {
                     return true;
                 }

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !
Tested under:
OS: Linux Ubuntu 24.04 / Mac arm64 / Windows 11
EIM_GUI: release/v0.7.0
ESP-IDF: v5.5.2 / v5.4.3

Able to download and launch EIM via IDE.
The previous major issue ("Stuck during IDF downloading") is resolved and no longer occurs on any tested platforms (macOS arm64, Linux Ubuntu, Windows 11).

However, the following errors still occur during testing:

  1. All platforms:
    affected by the "Broken Welcome Page" issue.
Could not create intro view proxy.
Caused by: java.lang.ClassNotFoundException: org.eclipse.ui.intro.config.CustomizableIntroPart cannot be found by com.espressif.idf.ui_1.0.1.202601221321

WelcomePage.txt

  1. Mac ARM64:
    the stuck issue has gone, I am able to launch EIM from IDE and download IDF without any problems, but facing this issue on Mac when launch EIM or close EIM:
execution error: PID not found (app may not have launched) (-2700)
No PID found in launcher output.
Invalid PID: -1

arm64MAC.txt

@kolipakakondal kolipakakondal added this to the v4.1.0 milestone Jan 27, 2026
Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

Hi @alirana01, thanks for the PR. I’m still in the process of reviewing it, but so far everything looks good 👍
I only noticed a bit of dead code — for example, the waitForProcessWindows methods don’t seem to be used.

I’ll get back to you if I find anything else.

@alirana01
Copy link
Collaborator Author

@AndriiFilippov kindly see if it works now there was a missing dependency that could have been causing the problem for welcome page not sure who removed it but please test again on all platforms again

@alirana01
Copy link
Collaborator Author

Hi @alirana01, thanks for the PR. I’m still in the process of reviewing it, but so far everything looks good 👍 I only noticed a bit of dead code — for example, the waitForProcessWindows methods don’t seem to be used.

I’ll get back to you if I find anything else.

@sigmaaa code is updated now please review throughly to see any issues

Copy link
Collaborator Author

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

Self Review

coderabbitai[bot]

This comment was marked as spam.

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

@alirana01 please check the CodeRabbit comments — they seem reasonable. Otherwise, LGTM!

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS: Windows 11 / Mac ARM64 / Linux Ubuntu 24.04
EIM: release/v0.7.0
ESP-IDF: master / 5.5.2 / 5.4.3

Welcome page issue fixed ✅
PID error fixed ✅
able to download IDF without any stuck ✅
LGTM 👍

@kolipakakondal kolipakakondal merged commit d27a7c5 into master Jan 29, 2026
7 of 8 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1686 branch January 29, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants