This topic describes only module-specific error codes. For details about universal error codes, see Universal Error Codes.
Error Message
Repeated operation.
Description
This error code is reported when a repeated operation is performed.
Possible Causes
The window has been created.
Solution
Before creating a window, check whether the window has been created or is in the current state.
Error Message
This window state is abnormal.
Description
This error code is reported when you operate a window in an abnormal state, for example, a window that is not created yet or has been destroyed.
Possible Causes
The window to operate is not created or has been destroyed.
Solution
Operate the window that exists.
Possible Causes
The application crashes when the getLastWindow() API is called during window destruction (such as using onWindowStageDestroy or performing page destruction).
Typical log information
Fault log format:
Error Name: Error Error Message: [window][getLastWindow]msg: xxx Error code: 1300002 Stack trace: at window.getLastWindow (WindowManagerService) at MyComponent.onWindowStageDestroy (MyAbility.ts:50)
Key information:
Solution
Locate the position where getLastWindow() is called based on the log stack and check whether the window is being destroyed (for example, in the onWindowStageDestroy or aboutToDisappear callback). Common scenario: loadContent() is not called to load the page when the window is created. As a result, the application crashes when getLastWindow() is incorrectly called during the destruction process.
Key points for resolution:
Positive and negative cases
Negative case
// Incorrect: The page is not loaded when the window is created, and **getLastWindow()** is called in the destruction process.
onWindowStageCreate(windowStage: window.WindowStage) {
// Missing: **loadContent** is not called to load the page.
windowStage.getMainWindow((err, win) => {
win.showWindow(); // The empty window is displayed directly.
});
}
onWindowStageDestroy() {
let lastWindow = window.getLastWindow(this.context); // The application crashes.
} Positive case
// Correct: The page is loaded immediately when the window is created. The destruction process only clears resources.
onWindowStageCreate(windowStage: window.WindowStage) {
windowStage.getMainWindow((err, win) => {
win.loadContent('pages/MainPage'); // Load the page during window creation.
});
}
onWindowStageDestroy() {
this.cleanupResources(); // Only clear resources. Do not call getLastWindow.
} Possible Causes
When you call the setResizeByDragEnabled() API in a subwindow to enable window resizing by dragging, error code 1300002 is returned, and the resizing cannot be implemented.
Typical log information
View the error log in DevEco Studio or using the hdc tool:
hdc shell hilog | grep -i -E "1300002|setResizeByDragEnabled"
Typical log example:
SetResizeByDragEnabled: This is not main window or decor enabled sub window
Key information:
Solution
Check whether decorEnabled is set to true in SubWindowOptions when creating a subwindow.
For the subwindow that calls this API, ensure that the title bar has been enabled for the subwindow.
Positive and negative cases
Negative case
windowStage.createSubWindowWithOptions('mySubWindow', {
title: "",
decorEnabled: false, // Incorrect: The title bar is not enabled.
isModal: false,
maximizeSupported: true
}); Positive case
let options: window.SubWindowOptions = {
title: "",
decorEnabled: true, // The title bar is enabled.
isModal: false,
maximizeSupported: true
};
windowStage.createSubWindowWithOptions('mySubWindow', options).then((windowClass) => {
// The API can be called properly when decorEnabled is set to true.
windowClass.setResizeByDragEnabled(true, (err: BusinessError) => {
console.error("setResizeByDragEnabled failed.", ` code: ${err.code}, message: ${err.message}`)
})
}) Possible Causes
When you call findWindow() to search for a window that does not exist, the application crashes.
Typical log information
Fault log format:
Error Name: Error Error Message: [window][findWindow]msg: The window is not created or destroyed Error code: 1300002 Stack trace: at window.findWindow (WindowManagerService) at MyComponent.onCreate (MyAbility.ts:50)
Key information:
Solution
Locate the position where findWindow() is called based on the log stack and check whether the window name is correct. Run the following command to query the findWindow parameter information:
grep -n "findWindow" src/**/*.ts
Use the HiDumper to verify the window status:
hdc shell hidumper -s WindowManagerService -a '-a'
Positive and negative cases
Negative case
// Incorrect: Pass an incorrect window name when searching for a window.
const currWindow = window.findWindow("test_Window");
// Incorrect: Call a function on an empty object.
currWindow.showWindow(); Positive case
// Correct: Perform an empty check on the obtained object after calling findWindow.
const currWindow = window.findWindow("test_Window");
if (currWindow) {
currWindow.showWindow();
} else {
console.error('Window not found');
} Possible Causes
After creating a window object using createSubWindow(), you call destroyWindow(). Before the window is destroyed, you call createSubWindow() again with the same name. As a result, the window fails to be created, and error code 1300002 is reported.
Typical log information
Fault log format:
WindowSessionCreateCheck: WindowName(TestSubWindow) already exists. Error code: 1300002
Key information:
Solution
The destroyWindow() API is used to destroy a window instance. This API is an asynchronous API. If the window instance to be destroyed has not been destroyed when the createSubWindow API is called, a window with the same name may be created, triggering error code 1300002.
Locate the position where createSubWindow() is called based on the log stack, search for all positions where createSubWindow() is called, and check whether the same window name is used.
grep -n "createSubWindow" src/**/*.ts
After the window fails to be created, use the HiDumper to check the current window status.
hdc shell hidumper -s WindowManagerService -a '-a'
Key points for resolution:
Positive and negative cases
Negative case
let windowClass: window.Window | undefined = undefined;
let windowClass = await windowStage.createSubWindow('mySubWindow');
// Incorrect: destroyWindow is an asynchronous API but is used as a synchronous API.
windowClass.destroyWindow();
let newWindow = await windowStage.createSubWindow('mySubWindow'); // Error code 1300002 may be returned. Positive case
// Correct: Create a window after the destruction is complete.
let windowClass = await windowStage.createSubWindow('mySubWindow');
// Call the destruction API and wait until the destruction is complete.
await windowClass.destroyWindow();
// Ensure that the window with the same name is created only after the destruction is complete.
let newWindow = await windowStage.createSubWindow('mySubWindow'); Use different window names to avoid duplicate names.
// Use a timestamp as part of the window name to avoid duplicate names. let windowName = 'mySubWindow_' + Date.now(); let windowClass = await windowStage.createSubWindow(windowName);
Possible Causes
You call the off('avoidAreaChange') API during window destruction (such as using onWindowStageDestroy, onDestroy, or page destruction), the application crashes.
Typical log information
Error Name: Error
Error Message: [window][off]msg: Unregister listener failed.
Error code: 1300002
Stack trace:
at windowClass.off('avoidAreaChange') (WindowManagerService)
at MyComponent.onWindowStageDestroy (MyAbility.ts:50) Key information:
Solution
Positive and negative cases
Negative case
// Incorrect: Call off in onWindowStageDestroy.
onWindowStageDestroy() {
this.windowClass.off('avoidAreaChange'); // The window may have been destroyed. Error code 1300002 is returned, and the application crashes.
} Positive case
// Cancel the listener before the page is hidden or the application is uninstalled (not in the destruction process).
onPageHide() {
try {
this.windowClass?.off('avoidAreaChange');
} catch (exception) {
console.error(`Failed to disable the listener. Cause code: ${exception.code}, message: ${exception.message}`);
}
} Error Message
This window manager service works abnormally.
Description
This error code is reported when the window manager service is abnormal.
Possible Causes
The internal services of the window are not started normally.
Solution
System service error. Try again later or restart the device.
Error Message
Unauthorized operation.
Description
This error code is reported when the API does not have the required permissions to operate an object.
Possible Causes
The window object of another process is operated.
Solution
Check whether the window object of another process is operated. If yes, delete the related operation.
Possible Causes
You call the restore() API for a subwindow, resulting in an operation failure and error code 1300004.
Typical log information
Fault log:
BusinessError 1300004: Unauthorized operation. Possible cause: Invalid window Type.Only main windows are supported.
Solution
The restore() API can be used to restore only the main window. Otherwise, error code 1300004 will be reported.
Use the HiDumper to check the window type and determine whether the window is the main window.
hdc shell hidumper -s WindowManagerService -a '-a'
Search for the target window in the output and determine the window type based on the Type field.
Possible Causes
When you call the getWindowSystemBarProperties() API in a non-main window of the application, such as a subwindow or a global floating window, error code 1300004 is reported.
Typical log information
Error Name: Error Error Message: [window][getWindowSystemBarProperties]msg: Invalid window type. Only main windows are supported. Error code: 1300004 Stack trace: at windowClass.getWindowSystemBarProperties() (WindowManagerService) at MyComponent.onWindowStageCreate (MyAbility.ts:50)
Key information:
Solution
The getWindowSystemBarProperties() API can be called only in the main window of an application. Otherwise, error code 1300004 will be reported.
Use the HiDumper to check the window type and determine whether the current window is the main window of the application.
hdc shell hidumper -s WindowManagerService -a '-a'
Search for the target window in the output and determine the window type based on the Type field. If the value of Type is 1, the window is the main window and getWindowSystemBarProperties() can be called. Otherwise, getWindowSystemBarProperties() cannot be called.
Positive and negative cases
Negative case
windowStage.createSubWindow('mySubWindow', (err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
console.error(`Failed to create the subwindow. Cause code: ${err.code}, message: ${err.message}`);
return;
}
windowClass = data;
console.info(`Succeeded in creating the subwindow. Data: ${JSON.stringify(data)}`);
if (!windowClass) {
console.info('Failed to load the content. Cause: windowClass is null');
}
let systemBarProperty = windowClass.getWindowSystemBarProperties()
}); Positive case
onWindowStageCreate(windowStage: window.WindowStage) {
let windowClass = windowStage.getMainWindowSync();
try {
let systemBarProperty = windowClass.getWindowSystemBarProperties();
console.info('Success in obtaining system bar properties. Property: ' + JSON.stringify(systemBarProperty));
} catch (err) {
console.error(`Failed to get system bar properties. Code: ${err.code}, message: ${err.message}`);
}
} Error Message
This window stage is abnormal.
Description
This error code is reported when you operate a WindowStage in the abnormal state, for example, a WindowStage that has been destroyed.
Possible Causes
The WindowStage is not created or has been destroyed.
Solution
Before operating a WindowStage, check whether it exists.
Error Message
This window context is abnormal.
Description
This error code is reported when you operate a window context in the abnormal state, for example, a window context that has been destroyed.
Possible Causes
The window context has been destroyed when being operated.
Solution
Before operating the window context, check whether it exists.
Error Message
Restore parent main window failed.
Description
This error code is reported when restoring the main window of the current window to the foreground fails.
Possible Causes
The main window is in the PAUSED lifecycle state.
Solution
Ensure that the lifecycle state of the main window is normal and then perform related operations.
Error Message
The display device is abnormal.
Description
This error code is reported when the display device is abnormal.
Possible Causes
The display device is not ready.
The display device is removed.
Solution
Ensure that the display device is normal.
Error Message
The parent window is invalid.
Description
This error code is reported when the parent window is invalid.
Possible Causes
No parent window is bound.
Solution
Ensure that the subwindow is bound to the parent window.
Error Message
The operation in the current window status is invalid.
Description
This error code is reported when the operation is not supported in the current window mode.
Possible Causes
Perform the move operation in the full-screen or split-screen window.
Solution
Do not move the full-screen or split-screen window.
Error Message
Failed to destroy the PiP window.
Description
This error code is reported when destroying a PiP window fails.
Possible Causes
The pointer to the PiP window is null.
Solution
No action is required.
Error Message
The PiP window state is abnormal.
Description
This error code is reported when the PiP window status is abnormal.
Possible Causes
The PiP window has been destroyed, but the code is still trying to access the window.
The PiP window is in an invalid state (for example, it has not been created, has been closed, or is being destroyed).
After the PiP window is destroyed, the window object is accessed in an asynchronous task or callback.
Solution
Do not call stopPiP() when the PiP window lifecycle state is ABOUT_TO_STOP or STOPPED.
Do not call startPiP() when the PiP window lifecycle state is ABOUT_TO_START or STARTED.
Possible Causes
After the PiP window is destroyed (for example, the user exits the PiP window or the window lifecycle ends), you call the stopPiP() API of the PiP window, triggering error code 1300012.
Typical log information
Error Name: Error Error Message: [PiPWindow][stopPiP]msg: The window is not created or destroyed. Error code: 1300012
Solution
Check whether the stopPiP() API is called when the PiP window is in ABOUT_TO_STOP or STOPPED state.
In the preceding state, the PiP window is about to stop or has stopped. In this case, the stopPiP() API cannot be called.
Check whether the stopPiP() API is called in asynchronous callbacks such as setTimeout and Promise, and whether the window may have been destroyed when the callback is executed.
In asynchronous callbacks, the PiP window may have been destroyed, and the code does not verify the PiP window status. In this case, calling the stopPiP() API will cause an error.
Positive and negative cases
Negative case
// Incorrect: The asynchronous task calls the **stopPiP()** API after the window is destroyed.
stopPiPTimer() {
setTimeout(() => {
this.pipController?.stopPiP();
}, 1000);
} Positive case
async stopPiPSafely(pipController: PiPController) {
let state: string = 'undefined';
pipController.on('stateChange', (newState: string, reason: string) => {
state = newState;
if (state === 'STARTED') {
pipController?.stopPiP();
}
});
} Possible Causes
When the PiP window has been started or is being started, you call the startPiP() API of the PiP window, triggering error code 1300012.
Typical log information
Error Name: Error Error Message: [PiPWindow][startPiP]msg: The window is already started or is about to start. Error code: 1300012
Solution
Check whether the startPiP() API is called when the PiP window lifecycle state is ABOUT_TO_START or STARTED.
In this state, the PiP window is about to start or has started. In this case, the startPiP() API cannot be called.
Check whether the startPiP() API is called in asynchronous callbacks such as setTimeout and Promise, and whether the window may have been started when the callback is executed.
In asynchronous callbacks, the PiP window may have been started or is being started, and the code does not verify the PiP window status. In this case, calling the startPiP() API will cause an error.
Positive and negative cases
Negative case
// Incorrect: The asynchronous task calls the **startPiP()** API after the window is created.
startPiPTimer() {
setTimeout(() => {
this.pipController?.startPiP();
}, 1000);
} Positive case
async startPiPSafely(pipController: PiPController) {
let state: string = 'undefined';
pipController.on('stateChange', (newState: string, reason: string) => {
state = newState;
if (state === 'STOPPED') {
pipController?.startPiP();
}
});
} Error Message
Failed to create the PiP window.
Description
This error code is reported when creating a PiP window fails.
Possible Causes
Incorrect parameters are passed in to create the PiP window.
Solution
Correct the input parameters.
Error Message
PiP internal error.
Description
This error code is reported when an internal error occurs in PiP.
Possible Causes
The window on which the PiP feature depends is abnormal or empty.
Solution
No action is required.
Error Message
Repeated PiP operation.
Description
This error code is reported when a repeated PiP operation is performed.
Possible Causes
The PiP window has been started or closed.
Solution
Do not start or stop PiP repeatedly.
Error Message
Parameter validation error.
Description
This error code is reported when parameters are incorrect. For example, the parameter value exceeds the allowed range, the length of the string or array does not meet the requirements, or the parameter format is incorrect.
Possible Causes
The parameter value is out of range.
The parameter length exceeds the allowed limits.
The parameter format is incorrect.
Solution
Verify that the parameters adhere to the required standards.
Error Message
API call timed out.
Description
This error code is reported when the API call times out.
Possible Causes
The wait time for a synchronous API call exceeds the upper limit.
Solution
The solution will vary based on the specific context. Typical approaches are:
Retry the API call a limited number of times.
Implement fallback measures, such as using cached data or alternative logic.
Abort the current processing logic.
Error Message
Wrong parameters for operating the floating ball.
Description
This error code is reported when parameters are incorrect. For example, the parameter value exceeds the allowed range, the length of the string or array does not meet the requirements, or the parameter format is incorrect.
Possible Causes
The parameter value is out of range.
The parameter length exceeds the allowed limits.
The parameter format is incorrect.
A mandatory parameter is not passed.
Solution
Ensure that the parameter value is within the allowed range.
Ensure that the parameter length is within the allowed limits.
Use the correct format for the parameter.
Check whether any mandatory parameter is not passed.
For details about the floating ball parameters, see FloatingBallParams.
Error Message
Failed to create the floating ball window.
Description
This error code is reported when creating a floating ball window fails.
Possible Causes
Invalid parameters are passed in to start the floating ball.
Attempt to start the floating ball on an unsupported device.
Attempt to start the floating ball when the application is in the background.
Solution
Check the parameters before starting the floating ball.
Verify that the device supports the floating ball before starting it.
Ensure that the application is in the foreground before starting the floating ball.
Error Message
Failed to start multiple floating ball windows.
Description
This error code is reported when starting multiple floating balls fails.
Possible Causes
Multiple floating ball controllers are created for the same application.
Solution
An application should create only one floating ball controller to start the floating ball. You are advised to use a singleton pattern to hold the floating ball controller.
Error Message
Repeated floating ball operation.
Description
This error code is reported when a repeated operation is performed on the floating ball.
Possible Causes
Attempt to start the floating ball while it is already running.
Attempt to stop the floating ball after it has already stopped.
Register the floating ball callback repeatedly.
Solution
Check whether the floating ball is already running before starting it.
Check whether the floating ball has already stopped before stopping it.
Ensure that the callback is not already registered before registering the floating ball callback.
Error Message
Floating ball internal error.
Description
This error code is reported when an internal error occurs in the floating ball.
Possible Causes
The window on which the floating ball depends is abnormal or empty.
The floating ball controller is abnormal or empty.
Solution
Check the window of the floating ball to ensure it is not empty.
Check the status of the floating ball controller to ensure it is not empty.
Error Message
The floating ball window state is abnormal.
Description
This error code is reported when the floating ball window state is abnormal.
Possible Causes
The floating ball window may not have been created or may have been destroyed.
Solution
Check that the floating ball window has been created and is not destroyed.
Error Message
The floating ball state does not support this operation.
Description
This error code is reported when the operation is not supported in the current floating ball state.
Possible Causes
Attempt to update the floating ball when it is not active.
Attempt to query window information when the floating ball is not active.
Attempt to launch an application window when the floating ball is not active.
Attempt to start the floating ball before the stop process is complete.
Solution
Check whether the floating ball is active before updating it.
Check whether the floating ball is active before querying window information.
Check whether the floating ball is active before launching an application window.
Wait for the floating ball to stop completely before restarting it.
Error Message
Failed to restore the main window.
Description
This error code is reported when launching an application window via the floating ball fails.
Possible Causes
The passed parameters are invalid.
The application does not have the ohos.permission.AUTO_RESTORE_MAIN_WINDOW permission and the floating ball is not tapped before the application window is launched.
Attempt to launch a window that belongs to another application.
Solution
Check the parameters used to launch the application window.
To launch the application window without user interaction, apply for the ohos.permission.AUTO_RESTORE_MAIN_WINDOW permission. Otherwise, launch the application window after the floating ball is tapped.
Launch only the window of this application.
Error Message
When updating the floating ball, the template type cannot be changed.
Description
This error code is reported when changing the template type fails.
Possible Causes
The template type used during the update is inconsistent with the one used during creation.
Solution
Ensure that the template type used when updating the floating ball matches the one used when it was created.
Error Message
Updating static template-based floating balls is not supported.
Description
This error code is reported when users attempt to update a floating ball based on a static template.
Possible Causes
Updating floating balls based on static templates is not supported.
Solution
Delete any existing floating balls based on static templates and create new ones.
Error Message
Repeated operations on the float view.
Description
This error code is reported when operations are repeated on the float view.
Possible Causes
The float view is being started or has been started, and is started again.
The float view is being stopped or has been stopped, and is stopped again.
The float view callback is registered repeatedly.
Solution
You are advised to use onStateChange to obtain the current status change. Before starting the float view, check whether the float view has been started.
You are advised to use onStateChange to obtain the current status change. Before stopping the float view, check whether the float view has been stopped.
Before registering the float view callback, ensure that the callback has not been registered.
Error Message
The floatView state does not support this operation.
Description
This error code is reported when the operation is not supported in the current float view state.
Possible Causes
The float view has been started but has not been stopped, and an operation that requires the float view be in stopped state (such as binding or unbinding) is performed.
The float view has not been started, and an operation that requires the float view be in started state (such as stopping, restoring the main window, or obtaining window attributes) is performed.
The float view is in stopping state, and a startup operation is performed.
Solution
Before performing an operation, check the current state of the float view to ensure that it meets the state requirements of the API.
To stop the float view, ensure that it has been started.
Wait until the float view stops (confirmed through the status change callback) and then perform the follow-up procedure.
Error Message
Failed to restore the main window.
Description
This error code is reported when the float view fails to start the main window of the application.
Possible Causes
The user has never clicked the float view.
The float view is not displayed in the foreground.
The main window is in the PAUSED lifecycle state.
The main window is in the multitasking screen.
Solution
Instruct the user to click the float view and then try to restore the main window.
Check whether the float view is displayed in the foreground.
Check the lifecycle state of the main window to avoid calling the restoration API when the main window is in the PAUSED state.
Ensure that the main window is not in the multitasking state and try to restore it again.
Error Message
Failed to start float view.
Description
This error code is reported when the float view fails to be started.
Possible Causes
Multiple float views are repeatedly started for the same application.
When the float view is started, the main window associated with the context is not in the foreground.
Solution
Only one float view can be started for the same application. Do not start multiple float views at the same time.
Before starting the float view, ensure that the application window to which the context is passed is displayed in the foreground.
Error Message
This operation conflicts with other floating windows.
Description
This error code is reported when this operation conflicts with other float views.
Possible Causes
The floating ball window or PiP window has been started in the application.
Solution
Before starting the float view, stop the floating ball window and PiP window.
Error Message
A window null pointer occurs.
Description
This error code is reported when you operate a window pointed to by a null pointer.
Possible Causes
A null pointer is used.
Solution
Operate the window that exists.
Error Message
This window type is invalid.
Description
This error code is reported when the window type is invalid.
Possible Causes
An invalid window type is used. For details about valid window types, see WindowType.
Solution
Use a window type supported.
Error Message
This window parameter is invalid.
Description
This error code is reported when a window parameter is invalid.
Possible Causes
Invalid parameters are passed in.
Solution
Correct the parameters.
Error Message
This system ability service works abnormally.
Description
This error code is reported when the ability service is abnormal.
Possible Causes
When the window is destroyed, the proxy fails to be initialized.
Solution
Restart the device and try again.
Error Message
This window IPC failed.
Description
This error code is reported when IPC fails.
Possible Causes
The window parameters fail to be transferred.
Solution
Before operating a window, ensure that the client and server services in the window are normal.
Error Message
Failed to start the ability.
Description
This error code is reported when a WindowExtensionAbility fails to start an application.
Possible Causes
Incorrect parameters are passed into the API used by the WindowExtensionAbility to start the application.
Solution
Pass in the correct parameters.