1# Cross-Process Application Capability Extension (UIExtension, for System Applications Only)
2
3**UIExtension** allows you to embed UI extensions from one application into another, providing a seamless experience as users interact with different application functionalities within a single application UI.
4
5![uiextension-ability](figures/uiextension-ability.png)
6
7## Basic Concepts
8
9- [UIExtensionComponent](../reference/apis-arkui/arkui-ts/ts-container-ui-extension-component-sys.md) component
10
11	Defined and used in the host application, **UIExtensionComponent** is provided by ArkUI for use in the application following the ArkTS declarative paradigm.
12
13- [UIExtensionAbility](../application-models/uiextensionability.md) component
14
15  Defined and used in the provider application, **UIExtensionAbility** allows the provider to run in a separate process and creates UI extensions that can be embedded in the host application's window.
16
17
18## Working Principle
19
20UIExtension offers a capability for cross-process application sharing. It is embedded into the host application (system application) process in the form of a component using the **UIExtensionComponent**. When the host application starts, it triggers the Application Management Service (AMS) to start the provider application process. AMS is mainly responsible for the management tasks of application startup, exit, and switching.
21
22After implementation, the page of the provider application can be displayed in the host application as a component:
23
24![uiextension-component](figures/uiextension-component.png)
25
26After being started by AMS, the provider application can exchange data with the host application.
27
28![uiextension-process-model](figures/uiextension-process-model.png)
29
30- The host application sends messages to the provider application through [UIExtensionProxy.send](../reference/apis-arkui/arkui-ts/ts-container-ui-extension-component-sys.md#send), and the provider can obtain the messages using [UIExtensionContentSession.setReceiveDataCallback](../reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md#uiextensioncontentsessionsetreceivedatacallback).
31- The provider application sends messages to the host application through [UIExtensionContentSession.sendData](../reference/apis-ability-kit/js-apis-app-ability-uiExtensionContentSession-sys.md#uiextensioncontentsessionsenddata), and the host can receive the messages using [UIExtensionProxy.onReceive](../reference/apis-arkui/arkui-ts/ts-container-ui-extension-component-sys.md#onreceive).
32
33## Available Capabilities
34
35### Basic Component Capabilities
36
37- Component-based [UIExtensionComponent](../reference/apis-arkui/arkui-ts/ts-container-ui-extension-component-sys.md): provides an embedded extension capability that allows the embedding and invocation of page extensions from other applications within the application page.
38- Full-screen UIExtension: presents content in a full-screen modal for immersive interaction, without being obscured by other elements. System applications can expose specific components or Node-APIs based on the underlying capabilities of UIExtension, enabling third-party applications to utilize these for creating full-screen modal experiences.
39
40### Available Capabilities of the UIExtensionAbility Process
41
42UIExtension is designed to facilitate the sharing of capabilities across different applications, offering a high degree of flexibility. It operates by launching the provider application's capabilities through a cross-process approach for use by the current (host) application. This mechanism involves service interactions between two separate processes, which is fundamentally different from the interactions between common components and their host applications.
43
44Below is a detailed list of the attributes, events, components, Node-APIs, and other features that the provider application can utilize within **UIExtensionAbility**.
45
46As component capabilities are subject to frequent updates, the current list of unsupported and partially supported features only reflects the status at the time of this document. Whether new capabilities are supported can be determined by referring to the principles of capability support. For capabilities that are currently unsupported, you can submit an issue to request support to the relevant component and UIExtension teams, which will then analyze the feasibility and provide support accordingly.
47
48**Universal Attributes**
49
50Due to the complexities of the cross-process communication mechanism, the **UIExtension** component is not able to influence other components or the host application's information, such as the application context **UIContext** and application window information.
51
52In scenarios where component attributes involve cross-component interactions, the following capabilities are not supported:
53
54- The attributes of the provider component cannot control, assign, or merge with the attributes of other components or host application components. For example, the [component ID](../reference/apis-arkui/arkui-ts/ts-universal-attributes-component-id.md) is not supported.
55- The attributes of the provider component cannot control display effects or animations that extend beyond the boundaries of the **UIExtension** component. For example, the [modal transition](../reference/apis-arkui/arkui-ts/ts-universal-attributes-modal-transition.md) is not supported.
56
57The details are as follows.
58
59| Attribute                                                    | Capability Support  | Description                                                  | Remarks                                                      |
60| ------------------------------------------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
61| [Component ID](../reference/apis-arkui/arkui-ts/ts-universal-attributes-component-id.md) | Not supported       | **id** identifies a component uniquely within an application. This module provides APIs for obtaining the attributes of or sending events to the component with the specified ID. | The **UIExtensionComponent** itself can use the component ID, and the provider can also set the component ID. However, there is no unified ID management system between the host application and the provider application. As a result, the host application cannot query information about components within the provider application using the component ID. Consequently, setting the component ID within the provider application is ineffective in terms of cross-process interaction. |
62| [Background blur](../reference/apis-arkui/arkui-ts/ts-universal-attributes-image-effect.md) | Not supported       | Image effects include blur, shadow, spherical effect, and much more. | —                                                            |
63| [restoreId](../reference/apis-arkui/arkui-ts/ts-universal-attributes-restoreId.md) | Not supported       | **restoreId** identifies a component in hopping scenarios. It can be used to restore the component to a specific state on a remote device. | —                                                            |
64| [Drag and drop control](../reference/apis-arkui/arkui-ts/ts-universal-attributes-drag-drop.md) | Not supported       | The drag and drop control attributes set whether a component can respond to drag events. | —                                                            |
65| [Modal transition](../reference/apis-arkui/arkui-ts/ts-universal-attributes-modal-transition.md) | Partially supported | The **bindContentCover** attribute binds a full-screen modal to a component. It provides a **ModalTransition** parameter for you to apply a transition effect for when the component is inserted or deleted. | Within the **UIExtension** component, the pages generated by the provider application cannot exceed the boundaries of the component. To make the page within the **UIExtension** component fill the entire screen, you must explicitly set the component to full-screen mode. |
66| [Sheet transition](../reference/apis-arkui/arkui-ts/ts-universal-attributes-sheet-transition.md) | Partially supported | The **bindSheet** attribute binds a sheet to a component. You can set the sheet to the preset or custom height for when the component is inserted. | Within the **UIExtension** component, the pages generated by the provider application cannot exceed the boundaries of the component. To make the page within the **UIExtension** component fill the entire screen, you must explicitly set the component to full-screen mode. |
67|                                                              |                     |                                                              |                                                              |
68
69**Components**
70
71By default, the provider application cannot interact with the host application's components or process context. Specifically, the following are not supported:
72
73- Effects that exceed a component's boundaries, such as the **Navigation** component displaying into the safe area
74- Components that rely on other components or require cross-component or cross-application control and access, for example, **PluginComponent** for accessing other components or **FormComponent** for displaying pages from other applications across processes
75- Components that depend on the host application's window information or process **UIContext** instance for capabilities, interactions, or animations, such as the **FolderStack** component
76
77The details are as follows.
78
79| Component                                                    | Capability Support  | Description                                                  | Remarks                                                      |
80| ------------------------------------------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
81| [PluginComponent (System API)](../reference/apis-arkui/arkui-ts/ts-basic-components-plugincomponent-sys.md) | Not supported       | **PluginComponent** enables users of the component to request both the component and the data it needs. The users send a component template and the corresponding data. It supports the SystemUI in integrating UI elements provided by various services through a plug-in-based approach. | 1. This component shares similarities with **UIExtension** and can be nested within other components. This nesting introduces additional complexity.<br>2. Since the provider of the **UIExtension** component operates in a separate process, it cannot access or interact with components within the host application by default. |
82| [FormComponent (System API)](../reference/apis-arkui/arkui-ts/ts-basic-components-formcomponent-sys.md) | Not supported       | **FormComponent** is a component used to display widgets.    | This component facilitates cross-process component calls. However, nesting it within UIExtension can complicate the process relationships, potentially leading to functional and performance issues. |
83| [IsolatedComponent (System API)](../reference/apis-arkui/arkui-ts/ts-container-isolated-component-sys.md) | Not supported       | **IsolatedComponent** is designed to support the embedding and display of UIs provided by independent .abc files within the current page, with the displayed content running in a restricted worker thread. | Due to its cross-application scheduling capability, UIExtension does not support nested launching of this component. |
84| [FullScreenLaunchComponent](../reference/apis-arkui/arkui-ts/ohos-arkui-advanced-FullScreenLaunchComponent.md) | Not supported       | **FullScreenLaunchComponent** is a component designed for launching atomic services in full screen. If the invoked application (the one being launched) grants the invoker the authorization to run the atomic service in an embedded manner, the invoker can operate the atomic service in full-screen embedded mode. If authorization is not provided, the invoker will launch the atomic service in a pop-up manner. | Due to its cross-application scheduling capability, UIExtension does not support nested launching of this component. |
85| [EmbeddedComponent](../reference/apis-arkui/arkui-ts/ts-container-embedded-component.md) | Not supported       | The **EmbeddedComponent** is a component used to embed into the current page the UI provided by another [EmbeddedUIExtensionAbility](../reference/apis-ability-kit/js-apis-app-ability-embeddedUIExtensionAbility.md) in the same application. The EmbeddedUIExtensionAbility runs in an independent process for UI layout and rendering. | Due to its cross-application scheduling capability, UIExtension does not support nested launching of this component. |
86| [RemoteWindow](../reference/apis-arkui/arkui-ts/ts-basic-components-remotewindow-sys.md) | Not supported       | **RemoteWindow** is a component that enables remote control of application windows, offering the capability to create synchronized animations between the application window and components during application startup and exit. | The components in UIExtension are already in another process and cannot affect or control the host application's window. |
87| [RichText](../reference/apis-arkui/arkui-ts/ts-basic-components-richtext.md) | Not supported       | The **RichText** component parses and displays HTML text.    | —                                                            |
88| [FolderStack](../reference/apis-arkui/arkui-ts/ts-container-folderstack.md) | Not supported       | The **FolderStack** component extends the **Stack** component by adding the hover feature for foldable devices. With the **upperItems** parameter set, it can automatically avoid the crease area of the foldable device and move the content to the upper half screen. The **FolderStack** component is usually used in modular development scenarios where .abc file hot update is required. | The component's capabilities require linkage with the host application's window, necessitating access to the host application's main window information within the provider. Therefore, this component is not supported at present. |
89| [XComponent](../reference/apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) | Not supported       | The **XComponent** can accept and display the EGL/OpenGL ES and media data input. | —                                                            |
90| [FormLink](../reference/apis-arkui/arkui-ts/ts-container-formlink.md) | Not supported       | The **FormLink** component is provided for interactions between static widgets and widget providers. It supports three types of events: router, message, and call. | This component facilitates cross-process component calls. However, nesting it within UIExtension can complicate the process relationships, potentially leading to functional and performance issues. |
91| [HyperLink](../reference/apis-arkui/arkui-ts/ts-container-hyperlink.md) | Not supported       | The **Hyperlink** component implements a link from a location in the component to another location. | —                                                            |
92| [ContextMenu](../reference/apis-arkui/arkui-ts/ts-methods-menu.md) | Not supported       | The menu bound to a component through [bindContextMenu](../reference/apis-arkui/arkui-ts/ts-universal-attributes-menu.md#bindcontextmenu12) on a page can be closed as needed. | —                                                            |
93| [Alert Dialog Box (AlertDialog)](../reference/apis-arkui/arkui-ts/ts-methods-alert-dialog-box.md) | Partially supported | You can set the text content and response callback for an alert dialog box. If **showInSubWindow** is set to **true** in **UIExtension**, the dialog box is aligned with the host window based on **UIExtension**. | The dialog box achieves alignment with the host application's window by utilizing data obtained from **UIExtension** regarding the application's window. Yet, only window alignment is supported. |
94| [Action Sheet (ActionSheet)](../reference/apis-arkui/arkui-ts/ts-methods-action-sheet.md) | Partially supported | An action sheet is a dialog box that displays actions a user can take. If **showInSubWindow** is set to **true** in **UIExtension**, the dialog box is aligned with the host window based on **UIExtension**. | The dialog box achieves alignment with the host application's window by utilizing data obtained from **UIExtension** regarding the application's window. Yet, only window alignment is supported. |
95| [Custom Dialog Box](../reference/apis-arkui/arkui-ts/ts-methods-custom-dialog-box.md) | Partially supported | A custom dialog box is a dialog box you customize by using APIs of the **CustomDialogController** class. You can set the style and content to your preference for a custom dialog box. If **showInSubWindow** is set to **true** in **UIExtension**, the dialog box is aligned with the host window based on **UIExtension**. | The dialog box achieves alignment with the host application's window by utilizing data obtained from **UIExtension** regarding the application's window. Yet, only window alignment is supported. |
96| [Navigation](../reference/apis-arkui/arkui-ts/ts-basic-components-navigation.md) | Partially supported | Since API version 11, this component supports the safe area attribute by default, with the default attribute value being **expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])**. You can override this attribute to change the default behavior. | 1. If **UIExtension** does not have modal or immersive settings configured, **Navigation** cannot extend into the safe area.<br>2. Routing to pages within the host application is not supported. |
97
98**Node-API**
99
100The capabilities provided by Node-APIs in the **UIExtension** scenario must account for their potential to extend beyond the current component and interact with the host application's components and process context. Specifically, the following are not supported.
101
102- The API may require information from the host application's context or window, such as **UIContext**.
103- The API may control or influence not just the component itself but also other components or aspects of the host application, such as UI appearance.
104
105The details are as follows.
106
107| Module                                                       | Capability Support  | Description                                                  | Remarks                                                      |
108| ------------------------------------------------------------ | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
109| [Page Transition](../reference/apis-arkui/arkui-ts/ts-page-transition-animation.md) | Not supported       | You can customize the page entrance and exit animations in the **pageTransition** API for transition between pages. | —                                                            |
110| [Implicit Shared Element Transition (geometryTransition)](../reference/apis-arkui/arkui-ts/ts-transition-animation-geometrytransition.md) | Not supported       | **geometryTransition** is used to create a smooth, seamless transition between views. By specifying the frame and position of the in and out components through **geometryTransition**, you can create a spatial linkage between the transition effects (such as opacity and scale) defined through the **transition** mechanism. In this way, you can guide the visual focus from the previous view (out component) to the new view (in component). | —                                                            |
111| [componentUtils](../reference/apis-arkui/js-apis-arkui-componentUtils.md) | Not supported       | The **componentUtils** module provides API for obtaining the coordinates and size of the drawing area of a component. | The information obtained pertains to the window, and by default, it is the information about **WindowProxy** of the UIExtensionAbility, not the main window information of the host application. |
112| [UIContext](../reference/apis-arkui/js-apis-arkui-UIContext.md) | Not supported       | **@ohos.window** adds the [getUIContext](../reference/apis-arkui/js-apis-window.md#getuicontext10) API in API version 10 for obtaining the **UIContext** object of a UI instance. The API provided by the **UIContext** object can be directly applied to the corresponding UI instance. | In the default **UIExtension** configuration, the provider lacks an actual window, and therefore it is not possible to obtain the correct **UIContext** through this API. |
113| [DragController](../reference/apis-arkui/js-apis-arkui-dragController.md) | Not supported       | The **dragController** module provides APIs for initiating drag actions. When receiving a gesture event, such as a touch or long-press event, an application can initiate a drag action and carry drag information therein.<br>The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see **UIContext**. | Drag event transmission between components relies on **UIContext** instances. Since the host and provider applications do not share the **UIContext** content, drag event transmission is not supported by default. |
114| [@ohos.arkui.inspector (Layout Callback)](../reference/apis-arkui/js-apis-arkui-inspector.md) | Partially supported | The **Inspector** module provides APIs for registering the component layout and drawing completion callbacks. | If a UIExtension component is specified, all the component information in the UIExtension is expected to be obtained. This capability is not supported yet. The provider can use this capability internally. |
115| [@ohos.arkui.performanceMonitor (Performance Monitor)](../reference/apis-arkui/js-apis-arkui-performancemonitor-sys.md) | Not supported       | The **performanceMonitor** module provides APIs for performance monitoring indicators: response delay, completion delay, and frame loss rate. Not supported | —                                                            |
116| [@ohos.font (Custom Font Registration)](../reference/apis-arkui/js-apis-font.md) | Not supported       | The **font** module provides APIs for registering custom fonts. | The registered fonts have a restricted scope, and the provider is unable to influence the font settings within the host application. |
117| [PluginComponentManager](../reference/apis-arkui/js-apis-plugincomponent.md) | Not supported       | The **PluginComponentManager** module provides APIs for the **PluginComponent** user to request components and data and send component templates and data. | The provider component, residing in a separate process, is unable to access data from other components. As such, the capability to interact with the host application's components is not supported. |
118| [@ohos.uiAppearance (UI Appearance) (System API)](../reference/apis-arkui/js-apis-uiappearance-sys.md) | Not supported       | The **uiAppearance** module provides basic capabilities for managing the system appearance. It allows for color mode configuration currently, and will introduce more features over time. | The provider application cannot influence the host application through this capability. |
119
120## Constraints
121
122**Security Capability Constraints**
123
124The **UIExtensionComponent** (on the host side) can access applications that have integrated the UIExtensionAbility (on the provider side), offering a universal capability for application sharing. As UIExtension capabilities do not independently include a security mechanism, the provider application must utilize other ArkUI capabilities to protect against potential attacks from the host application, including scenarios with **CreateModalUIExtension**.
125
126Considering the extensive capabilities of UIExtension (including those derived from UIExtension, such as those for **CreateModalUIExtension** in the system), if there are security concerns within the provider application that cannot be resolved within UIExtension, alternative approaches should be considered. Using UIExtension without proper security measures poses potential risks to both the provider and host applications.
127
128**Usage modes:**
129
130- **CreateModalUIExtension** (full-screen modal mode): **CreateModalUIExtension** is an inner class interface used exclusively by system applications to launch cross-process UIs through the development of Node-APIs or components. In this mode, a modal that overlays the application is created, preventing any components or windows from the host application from obscuring the UIExtension, and resizing of the component is not permitted.
131
132- **UIExtensionComponent** (component mode): This mode is exclusively for system applications and can be used within applications through the ArkTS declarative paradigm. Integrated as a component, **UIExtensionComponent** allows for interaction effects similar to those of other components within the application.
133
134In component mode, to avoid being obscured by the host application's subwindows:
135
136- The provider application can determine, based on its service needs, whether to allow the host application to obscure the UI.
137
138- A recommended measure to prevent obscuration is the use of the [hideNonSecureWindows](../reference/apis-arkui/js-apis-uiExtensionHost-sys.md#hidenonsecurewindows) API.
139
140- This approach has a drawback: Once applied, it restricts the host application's interaction capabilities, as it can no longer create subwindows that could cover the provider application's window.
141
142
143**Nesting Constraints**
144
145UIExtension capabilities allow for a nested dependency chain as the following: application A (UIAbility) -> application B (UIExtensionAbility) -> application C (UIExtensionAbility). However, because of the cross-process nature, too many nesting levels can lead to a sharp decline in application interaction performance. Therefore, the following constraints are imposed:
146
147- No more than three levels of nesting: Excessive nesting levels can lead to frequent cross-process interactions, degrading response performance and resulting in a poor user experience.
148- No circular nesting allowed: Circular nesting, such as application A (UIAbility) -> application B (UIExtensionAbility) -> application C (UIExtensionAbility) -> back to application B (UIExtensionAbility), can cause application B to become unresponsive in synchronous processing scenarios, leading to potential deadlocks.
149
150**Event Processing Mechanism Constraints**
151
152Events are handled synchronously or asynchronously based on their use case:
153
154- Interactions between the host process and the provider process are handled asynchronously by default: This avoids performance issues and deadlocks, which could affect the overall interaction experience.
155- Synchronous event handling principles: Synchronous events are supported where they have a low trigger frequency and minimal performance impact; they should meet the actual use scenarios.
156
157When using the UIExtension capabilities, comply with the following design constraints:
158
159- Synchronous event handling scenarios: Performance issues due to deep nesting or functional issues due to circular nesting cannot be resolved by the UIExtension component mechanism. You need to analyze and resolve these issues based on their service scenarios, such as reducing nesting levels or using non-UIExtension component solutions.
160- Asynchronous event handling scenarios: Both the UIExtension component and the host application's components may receive events simultaneously. You need to manage this based on the use scenario. For example, you can configure the host application components not to handle the events. If this is not feasible, you are advised to replace the UIExtension component to ensure a seamless interaction experience.
161
162| Scenario         | Category                             | Supported or Not | Synchronous/Asynchronous (Host and Provider) | Remarks                                                      |
163| ---------------- | ------------------------------------ | ---------------- | -------------------------------------------- | ------------------------------------------------------------ |
164| Universal event  | Click event (**Click**)              | Supported        | Asynchronous                                 | —                                                            |
165| Universal event  | Touch event (**Touch**)              | Supported        | Asynchronous                                 | —                                                            |
166| Universal event  | Drag event (**onDrag*XXX***)         | Supported        | Asynchronous                                 | —                                                            |
167| Universal event| Key event (**KeyEvent**)      | Supported    | Synchronous                     | Circular nesting or excessive nesting can cause unresponsiveness in applications. To address this issue, a default timeout mechanism is provided for managing waiting periods. If the timeout threshold is exceeded, the waiting is automatically aborted. From the perspective of the upper layer, this is treated as if the event was not processed at all.|
168| Universal event| Focus event (**onFocus**/**onBlur**)| Supported    | Synchronous                     | Circular nesting or excessive nesting can cause unresponsiveness in applications. To address this issue, a default timeout mechanism is provided for managing waiting periods. If the timeout threshold is exceeded, the waiting is automatically aborted. From the perspective of the upper layer, this is treated as if the event was not processed at all.|
169| Universal event  | Mouse event (**onHove**/**onMouse**) | Supported        | Asynchronous                                 | —                                                            |
170| Gesture handling | —                                    | Supported        | Asynchronous                                 | —                                                            |
171| Accessibility  | —                          | Supported    | Synchronous                     | Circular nesting or excessive nesting can cause unresponsiveness in applications. To address this issue, a default timeout mechanism is provided for managing waiting periods. If the timeout threshold is exceeded, the waiting is automatically aborted. From the perspective of the upper layer, this is treated as if the event was not processed at all.|
172
173**Page Rendering Experience Constraints**
174
175As UIExtension involves cross-process application calls, the processing between the host application process and the provider application process cannot be synchronized, leading to different experience issues compared to regular components. Be aware of the performance constraints of rendering pages across multiple processes with this component and take targeted measures.
176
177- **Flickering white screen**: Initiating a new process through UIExtension to deliver functionality involves a sequence of steps – creation, launch, and page rendering – that require time to complete. During this period, users may notice a brief display of the **UIExtensionComponent**'s default white background, resulting in a flickering white screen.
178- **Desynchronization between rendering and display**: When the host application page changes rapidly (such as during screen rotation or window resizing), there can be a desynchronization between the rendering of the host application page and the content displayed within the **UIExtension** component. This issue arises from cross-process interactions; while the provider application's process tasks are triggered by the host application, layout tasks are handled in the respective process's JavaScript thread. There is no guarantee of synchronization between the host application's and provider application's rendering tasks, resulting in desynchronization.
179
180
181
182When developing the provider application, consider the following design constraints:
183
184- Use scenarios with minimal layout changes.
185- When layout changes occur, the provider application's JavaScript thread should execute as few tasks as possible to ensure that it can respond to layout change tasks promptly.
186
187You can mitigate the flickering white screen issue with the provider application in the following ways:
188
189- Adjust the background color of the UIExtensionComponent (for instructions, see [Background](../reference/apis-arkui/arkui-ts/ts-universal-attributes-background.md)) to match the background color of the host application's and provider application's pages, to deliver a seamless transition and prevent noticeable changes during the loading process.
190- Utilize the [placeholder](../reference/apis-arkui/arkui-ts/ts-container-ui-extension-component-sys.md#uiextensionoptions11) mechanism provided by this component to configure a custom UI, which will be displayed before the provider application page is fully displayed.
191
192If the mitigation does not fully meet the application's interaction requirements due to the constraints of cross-process capabilities, it is recommended that you consider alternative solutions.