How Chrome Extension is Installed, and how to Troubleshoot Installation Issues

How Chrome Extension is installed, and how to troubleshoot installation issues?

Introduction

This document provides a detailed explanation of the events that occur during Chrome Extension installation, and detailed troubleshooting information is available at the end.

Chrome Extension ID

A Chrome Extension must have an ID, which is mainly used by the Chrome Web Store.

There are 2 different extension installations available for the Chrome Extension. That is,

  1. Online installation

    1. The extension exists on the Chrome Web Store, but it is configured to be unsearchable from its search bar (here). The Chrome Extension ID might be different across machines or environments because the ID typically changes based on the Studio/Robot version installed on the machine. Refer to the Studio - List of extensions for Chrome to find the Chrome Extension ID corresponding to the Studio/Robot version in use.

  2. Offline installation

    1. It is a self-hosted local version that can be used in controlled environments for machines that have restricted Internet access and do not have access to the Chrome Web Store. The Offline Chrome Extension ID does not change with each version of the Studio/Robot. The Offline Chrome extension ID can be found here.

Chrome Extension Types

There are two extension types, namely, Manifest V2 (MV2) and Manifest V3 (MV3). MV3 is the most recent extension type and a standard that offers higher security and privacy guarantees and replaces the MV2 type, which is deprecated now. Read the Important note in the documentation to know the background of MV2 deprecation and transition to the MV3 type. To know the list of MV2 and MV3 UiPath Chrome Extensions, refer to the Type column in the table documented here.

Components of Chrome Extension

Chrome Extension has 2 components. They are bundled with Studio and Robots. They are not updated with NuGet. This means that updating the UiPath.UIAutomation.Activities package does not update the Chrome Extension.

  • .crx file

  • Chrome Native Messaging

Content of .crx File

The .crx file is a file extension for Chrome Extensions, and UiPath has Chrome extensions built with CRX2 format and CRX3 format.

CRX essentially is a zip. If it is unzipped, it contains a JavaScript file, manifest.json, and icons. The full file list is below for the latest .crx file.

  • ContentLoader.js

  • Loader.js

  • manifest.json

  • uiPath128.png

  • uiPath16.png

  • uiPath48.png

  • _metadata\verified_contents.json

The difference between .zip and .crx is that .crx contains some header data. For more detail refer to here

.crx File version

UiPath Chrome Extension was built with CRX2, but starting with Chrome 73, the CRX2 format was phased out and is no longer supported by Chrome. Devs changed the CRX file format to CRX3 to accommodate this change. Later devs added a CRX2 format file for customers using Chrome versions older than 64.0.3242. The version that has both CRX3 and CRX2 will be able to handle old Chrome and new Chrome.
Example:

  • uipath_extension_for_chrome.crx

    • CRX3

  • uipath_extension_for_chrome_crx2.crx :

    • CRX2

Chrome Native Messaging Host

UiPath Robot/Studio/UiExplorer cannot communicate directly with Chrome. For a native application to communicate with Chrome, a mediator called Native Messaging is used. Refer to Native messaging | Chrome for Developers for more information on Native Messaging.

UiPath Chrome Native Messaging Host (ChromeNativeMessaging.exe) is an implementation of a native messaging host.

Implementation of the .crx file and Chrome Native Messaging Host is extremely minimal, and the driver itself (UiAutomation Activity pack) does the heavy lifting.

What Happens when SetupExtensions.exe is Executed

When "C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe" is executed, a registry key is written for Chrome Native Messaging Host and a .crx file. Chrome Extension can be installed per user with the command SetupExtensions.exe /chrome or per system with the command SetupExtensions.exe /chromeglobal or using Group Policy (ref).
Below are the Registry keys, values, and data created with the Chrome Extension:

  • SetupExtensions.exe /chrome (Per User)

    • .crx related

      • HKEY_CURRENT_USER\Software\Google\Chrome\Extensions\<Chrome Extension ID>

        • (Default) | REG_SZ | (value not set)

        • path | REG_SZ | C:\Program Files\UiPath\Studio\UiPath\BrowserExtension\uipath_extension_for_chrome.crx

          • Path value contains a data string of the file location. The path may be different depending on the Studio/Robot installation mode. The file name may be different based on the Studio/Robot version.

        • version | REG_SZ | <Chrome Extension version>

    • Chrome Native Messaging Host related

      • HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.uipath.chromenativemsg_v2

        • (Default) | REG_SZ | C:\Users\<username>\AppData\Local\UiPath\native_host_manifest_chrome.json

  • SetupExtensions.exe /chromeglobal (Per System)

    • .crx related

      • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Chrome\Extensions\<Chrome Extension ID>

        • (Default) | REG_SZ | (value not set)

        • path | REG_SZ | C:\Program Files\UiPath\Studio\UiPath\BrowserExtension\uipath_extension_for_chrome.crx

          • Path value contains a data string of the file location. The path may be different depending on the Studio/Robot installation mode. The file name may be different based on the Studio/Robot version.

        • version | REG_SZ | <Chrome Extension version>

    • Chrome Native Messaging Host related

      • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Chrome\NativeMessagingHosts\com.uipath.chromenativemsg_v2

        • (Default) | REG_SZ | C:\Program Files\UiPath\Studio\UiPath\native_host_manifest_chrome.json

  • Extension Installed per User using Policy

  • Extension Installed per System using Policy

Below are additional details about the registry key:

  • Policy installation method provides the URL to install the extension from the internet, whereas the Per System and Per User installation method provides the location in the UiPath installation.

  • The native_host_manifest_chrome.json file location

    • native_host_manifest_chrome.json is created by SetupExtensions.

      • If installed per user, then native_host_manifest_chrome.json will be created in the user’s home directory %localappdata%\UiPath

      • If installed per system, then there is no suitable user directory. Check the path of the native_host_manifest_chrome.json in the registry path Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Chrome\NativeMessagingHosts.

  • Adding the Chrome Native Messaging Host-related registry key can be done through SetupExtensions.exe /chromenativehost for the user installation, SetupExtensions.exe /chromenativehostglobal for the system.

What happens at the first execution of Chrome after SetupExtensions.exe is Executed

  1. Chrome notices that there is a registry key regarding Extensions being added, thus Chrome shows the following prompt. This prompt appears because the Extension was installed using user or system installation mode.

  2. After the prompt appears

    1. Click 'Enable extension', the extension will be unpacked to “%localappdata%\Google\Chrome\User Data\Default\Extensions\<UiPath Chrome Extension ID>”.

    2. If a click is made outside of this prompt, the prompt will no longer appear. To enable, run “chrome://extensions/” on the Chrome browser URL and move the bottom right toggle button in “UiPath Web Automation” to the right. Then the extension will be unpacked.

    3. If 'Remove from Chrome' was clicked in the prompt, or 'Remove' button in the “chrome://extensions/”, registry key values will remain, but Chrome internally marks the UiPath Chrome Extension as removed. In order to remove this mark, execute SetupExtensions.exe /chrome /uninstall or its global counterparts. For cleaning the full setup, execute SetupExtensions.exe /chromecleanup. The cleanup command is not available for older version SetupExtensions.exe.

Installation of the extension through policy will not show the prompt and will automatically install and enable, which is the benefit of policy installation. Due to this benefit, installing through policy will be beneficial for customers planning a mass computer setup. With the policy and automated setup script with Chrome Native Messaging Host installation command, UiPath Chrome Extension installation can be fully automated.

How Chrome Native Messaging Host Starts

Chrome Native Messaging Host is started by Chrome, not the UiPath Chrome Extension.

  1. When any Chrome Extension is enabled, Chrome scans the manifest.json file for all registered Native Messaging Hosts from the registry. Inside manifest.json, there is a key named “allowed_origins”. This key stores detail regards to Chrome Extension that uses this Native Messaging Host. UiPath Chrome Native Messaging Host’s manifest.json has
    "chrome-extension://<Chrome Extension ID>/"
    as the value of the allowed_origins key.

  2. Chrome realizes that the UiPath Chrome Extension depends on this Native Messaging Host, and Chrome starts the Messaging Host. In order to start the Messaging Host, it refers to the key “path”, which contains the location of ChromeNativeMessaging.exe.

  3. It’s important to note that Chrome launches the ChromeNativeMessaging.exe via the cmd.exe process. If cmd.exe is disabled, it could potentially prevent the launch of ChromeNativeMessaging.exe.

First Step of Troubleshooting

  1. Closing Chrome

  2. Executing SetupExtensions.exe /chromecleanup

  3. Installing Chrome Extension with the preferred setting

These steps hypothetically should fix most problems. If the UiPath version is too old to use this command, run “SetupExtensions.exe /chrome /uninstall” or “SetupExtensions.exe /chromeglobal /uninstall”, then install. These steps will clear the registry key and delete everything that may cause issues in the environment. Nevertheless, below are some confirmations that can be done.
Caution: Be aware /chromecleanup command will modify all users. The Chrome extension will be gone for other users as well, unless installation is done using the /chromeglobal command.

Manual Checks

  1. Registry key missing or wrong

    1. Check if the registry key value is correct. Regarding file path-related registry data, make sure those files exist.

  2. Removed

    1. If the 'Remove' button is pressed, one of the following commands can delete the removed mark of the extension from Chrome.

      1. “SetupExtensions.exe /chrome”

      2. “SetupExtensions.exe /chromeglobal”

      3. “SetupExtensions.exe /chrome /uninstall”

      4. “SetupExtensions.exe /chromeglobal /uninstall”

      5. “SetupExtensions.exe /chromecleanup”

  3. The Data created in the local app data is broken

    1. Check “%localappdata%\Google\Chrome\User Data\Default\Extensions\<UiPath Chrome Extension ID>” and see if any file is missing or corrupted.
      Also, the UiPath Chrome Extension section of chrome://extensions will show that it is corrupted.

    2. Run “SetupExtensions.exe /chrome /uninstall” and uninstall it. If the file remains, delete it manually.

Second Step of Troubleshooting

Extensions and Native Messaging Host can be blacklisted or whitelisted. The customer may only whitelist the Extension and not whitelist the Native Messaging Host due to a lack of knowledge. Or the customer may not whitelist either.
Current policy can be confirmed from the Chrome browser. Go to chrome://policy
The blacklist configurations are below

The whitelist policy configurations are below

Final Step of Troubleshooting

This is for escalating the issue to the Engineering team/MCS/SMEs. The logging for Chrome can be enabled. Note that the following change will have an effect when the browser is launched manually and may not have an effect if the automation launches the browser. To ensure the logs are generated when the Robot executes the automation, add --enable-logging --v=1 in the 'Extra arguments for Open Browser Chrome' in the Project settings under Browser in the UI Automation Classic section. This setting is applied to both Open Browser (Classic) and use App/Browser (Modern) activity.

Below are the steps for collecting the logs by launching the Chrome browser manually and not via automation:

  1. Run the command below on the command prompt to move to the Chrome directory. The installation directory might differ

    1. cd C:\Program Files\Google\Chrome\Application\

  2. Run chrome --enable-logging --v=1

Another way to do it is to edit the Shortcut

  1. Right-click the Chrome shortcut and Select Property

  2. Edit the content of “Target”. Below is a sample, but simply append “enable-logging --v=1” at the end of what is currently set as Target, since the installation directory of Chrome may be different.
    "C:\Program Files\Google\Chrome\Application\chrome.exe" -enable-logging --v=1

For more information, refer here

After Chrome is logging enabled, Open Chrome, open a web page, then close the browser.
The logs can be found in %localappdata%\Google\Chrome\User Data\chrome_debug.log. Open it and search for the extension ID or ChromeNativeMessaging.exe.

The chrome_debug.log was used to identify an issue where the extension icon was visible in the Chrome Extensions section of the Chrome menu, but ChromeNativeMessaging.exe wasn’t running. From this log, devs found that the environment variable “ComSpec” was missing. This environment variable is necessary to open the communication channel between the extension and ChromeNativeMessaging.exe

Final Word

Please escalate the issue to the Escalation/MCS team if the information provided in this document does not help solve the problem.