Anomaly handling methods, chips, electronic devices and media
By intercepting the exit process of the host application when the Quick App engine malfunctions and displaying a fallback diagram of the malfunction, the problem of the host application crashing indefinitely is solved, thus improving the user experience.
Patent Information
- Application Number
- CN202510631783.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2026-11-17
AI Technical Summary
The host application may encounter errors when running the quick app, leading to endless crashes and crashes, which affects the user experience.
By detecting anomalies in the Quick App engine, the exit process of the host application is intercepted, and an anomaly fallback diagram is displayed in the Quick App to prevent endless crashes and app crashes.
It effectively prevents the host application from crashing and freezing indefinitely, thus improving the user experience.
Smart Images

Figure CN123114804A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic equipment technology, and in particular to an anomaly handling method, a chip, an electronic device, and a medium. Background Technology
[0002] Quick Apps are a lightweight business model that can run as plug-ins within a host application (such as the desktop), providing a good user experience. However, exceptions may occur during the execution of a Quick App within the host application. These exceptions can cause the host application to exit (the user interface upon exiting may manifest as an application crash), potentially leading to an endless series of crashes and negatively impacting the user experience. Summary of the Invention
[0003] This application provides an exception handling method, chip, electronic device, and medium that help prevent host applications from crashing and dropping indefinitely.
[0004] In a first aspect, embodiments of this application provide an exception handling method applied to an electronic device, the electronic device including a target application, the exception handling method comprising: detecting a first operation, the first operation being used to request the target application to run a first quick application, the first quick application being any quick application; responding to the first operation, the target application executing a first process on the first quick application; wherein the first process is a process for running the quick application; if an exception occurs when the target application executes the first process on the first quick application, obtaining exception information; if the exception information indicates that the quick application engine has malfunctioned, executing processing for intercepting a second process; wherein the second process is used to control the target application to exit the application when an exception occurs when the target application executes the first process on the first quick application.
[0005] By intercepting the target application's exit from the application process caused by an exception in the Quick App engine, the target application can be prevented from exiting, thus avoiding infinite crashes and app crashes.
[0006] Optionally, the exception handling method further includes: displaying first information in the first quick app when the exception information indicates that an exception has occurred in the quick app engine; the first information is information indicating that an exception has occurred in the quick app.
[0007] Optionally, in response to the first operation, the target application performs a first process on the first quick app, including: in response to the first operation, determining whether the first quick app is recorded as an abnormal quick app; if it is determined that the first quick app is not recorded as an abnormal quick app, the target application performs the first process on the first quick app; the exception handling method further includes: if the exception information indicates that the quick app engine has encountered an exception, recording third information, the third information being used to indicate that the first quick app is recorded as an abnormal quick app.
[0008] Optionally, an exception occurs when the target application executes the first process of the first application, including: an exception occurs in the first thread running when the target application executes the first process of the first application.
[0009] Optionally, the processing for intercepting the second process is performed, including: if the exception information indicates that the first thread is a child thread, intercepting the second process, and displaying the first information in the first quick application according to the third information; the first information is information indicating that there is an exception in the quick application.
[0010] Optionally, the processing for intercepting the second process includes: if the exception information indicates that the first thread is the main thread, the target application exits the application and then restarts; after the target application restarts, the first information is displayed in the first quick application according to the third information; the first information is information indicating that the quick application has an exception; wherein the electronic device displays one of the first information and the second information in the first quick application; the second information is the page content of the first quick application created by the target application executing the first process on the first quick application.
[0011] Optionally, the third information is recorded, including: when the number of quick apps included in the target application is one, the third information is recorded; wherein the quick apps included in the target application are quick apps added to the target application from the quick service center, and the target application includes a first quick app.
[0012] Optionally, the exception information includes exception thread information; the first process includes a sub-process for creating the first application; the exception handling method further includes: updating the mapping information when the target application executes the sub-process on the first application, the mapping information being used to describe the mapping relationship between the first application and the threads running in the target application; and recording third information, including: recording the third information when the exception thread information matches the thread information in the mapping information.
[0013] Optionally, the exception handling method further includes: if an exception occurs when the target application executes the first process on the first application, determining whether the time interval between the last exception in the target application and the last exception exceeds an interval threshold; if it is determined that the time interval between the last exception in the target application and the last exception exceeds the interval threshold, clearing the exception count of the first application; and recording third information, including: incrementing the exception count of the first application by 1; and recording the third information if the updated exception count of the first application exceeds the first count threshold.
[0014] Optionally, the third information may be recorded, including: recording the third information when the survival time of the first quick application included in the target application does not exceed the duration threshold, or when the survival time of one or more other quick applications included in the target application exceeds the duration threshold.
[0015] Optionally, the exception handling method further includes: detecting abnormal quick applications from the quick applications included in the target application based on the exception information; wherein the quick applications included in the target application are quick applications added to the target application from the quick service center, and the target application includes a first quick application; recording third information, including: determining abnormal quick applications according to priority rules when no abnormal quick applications are detected; and recording third information when the first quick application is determined to be an abnormal quick application; wherein the priority rules include: determining abnormal quick applications in descending order of priority, with quick applications in the release state having a higher priority than quick applications in the online state.
[0016] Optionally, the exception handling method further includes: if an exception occurs when the target application executes the first process of the first quick application, determining whether the time interval between the last exception of the target application and the last exception exceeds an interval threshold; if it is determined that the time interval between the last exception of the target application and the last exception exceeds the interval threshold, clearing the target exception count; if no abnormal quick application is detected, incrementing the target exception count by 1; and recording third information, including: recording the third information if the updated target exception count exceeds the second count threshold.
[0017] Optionally, the exception handling method further includes: if the updated number of target exceptions does not exceed the third threshold, the target application exits the application; if the updated number of target exceptions exceeds the third threshold but does not exceed the second threshold, processing to intercept the second process is performed.
[0018] Optionally, the exception information includes exception stack information; the exception information indicates that an exception has occurred in the Quick App engine, including: the exception stack information contains information that matches the Quick App engine.
[0019] The specific technical implementation of any of the methods in the first aspect above can be found in the relevant technical descriptions in other embodiments of this application, and will not be repeated here.
[0020] Secondly, embodiments of this application provide an exception handling device applied to an electronic device, the electronic device including a target application, the exception handling device comprising: a detection module, configured to detect a first operation, the first operation being configured to request the target application to run a first quick application, the first quick application being any quick application; a first processing module, configured to, in response to the first operation, the target application execute a first process on the first quick application; wherein the first process is a process for running the quick application; an acquisition module, configured to acquire exception information when an exception occurs during the execution of the first process by the target application on the first quick application; and a second processing module, configured to, when the exception information indicates that an exception has occurred in the quick application engine, execute processing to intercept a second process; wherein the second process is configured to, when an exception occurs during the execution of the first process by the target application on the first quick application, control the target application to exit the application.
[0021] Thirdly, embodiments of this application provide a chip, including: a processor, which is configured to execute computer program instructions stored in a memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to execute the method as described in any of the first aspects.
[0022] Fourthly, embodiments of this application provide an electronic device, which includes one or more memories for storing computer program instructions and one or more processors, wherein when the computer program instructions are executed by one or more processors, the electronic device is triggered to perform the method as described in any of the first aspects.
[0023] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the method as described in any of the first aspects.
[0024] In a sixth aspect, embodiments of this application provide a computer program product, which includes a computer program that, when run on a computer, causes the computer to perform the method as described in any of the first aspects.
[0025] The technical effects of the aforementioned aspects can be used for reference, and will not be elaborated further here. Attached Figure Description
[0026] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly described below.
[0027] Figure 1a and Figure 1bThese are schematic diagrams illustrating the user interface for using Quick App cards, provided in some embodiments of this application.
[0028] Figure 2 A timing diagram of a card flow provided for one embodiment of this application;
[0029] Figure 3 A schematic diagram of a host application running a quick app card according to an embodiment of this application;
[0030] Figure 4 A sequence diagram showing the infinite crashes and shutdowns of host applications based on related technologies;
[0031] Figure 5 This is an illustration of a desktop crashing and freezing indefinitely under related technologies;
[0032] Figure 6a A schematic diagram of an exception handling system provided in one embodiment of this application;
[0033] Figure 6b A schematic diagram of an interface for displaying an anomaly catch-all image in a quick app card, provided as an embodiment of this application;
[0034] Figure 7 A flowchart illustrating an exception handling method provided in one embodiment of this application;
[0035] Figure 8 A flowchart illustrating another exception handling method provided in one embodiment of this application;
[0036] Figure 9 This is a schematic diagram illustrating the recording mapping information provided in one embodiment of this application;
[0037] Figure 10 A schematic diagram illustrating the lifespan of different Quick App cards according to one embodiment of this application;
[0038] Figure 11 A flowchart illustrating another exception handling method provided in one embodiment of this application;
[0039] Figure 12 A timing diagram of an exception handling method provided in one embodiment of this application;
[0040] Figure 13 A flowchart illustrating another exception handling method provided in one embodiment of this application;
[0041] Figure 14 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application;
[0042] Figure 15This is a schematic diagram of the software architecture of an electronic device provided in one embodiment of this application. Detailed Implementation
[0043] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0044] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0045] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0046] It should be understood that the term "at least one" as used in this document refers to one or more, and "more than one" refers to two or more. The term "and / or" as used in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. A and B can be singular or plural. Additionally, the character " / " in this document generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of singular or plural items. For example, at least one of a, b, and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0047] It should be understood that although the terms "first," "second," etc., may be used to describe the set thresholds in the embodiments of this application, these set thresholds should not be limited to these terms. These terms are only used to distinguish the set thresholds from each other. For example, without departing from the scope of the embodiments of this application, the first set threshold may also be referred to as the second set threshold, and similarly, the second set threshold may also be referred to as the first set threshold.
[0048] Quick Apps are a lightweight business model that can run as plug-ins within various host applications (or simply hosts), providing a superior user experience. Unlike traditional applications that require downloading and installation, Quick Apps can be used instantly without downloading or installing.
[0049] For example, the host application can be an application such as a desktop, a negative one screen, or a quick service center.
[0050] Optionally, Quick Apps can exist in the host application as Quick App cards. The host application can display Quick App cards to achieve the effect of showcasing Quick Apps.
[0051] See Figure 1a or Figure 1b As shown in the example, the card service interface 108 of the Quick Service Center can display the following quick app cards: "File Management" card 101, "Summer Fan" card 102, "Working Calendar" card 103, "Battery Emoji" card 104, and "Weather" card 105.
[0052] See Figure 1a As shown in the example, the desktop interface 109 can display a "Working Calendar" quick app card 111.
[0053] See Figure 1b As shown in the example, the interface 115 on the negative one screen can display the "Perpetual Calendar" quick app card 116, the "Popular Apps" quick app card 117, and the "Battery Emoji" quick app card 118 respectively.
[0054] Optionally, the Quick Service Center host application can contain multiple (or several) Quick App cards. Users can add, click, or perform other operations on the Quick App cards displayed in the Quick Service Center as needed. For example, users can add any Quick App card from the Quick Service Center to other host applications such as the desktop or the negative one screen as needed.
[0055] For example, if a user requests to add a Quick App card from the Quick Service Center to the desktop, the desktop responds to the user's add request by executing a card process (e.g., ...) for that Quick App card. Figure 2 (See the card flow diagram). After executing the card flow diagram on the desktop, the quick app card will be displayed on the desktop interface.
[0056] See Figure 1a As shown in the example, when a user needs to add the "Working Calendar" quick app card 103 to the desktop, they can click the add control 106 used to add the "Working Calendar" quick app card 103 to other host applications and select "Add to Desktop" to send an add request to the desktop. The desktop responds to the user's add request by executing a card flow for the requested quick app card. After the card flow is executed on the desktop, the "Working Calendar" quick app card 111 can be displayed on the desktop interface 109.
[0057] See Figure 1bAs shown in the example, when a user needs to add the "Battery Emoji" quick app card 104 to the negative one screen, they can click the add control 107 used to add the "Battery Emoji" quick app card 104 to other host applications, and select to add it to the negative one screen to send an add request to the negative one screen. The negative one screen responds to the user's add request by executing a card flow for the quick app card requested by the user. After the card flow is executed on the negative one screen, the interface 115 of the negative one screen can display the already added "Perpetual Calendar" quick app card 116 and "Popular Apps" quick app card 117, as well as the newly added "Battery Emoji" quick app card 118.
[0058] For example, after a user clicks the add control on any Quick App card, the Quick Service Center can display the add options through pop-ups or page redirects, allowing the user to choose which host application to add the Quick App card to.
[0059] After adding Quick App cards from the Quick Service Center to other host applications such as the home screen and the -1 screen, users can perform operations such as deleting, moving, and clicking on the Quick App cards added to other host applications as needed. For example, when a user clicks on a displayed Quick App card, the host application can redirect the displayed content to the content of the displayed Quick App card.
[0060] Optionally, based on the user's actions of adding or deleting quick app cards, there may be one or more quick app cards in the host application such as the desktop or the negative one screen, or there may be no quick app cards.
[0061] Optionally, during the operation of the host application, the quick app cards in the host application can be displayed or hidden.
[0062] See Figure 1a or Figure 1b As shown in the example, there may be multiple quick app cards in the quick service center. These multiple quick app cards may include quick app cards 101 to 105 displayed in the card service interface 108, as well as other quick app cards not displayed in the card service interface 108.
[0063] For example, if a user needs to view other quick app cards, they can swipe up on the card service interface 108. In response to this swipe up, the quick service center can hide the quick app cards displayed on the card service interface 108 and display the quick app cards not displayed on the card service interface 108.
[0064] See Figure 1a As shown in the example, there can be a Quick App card on the desktop, i.e. Figure 1aThe “Working Calendar” quick app card 111 is shown in the image. The desktop interface may include at least interface 109 and interface 113. The desktop may display the “Working Calendar” quick app card 111 while displaying interface 109 and hide the “Working Calendar” quick app card 111 while displaying interface 113.
[0065] For example, while the device is displaying the desktop interface 109, if the user needs to view the desktop interface 113, they can perform a right swipe operation 112 on the interface 109. In response to this operation 112, the desktop can display the interface 113 and hide the "Working Calendar" quick app card 111.
[0066] For example, while the device is displaying the desktop interface 113, if the user needs to view the desktop interface 109, they can perform a left swipe operation 114 on the interface 113. In response to this operation 114, the desktop can display the interface 109 and show the "Working Calendar" quick app card 111 in the interface 109.
[0067] join Figure 1b As shown in the example, there can be three quick app cards on the negative one screen, i.e. Figure 1b Quick App cards 116 to 118 are shown in the image. During operation, Quick App cards 116 to 118 can be displayed on interface 115 of the negative one screen.
[0068] For example, while the device is displaying the main desktop interface, if the user needs to view the interface 115 of the negative one screen, they can perform a right swipe operation on the main desktop interface. In response to the right swipe operation, the negative one screen can display interface 115 and show quick app cards 116 to 118 in interface 115.
[0069] Optionally, the card flow can be used to support the host application in managing the entire lifecycle of quick app cards (such as creation, loading, rendering, displaying, hiding, and destroying) to handle user operations such as adding, deleting, moving, and clicking quick app cards.
[0070] See Figure 2 The example shown may include at least (1) a card loading process, (2) a card parsing process, (3) a card rendering process, and (4) a card showing / hiding process. Optionally, the card process may also include Figure 2 Other processing procedures not shown, such as card deletion and card movement.
[0071] See Figure 2 The card loading process, card parsing process, and card rendering process are combined to create quick app cards.
[0072] For example, taking the desktop as an example, if a user requests to add a Quick App card from the Quick Service Center to the desktop, the desktop can sequentially execute the card loading process, card parsing process, and card rendering process for the requested Quick App card to create the Quick App card. After creating the Quick App card, the desktop can perform operations such as showing or hiding the created Quick App card.
[0073] For a user request to add a Quick App card to the desktop, the desktop can record that Quick App card. Afterwards, if the desktop restarts, it can sequentially execute the card loading process, card parsing process, and card rendering process to recreate the Quick App card.
[0074] See Figure 2 During the display / hiding process of a quick app card created by the host application, the host application can perform or repeatedly perform display / hiding related processes on the created quick app card in response to user control operations. For example, in some feasible examples, the user can perform control operations multiple times during the runtime of the host application. Exemplarily, the control operation could be, for example, the aforementioned downward swiping operation on the card service interface 108. Figure 1a The rightward sliding operation 112 shown is... Figure 1a The leftward sliding operation 114, etc., is shown in the figure.
[0075] See Figure 2 To support any host process (or the process of the host application) in executing card flows on any Quick App card, the Quick App Engine can provide a card-sdk to the host application. The Quick App Engine APK can include card-runtime (card runtime environment), engine services, and V8 services. APK stands for Android application package, meaning Android application package.
[0076] card-runtime can be used to manage the lifecycle of quick app cards (such as loading, unloading, etc.) and resource scheduling.
[0077] V8 services are internal services of the V8 engine and can be used as child processes of the engine process (or the fast app engine process). The V8 engine is a JavaScript engine that accelerates the execution of JavaScript code to improve application performance.
[0078] card-sdk is a card toolkit provided by the Quick App Engine for host applications. Through standardized interfaces and components, it enables host applications to quickly implement content display and logical interaction of Quick App cards.
[0079] See Figure 2 and Figure 3 As shown in the example, card-sdk can provide capabilities to host applications, enabling them to manage quick app cards throughout their entire lifecycle by calling card-sdk, in order to handle various operations performed by users on quick app cards.
[0080] For example, see Figure 3 If a user adds Quick App Card 1 (developed by Developer 1) to their desktop from the Quick Server Center, the desktop can call the card-sdk to execute the relevant steps in the card process to create and display Quick App Card 1. While Quick App Card 1 is displayed on the desktop, the user can perform operations such as hiding, destroying, or clicking on it. The desktop can then call the card-sdk to execute the relevant steps in the card process to respond to the user's actions. Understandably, this implementation logic also applies to Quick App Card 2 (developed by Developer 2) and Quick App Card 3 (developed by Developer 3), as well as other host applications, which will not be elaborated upon here.
[0081] like Figure 2 As shown, card-runtime can run in the host process, while engine services and V8 services can run in the engine process. The host service in the host process can communicate and interact with card-runtime in the host process by calling card-sdk, so that card-runtime can perform operations such as creating, displaying, and hiding quick app cards.
[0082] Figure 2 In the example shown, card-sdk and card-runtime can communicate and interact through classloader. IJsService is an inter-process communication interface that supports communication and interaction between the host process and the engine process. Therefore, card-runtime and the engine service can communicate through IJsService.
[0083] (1) Card loading process
[0084] Before the card loading process, the host service initiates the card creation process to begin creating the card, and then requests the card-runtime to create a card instance. After the card-runtime completes the card instance creation, it returns a notification to the host service that the card instance creation is complete. After the card instance is created, the host service requests the card-runtime to load the card so that the card-runtime can load the card data.
[0085] For example, card data may include a unique identifier for the Quick App card, such as a Uniform Resource Locator (URL) for the Quick App card. After loading the card data, card-runtime retrieves the card application resources for the Quick App card based on the card data. For example, card application resources may include information used to create the Quick App card, such as the Quick App card's installation package.
[0086] For example, see Figure 9 The steps for the card-runtime to load card data may include sequentially running the io thread "LoadUrl", the UI thread "LoadUrlInternal", and the io thread "LoadAppInfo". The io thread "LoadUrl" can be used to load the URL link of the Quick App card by calling the LoadUrl function; this thread can be a child thread. The UI thread "LoadUrlInternal" can be used to load the internal URL link of the Quick App card based on its URL link by calling the LoadUrlInternal function; this thread can be the main thread. The io thread "LoadAppInfo" can be used to load the Quick App card information based on its internal URL link by calling the LoadAppInfo function.
[0087] (2) Card parsing process
[0088] After obtaining the card application resources of the Quick App card, card-runtime can perform card runtime initialization and establish a communication connection with the V8 service in the Quick App Engine APK through the engine service in the Quick App Engine APK.
[0089] like Figure 2 As shown, card-runtime can send a request to the engine service to establish a communication connection with the V8 service. The engine service can then send a request to the V8 service to establish a JSBridge communication connection, enabling the V8 service to establish a JSBridge communication connection with card-runtime. After establishing the JSBridge communication connection with card-runtime, the V8 service can return a notification to the engine service indicating that the JSBridge binding is complete. The engine service can then send a notification to card-runtime indicating that the V8 binding is complete, thus completing the communication connection between card-runtime and the V8 service. This provides support for card-runtime to subsequently trigger the V8 service to build the quick app card page.
[0090] After establishing a communication connection with the V8 service, card-runtime can parse the obtained card application resources and send the parsed content to the V8 service to instruct it to build the Quick App card page accordingly. After building the Quick App card page, the V8 service can send a rendering event (Action) to card-runtime. Card-runtime can then execute the Event to construct a rendering Event object, thereby creating the Quick App card. An Event can represent an action to be performed.
[0091] (3) Card rendering process
[0092] card-runtime constructs a rendering event object by executing the rendering event Action sent by the V8 service, and sends a rendering completion notification to the host service after construction is complete. Upon receiving the rendering completion notification, the host service can trigger the card service in the host process to perform card display processing, so as to display the quick app card created by card-runtime on the host application's page.
[0093] (4) Card display / hide process
[0094] After creating a quick app card, card-runtime can call relevant functions based on the quick app card's lifecycle. For example, while the card service is displaying the quick app card, card-runtime can call the `onshow` function to perform card display-related operations, such as recording the quick app card's state as displayed. While the card service is hiding the quick app card, card-runtime can call the `onhide` function to perform card hiding-related operations, such as recording the quick app card's state as hidden. For instance, card display-related operations might include setting the quick app card's state to displayed and running a detection sub-thread.
[0095] During the execution of the card process by the host application, there may be issues such as abnormalities in the host application's own business logic or the Quick App engine, causing the host application to exit the application (or simply exit the application). The user interface changes upon exiting the application may manifest as an application crash or freeze.
[0096] Exceptions can occur at multiple points where the host application calls the card-sdk to execute the card process, and the frequency of these exceptions typically increases as the Quick App card business grows. For example, in... Figure 4 In the example shown, the card loading process, card parsing process, card rendering process, and card showing / hiding process in the card flow may all encounter abnormalities, causing the host application to exit.
[0097] In some feasible implementations, electronic devices can be equipped with a handler for catching and processing exceptions using TRY-CATCH. Exceptions caught using TRY-CATCH can be handled, preventing the host application from crashing. TRY-CATCH is a mechanism used in programming to catch and handle exceptions, primarily to prevent programs from crashing due to unhandled exceptions. For example, in one example... Figure 2 The exceptions in the card parsing process shown can be captured by the processor, so that the card parsing process does not cause the host application to exit, thus eliminating the risk of host application crashing or freezing.
[0098] For example, each processing step in the card flow can involve the execution of multiple threads. See, for example... Figure 9 During the card loading process, the input / output (IO) thread and the user interface (UI) thread can be switched multiple times.
[0099] In some examples, exceptions in the Quick App Engine typically occur when the thread running the card-runtime encounters an error during the host application's call to the card-sdk. The card-runtime is an internal component of the Quick App Engine APK; if the thread running the card-runtime encounters an error, and the host application cannot catch and handle the exception, it can cause the host application to exit. In other examples, exceptions in the Quick App Engine can also be other unknown exceptions that occur during the host application's call to the card-sdk.
[0100] If the host application exits and restarts due to an anomaly in its own business or a problem with the quick app engine, the existence of the anomaly can cause the host application to exit again, and so on, resulting in endless crashes and crashes of the host application, which affects the user experience.
[0101] In some examples, host applications such as the desktop can automatically restart after exiting, while host applications such as the Quick Service Center and the negative one screen can not automatically restart after exiting, but can be manually triggered by the user. For example, taking the negative one screen as an example, the electronic device can display the desktop after exiting the negative one screen. If the user then performs an operation to request the launch of the negative one screen, the negative one screen can be restarted.
[0102] In related technologies, for example, see Figure 4Exceptions can occur at multiple points in the host application's card-sdk execution process. These exceptions can cause the host application to exit during (or during) the card process execution. If the host application exits and is restarted, and then re-executes the card process, the exceptions can cause the host application to exit again, creating a loop that leads to the host application crashing and freezing indefinitely.
[0103] For example, see the desktop. Figure 5 The infinite crashing and reloading loop of the desktop can be as follows: the desktop executes the card process → an error occurs while the desktop is executing the card process and it exits (desktop crashes and reloads) → the desktop automatically restarts → the desktop executes the card process again.
[0104] Taking the example of a user adding a quick app card from the quick service center to the desktop, the infinite crashing and reloading loop of the desktop can be as follows: the desktop executes the card process for the quick app card requested by the user. If an exception occurs during the execution of the card process, the desktop exits. After the desktop exits, it can automatically restart and execute the card process again after restarting, and so on. Figure 5 The user interface changes in the illustrated loop process can manifest as the desktop crashing, freezing, and restarting an infinite number of times, impacting the user experience.
[0105] To address the issue of host applications crashing indefinitely due to exceptions in the Quick App engine, one embodiment of this application provides an exception handling method. This method, when an exception in the Quick App engine causes an exception in the host application's card flow execution, displays an exception fallback diagram to intercept the host application's exit process. This prevents the host application from exiting due to card flow exceptions, thereby avoiding infinite crashes and exits. For example, the host application exit process may include the step of terminating the host application's process.
[0106] In one example, in response to a user adding a Quick App card from the Quick Service Center to the desktop, the desktop executes a card flow for the Quick App card to create and display it. If an exception occurs in the Quick App engine, causing an error to occur during the desktop's card flow execution, the desktop can exit and restart, displaying an error fallback image in the Quick App card instead of re-executing the card flow for the Quick App card.
[0107] Compared to the page content of the quick app card created by the desktop's execution of the card process, the exception catch-all image can be used as a specific way to present the page content of the quick app card. The desktop can display the exception catch-all image within the quick app card to achieve the effect of displaying the quick app card's page content, instead of displaying the page content of the quick app card created by executing the card process. In other words, the desktop can replace executing the card process for the quick app card by displaying the exception catch-all image. By no longer executing the card process for the quick app card, the possibility of exceptions occurring when the desktop executes the card process can be avoided, thus ensuring normal desktop operation. Since the host application exit process is usually executed when the host application encounters an error, displaying the exception catch-all image can intercept the execution of the host application exit process on the desktop, preventing the desktop from exiting and thus avoiding infinite desktop crashes and freezes.
[0108] In one embodiment of this application, such as Figure 6a As shown, the exception handling system may include a remote configuration platform 603, a data monitoring platform 604, a big data platform 605, and an electronic device. The electronic device may include a host application 601 and a quick app engine 602. For example, the electronic device may be a terminal device such as a smartphone or tablet.
[0109] The quick app cards in host application 601 may include quick app card A and quick app card B. Host application 601 can execute card procedures for quick app card A and quick app card B respectively. If an exception occurs when host application 601 executes a card procedure for either quick app card, and the electronic device does not handle the exception, the exception may cause host application 601 to exit. See, for example. Figure 7 In step 711, if the number of exceptions recorded in step 711 does not exceed 5, the host application may choose not to handle the exception, thereby causing the host application to exit.
[0110] The Quick App Engine 602 may include an exception handler 6021 and a tracking component 6022.
[0111] The exception handler 6021 can, based on the detection of an exception in the host application 601, execute an automatic recovery mechanism if an exception occurs in the quick app engine 602, causing an exception in the execution of the card flow in the host application 601. The automatic recovery mechanism may include identifying the exception card, intercepting the host application's exit process, and displaying a fallback page (such as displaying an exception fallback image) in the exception card. For example, Figure 6b This shows an example of an interface where the desktop displays an exception catch-all diagram 600 in the exception card.
[0112] For example, if the Quick App engine malfunctions, causing the host application 601 to encounter an error while executing the card process for Quick App card A, the exception handler 6021 can determine that Quick App card A is an abnormal card and can display a fallback page in Quick App card A to intercept the execution of the host application exit process for the host application 601, thus preventing the host application 601 from exiting. Optionally, the specific technical implementation of exception handling by the exception handler 6021 can be found in [reference needed]. Figure 7 The relevant content in the illustrated embodiments will not be described in detail here.
[0113] The exception handler 6021 can also be used to obtain exception information and report it to the event tracking component 6022 when an exception occurs during the execution of the card process in the host application 601. The exception information may include the exception type, exception stack, and other information. For example, the exception type may be that the exception occurred during the execution of a child thread or during the execution of the main thread.
[0114] The event tracking component 6022 can report abnormal event tracking information to the big data platform 605 and trigger the data monitoring platform 604 to issue an anomaly monitoring alarm. For example, the event tracking component 6022 can use HASDK to report abnormal event tracking information. HASDK is a dynamic link library file in the Windows operating system.
[0115] Optionally, different tracking points can correspond to different types of information. For example, tracking point 001 corresponds to reporting an anomaly, and tracking point 002 corresponds to handling an anomaly (such as displaying an anomaly catch-all diagram in the anomaly card). Tracking component 6022 can obtain anomaly information based on tracking point 001 and report the anomaly information to big data platform 605. It can also obtain the number of anomaly handling operations of anomaly processor 6021 based on tracking point 002 and report the number of operations to big data platform 605.
[0116] The data monitoring platform 604 can perform anomaly monitoring and alarms according to alarm rules. For example, alarm rules may include: when the number of anomaly handling events in data statistics reaches a threshold, an anomaly monitoring alarm will be issued. When maintenance personnel receive an anomaly monitoring alarm notification from the data monitoring platform 604, they can upgrade (or update) the quick application engine based on the anomaly information stored in the big data platform 605.
[0117] The remote configuration platform 603 can control the on / off state of the exception handler 6021 and update the value of any parameter used by the exception handler 6021 to perform exception handling. For example, this parameter can be... Figure 7The illustrated embodiment includes duration thresholds and corresponding thresholds for various anomaly counts. By controlling the on / off state of the anomaly processor 6021 as needed, the stability of the electronic device's original services can be avoided when the anomaly processor 6021 malfunctions.
[0118] The remote configuration platform 603 can also control the exception handler 6021 to perform exception handling for some host applications (such as the desktop), while not performing exception handling for other host applications (such as the negative one screen). For example, the desktop can automatically restart after exiting. By performing exception handling on the desktop, the situation where the desktop crashes and freezes indefinitely in a short period of time due to an exception in the quick app engine can be avoided.
[0119] See Figure 7 One embodiment of this application provides an exception handling method, which may include steps 701 to 719. Understandably, Figure 7 The card described in the illustrated embodiment can be any quick app card.
[0120] Understandably, Figure 7 The parameters in the illustrated embodiments, such as the duration threshold and the number of times threshold, are just some feasible examples. The values of the parameters can also be set to other feasible values as needed in other embodiments of this application, and there is no limitation on this.
[0121] Optionally, Figure 7 The entity executing the exception handling method shown can be an electronic device. The electronic device may include an exception handler (such as the exception handler 6021 mentioned above), and execute exception handling-related steps by running the exception handler, such as steps 704 to 719 below.
[0122] See Figure 7 The exception handling method may include an exception determination process, an exception handling process, and an exception count clearing process.
[0123] like Figure 7 As shown, the exception determination process includes an exception cause determination process and an exception card determination process. See the following descriptions of each step in the exception card determination process. Figure 7 The exception handling method shown can cover all exception scenarios in the entire process, from loading, parsing, rendering, to displaying / hiding.
[0124] like Figure 7 As shown, the exception handling process includes a general exception handling process and a fallback exception handling process. The general exception handling process is applicable when the exception card determination process identifies a specific exception card, while the fallback exception handling process is applicable when the exception card determination process does not identify a specific exception card.
[0125] Step 701: Execute the card process.
[0126] In some examples, if a user requests to add any Quick App card from the Quick Service Center to other host applications such as the desktop or the negative one screen, the other host application can execute the card process for that Quick App card, such as the processing steps in the card process for loading, parsing, rendering, and showing / hiding the Quick App card.
[0127] In some examples, for any Quick App card in the host application, the host application can execute card flows for that Quick App card under various circumstances, such as restarting (e.g., restarting after exiting), having a version update of the Quick App engine, or reconnecting to the Quick App engine after the host application has lost connection. These flows might include steps for loading, parsing, rendering, and showing / hiding the Quick App card. For example, see [link to example]. Figure 2 Disconnecting the host application from the Quick App Engine can also disconnect the card-runtime from the V8 service.
[0128] In some examples, the host application can respond to user actions by performing card flows on any quick app card in the host application, such as performing processing steps in the card flow to show / hide, delete, or move the quick app card.
[0129] For example, if a user performs the above-described up / down swipe operation on the card service interface 108, the Quick Service Center can perform a show / hide process on the Quick App card; if the user performs Figure 1a The rightward swipe operation 112 shown can cause the desktop to perform a hiding process on the quick app card 111; if the user performs... Figure 1a The leftward swipe operation 112 shown in the figure allows the desktop to perform display processing steps on the quick app card 111; if the user performs an open operation... Figure 1b The operation of the negative one screen interface 115 shown can enable the negative one screen to perform display processing steps on quick app cards 116 to 118.
[0130] Step 702: An exception occurred while executing the card process.
[0131] For example, the reason why the host application encounters an error in executing the card process could be due to an error in the host application's own business logic or an error in the Quick App engine.
[0132] For example, an exception in the Quick App engine could be caused by an error occurring in the thread running the card-runtime during the host application's call to the card-sdk. Figure 4In the illustrated embodiment, the exception can occur at multiple points in the card process, such as when the card-runtime runs the aforementioned io thread "LoadUrl", or when the card-runtime runs the thread used to call the onshow function.
[0133] Step 703: Obtain exception information.
[0134] For example, exception information may include exception thread information and exception stack information. Referring to step 706 below, the exception stack information can be used to determine the cause of the exception. Referring to step 708 below, the exception thread information can be used to determine the exception card.
[0135] See Figure 8 The example shown can be derived from... Figure 8 The processor 1 shown acquires exception information. Processor 1 can be used to acquire exception information in real time when an exception occurs in the host application and record the timestamp of the exception. For example, Figure 6a The exception handler 6021 in the embodiment may include the processor 1.
[0136] Step 704: Determine whether the time elapsed since the last anomaly in the host application exceeds the time threshold. If yes, proceed to step 705; otherwise, proceed to step 706.
[0137] For example, the difference between the current time (such as the time when step 704 is executed) and the timestamp of the last exception in the host application can be used as the time since the last exception in the host application.
[0138] For example, the duration threshold can be any feasible value such as 1 minute, 5 minutes, or 10 minutes. By setting a smaller duration threshold, it is possible to prevent the host application from crashing and exiting indefinitely within a short period of time, thus affecting the user experience. Understandably, the reason for the last exception of the host application can be any reason that caused the host application to exit, and there is no limitation on this.
[0139] Step 705: Clear all recorded exception counts. Exception counts can be recorded in steps 711, 714, and 715 below. By executing step 705, various exception counts previously recorded by executing steps 711, 714, and 715 can be cleared (e.g., reset to zero).
[0140] Optionally, MMKV can be used to store all recorded exception counts within the host application. MMKV (Memory Mapped Key-Value storage) is a high-efficiency key-value storage component based on memory mapping, which can be used to store local data of the application. When using variables to store the count of exceptions, the exception counts stored in memory will be cleared when the host application restarts. In contrast, when using MMKV to store the recorded exception counts, it can be guaranteed that the stored exception counts will not be cleared after the host application restarts.
[0141] For host applications experiencing endless crashes within a short period, the time interval between two consecutive crashes is relatively short. To accurately address the issue of host applications experiencing endless crashes within a short period, all stored exception counts can be cleared when the time elapsed since the last exception does not exceed a time threshold. This can prevent the accumulation of exception counts from leading to misjudgments.
[0142] In step 705, if the interval between the current time of the exception and the last exception of the host application is large, it can be said that the host application does not currently have the risk of infinite crashes and crashes in a short period of time, and the impact of one or more crashes and crashes occurring intermittently over a long period of time on the user experience is small. In this way, when the time since the last exception of the host application is large, all recorded exception counts can be cleared.
[0143] If the interval between the current exception and the last exception in the host application is small, it indicates that the host application is at risk of crashing and disappearing indefinitely within a short period of time. Such crashes and disappearances indefinitely within a short period of time would have a significant impact on the user experience. In this case, if the time elapsed since the last exception in the host application is small, all recorded exception counts may not be cleared.
[0144] By clearing all recorded exception counts as needed, support can be provided for subsequent exception handling processes on demand, avoiding the execution of unnecessary exception handling procedures.
[0145] Step 706: Based on the exception stack trace, determine if the Quick App engine is malfunctioning. If so, proceed to step 707; otherwise, do not intercept the host application exit process. The host application exit process is used to control the host application's exit from the application.
[0146] Step 706 above is used to determine the cause of the exception based on the exception stack information. The cause of the exception may be an exception in the host application's own business or an exception in the quick app engine.
[0147] When an exception occurs in the host application's own business logic, the exception handler may not intercept the host application's exit process, thus not handling the exception; however, the existence of the exception can still cause the host application to exit. But when an exception occurs in the Quick App engine, the exception handler can further determine the exception card and then execute the exception handling process as needed. See steps 707-710; the exception card can be determined by combining the exception thread information and the scenario information.
[0148] For example, if the exception stack information indicates that an exception occurred during the host application's call to the Quick App Engine's card-sdk, then the cause of the exception can be determined to be an exception in the Quick App Engine; otherwise, the cause of the exception can be determined to be an exception in the host application's own business logic.
[0149] Optionally, the pathname related to card-sdk can be matched from the exception stack trace. A successful match indicates that an exception occurred during the host application's call to card-sdk, and the cause of the exception is an error in the Quick App engine. A failed match indicates that the exception did not occur during the host application's call to card-sdk, and the cause of the exception is an error in the host application's own business logic.
[0150] In one embodiment, see Figure 8 The exception handling method may include the following steps 801 to 803.
[0151] Step 801: Determine whether there is a path name related to card-sdk in the exception stack information. If so, determine that the exception is caused by an exception in the quick application engine and execute step 802. If not, determine that the exception is caused by an exception in the host application's own business and do not intercept processor 2.
[0152] Processor 2 can be used to execute the host application exit process when an exception occurs in the host application, in order to control the host application to exit the application.
[0153] When the cause of the exception is an anomaly in the host application's own business logic, it is usually not possible to resolve the exception by displaying an exception fallback diagram to intercept the host application's exit process. In this case, processor 2 can be left uninterrupted to avoid intercepting the host application's exit process.
[0154] Step 802: Execute the abnormal card identification process.
[0155] Step 803: Execute the general / backup exception handling process.
[0156] For the specific technical implementation of steps 802 to 803, please refer to [reference needed]. Figure 7 The relevant steps in the illustrated embodiments will not be described in detail here.
[0157] See Figure 8The example exception stack trace shows a pathname "org.hapjs.honorcard" related to the card-sdk, indicating an exception occurred during the host application's call to the card-sdk. This confirms that the exception is caused by a problem with the Quick App engine. Once the Quick App engine is identified as the cause, step 802 can be executed to further identify the problematic card.
[0158] Step 707: Determine if there is only one card in the host application. If yes, proceed to step 714; otherwise, proceed to step 708.
[0159] Figure 7 In the illustrated embodiment, if it is determined that there is only one card in the host application, it can be indicated that the current usage scenario is a single-card scenario. This can be considered an abnormal card, and step 714 can be executed for that card. For example, see... Figure 4 An exception can occur at any point during the card processing flow.
[0160] If it is determined that there are multiple cards in the host application, it can be said that the current usage scenario is a multi-card scenario. In this case, step 708 can be executed to try to identify the abnormal card from the multiple cards through card matching.
[0161] See one example. Figure 1a In response to the user adding the "Working Calendar" quick app card 103 to the desktop, the desktop executes the card process. If an exception occurs during the execution of the card process, step 707 can determine that there is only one card in the host application. For example, the exception can be an exception that occurs during any of the processing steps of loading, parsing, rendering, or displaying the card process.
[0162] See another example. Figure 1a In response to the user's left swipe operation 114, the desktop executes the card flow. If an exception occurs during the desktop's execution of the card flow, step 707 can determine that there is only one card in the host application. For example, the exception can be an exception that occurs when the desktop executes the display processing step in the card flow.
[0163] Step 708: Perform card matching based on the mapping information and abnormal thread information.
[0164] See Figure 2The card loading, parsing, and rendering processes in the card flow are used to create quick app cards. Each thread running during card-runtime corresponds to a quick app card. This allows for real-time updates to the mapping relationship between the threads running card-runtime and the quick app cards. For example, the mapping information between the thread ID and the card ID of the quick app card can be updated in real time. Card matching can then be performed based on the recorded mapping information and abnormal thread information.
[0165] During the card display / hide process in the card flow, the thread running by card-runtime to call the onshow / onhide functions corresponds to multiple cards (multi-card scenario in step 708), rather than a single card. For example, card-runtime can run a thread to call the onshow function when displaying any card, making the mapping relationship between threads and cards one-to-many rather than one-to-one. Therefore, it is usually impossible to identify the abnormal card from multiple cards by recording mapping information. Furthermore, exceptions during card display / hide can occur not only due to thread execution errors but also due to UI-specific errors. Thus, it is possible to avoid recording mapping information during card display / hide.
[0166] Optionally, in each processing step of the card flow for creating a Quick App card, the thread ID can be mapped to the card ID of the Quick App card before each thread runs, so as to generate or update the mapping information in real time. For example, see... Figure 9 When switching threads, the thread ID can be updated based on the ID of the new thread.
[0167] During the creation of Quick App cards, the threads running the card-runtime can be allocated by the thread pool in the electronic device, which usually prevents multiple Quick App cards from occupying the same thread at the same time. This ensures the accuracy of the mapping relationship, which helps to accurately identify abnormal cards from multiple cards based on the mapping relationship.
[0168] Figure 9 In the illustrated embodiment, it is assumed that the processor in the electronic device can use TRY-CATCH to capture and handle exceptions during the card parsing process, so that the exception does not cause the host application to exit and there is no risk of exception during the card parsing process. Thus, mapping information does not need to be recorded during the card parsing process.
[0169] For example, see Figure 9The card loading process includes the sequential execution of the io thread "LoadUrl", the UI thread "LoadUrlInternal", and the io thread "LoadAppInfo". The card rendering process includes a rendering thread for rendering the card. Thus, when the io thread "LoadUrl" starts running, the mapping between its thread ID "161" and the card ID "com.example.demo1" of the quick app card is recorded. When the UI thread "LoadUrlInternal" starts running, the mapping between its thread ID "1" and the card ID "com.example.demo1" is updated. When the UI thread "LoadAppInfo" starts running, the mapping between its thread ID "189" and the card ID "com.example.demo1" is updated. When the rendering thread starts running, the mapping between its thread ID "116" and the card ID "com.example.demo1" is updated.
[0170] For example, suppose an exception occurs when the card-runtime runs the UI thread "LoadUrlInternal". The exception thread information may include the thread ID "1". In this way, the corresponding quick app card can be identified as the exception card based on the real-time mapping relationship between the thread ID "1" and the card ID "com.example.demo1".
[0171] For example, if an exception occurs when the card-runtime is running the rendering thread, the exception thread information can include the thread ID "116". In this way, the corresponding Quick App card can be identified as the exception card based on the real-time mapping relationship between the thread ID "116" and the card ID "com.example.demo1".
[0172] Step 709: Determine if a card is matched. If yes, proceed to step 715; otherwise, proceed to step 710.
[0173] For example, see Figure 2 If an exception occurs during the creation of a Quick App card in the card process, the exception thread information can be the ID of the thread running at the time of the exception. This ID can match the thread ID in the recorded mapping information. Therefore, if card matching determines that the thread ID in the exception thread information matches the thread ID in the mapping information (i.e., a card is matched), then the Quick App card corresponding to the card ID in the mapping information can be identified as an exception card.
[0174] For example, referring to step 715, if the number of exceptions for the matched quick app card in step 708 does not exceed 5 after incrementing by one, the host application can execute the card process again for multiple quick app cards in the host application after restarting. If an exception occurs when creating the quick app card, the quick app card can be identified as an abnormal card again after card matching, so that the number of exceptions for the quick app card is incremented by one again. This process is repeated until the number of exceptions is greater than 5, at which point the general exception handling process is executed for the quick app card.
[0175] If no card is matched during card matching, it means that the card process did not encounter an error during the creation of the Quick App card, but rather during the display / hiding of the Quick App card. In this case, you can continue to step 710.
[0176] For example, see Figure 1b If the user clicks control 107 and selects to add it to the negative one screen, the desktop can execute the card flow for the "Battery Emoji" quick app card 104. During the card display step of the card flow, the negative one screen can call the onshow function to perform display-related operations. If an exception occurs in the thread used to call the onshow function, the exception thread information can include the thread's ID, and the card cannot be matched using card matching based on the exception thread information.
[0177] For example, after the desktop restarts, a card flow can be executed for each of the multiple quick app cards on the desktop. In the card display step of the card flow, the desktop can call the `onshow` function to perform display-related operations. If an exception occurs in the thread used to call the `onshow` function, the exception thread information can include the thread's ID, and the card cannot be matched using card matching based on the exception thread information.
[0178] Step 710: Determine if only one card's survival time is below a time threshold. If yes, proceed to step 716; otherwise, proceed to step 711. For example, the time threshold could be 10 seconds.
[0179] When it is determined in step 707 that there are multiple cards in the host application, it can be said that the usage scenario when executing step 710 is a multi-card scenario. If the lifespan of one card in the host application is lower than the time threshold, while the lifespan of one or more other quick app cards in the host application is not lower than the time threshold, it can be said that the current usage scenario is a multi-card scenario with abnormal new card issuance, and the newly issued card is an abnormal card. For example, one card issuance scenario is adding a quick app card from the quick service center to another host application.
[0180] In some examples, the start time for the lifespan of a Quick App card can be the time when a user requests to add the Quick App card from the Quick Service Center to another host application, or it can be the time when another host application begins to execute the card process for the Quick App card, for example, it can be... Figure 2 The illustrated embodiment shows the start time of card creation. The end time of a Quick App card's lifespan can be the moment when an error occurs during the host application's card execution process.
[0181] For example, in a scenario involving multiple cards and an abnormal new card issuance, a user sequentially requests to add Quick App Card 1, Quick App Card 2, and Quick App Card 3 to the desktop. For instance, the user can click the add control for Quick App Card 1 in the Quick Service Center and select "Add to Desktop." The desktop responds to the user's action by executing the card process for Quick App Card 1. If no abnormality occurs when the desktop executes the card process for Quick App Card 1, the electronic device can display the desktop and show Quick App Card 1 on the desktop interface. Afterward, the user can return to the Quick Service Center, click the add control for Quick App Card 2, and select "Add to Desktop." This process repeats until an abnormality occurs when the desktop executes the card process for Quick App Card 3.
[0182] See Figure 10 In the example shown, in response to each card addition operation by the user, the desktop executes the card process sequentially for Quick App cards 1 through 3. Assuming no exceptions occur when the desktop executes the card process for Quick App cards 1 and 2, but an exception occurs when executing the card process for Quick App card 3, then the survival time ΔT1 of Quick App card 1 and the survival time ΔT2 of Quick App card 2 are not lower than the time threshold, while the survival time ΔT3 of Quick App card 3 is lower than the time threshold. Therefore, it can be determined that the newly added Quick App card 3 is an abnormal card.
[0183] In scenarios involving multiple cards and abnormal new card issuance, a general exception handling process can be executed on the identified abnormal cards without accumulating the exception counts for the abnormal cards as shown in steps 714 and 715. This ensures accurate handling of abnormal cards in this scenario because: if the exception counts for abnormal cards are accumulated, the host application can exit and restart. After restarting, the host application can execute the card process for each card individually until another exception occurs. After the host application restarts, the start time of each card's lifespan is updated accordingly, for example, it can be updated to the moment when the host application starts executing the card process for the card after restarting. This would make the start times of each card's lifespan usually very similar, easily leading to a situation where the lifespan of each card is less than the time threshold. Consequently, executing step 710 would yield a negative judgment result, which does not meet the expected judgment.
[0184] If step 710 yields a negative result, it indicates that the specific abnormal card was not identified from the multiple cards in the abnormal card determination process. The exception that occurs when the host application executes the card process is usually a UI-related exception, such as an exception occurring in the thread running when the host application displays / hides a certain application card, or an exception caused by other unknown circumstances. In this case, a fallback exception handling process can be executed.
[0185] Figure 7 In the illustrated embodiment, steps 707 to 710 can be executed sequentially. In other feasible embodiments, the order of execution of these steps is not limited. For example, steps 708 and 709 can be executed first, followed by step 707.
[0186] Step 711: Record the number of exceptions +1. If the number of exceptions after the update is ≤5, do not intercept the host application exit process. If the number of exceptions after the update is >5 and ≤8, intercept the host application exit process. If the number of exceptions after the update is >8, execute step 712.
[0187] Understandably, since no specific exception card is identified during the exception card identification process, the exception count recorded in step 711 is not specific to any particular exception card. The exception count can be incremented each time step 711 is executed. If the updated exception count does not exceed 5, the exception can be left unhandled, and the host application exit process can be left uninterrupted. In this case, the host application can exit, for example, the desktop can exit and automatically restart.
[0188] After the host application exits and restarts, the card process can be executed for each quick app card in the host application until an exception occurs again, which may lead to the re-execution of step 711, and so on. In this way, the host application can exit and restart 5 times in a loop, so as to avoid unnecessary exception handling without significantly affecting the user experience (these 5 crashes can be regarded as normal crashes, not infinite crashes).
[0189] If the number of exceptions exceeds 5 but does not exceed 8 after the update, the exception can be left unhandled, but the host application's exit process can be blocked. For example, if the desktop includes multiple quick app cards, when a user requests to display these multiple quick app cards, the desktop can execute the display processing steps in the card flow for each quick app card, and an exception may occur during the execution of the display processing steps. This exception will increment the exception count in step 711 by 1, but will not cause the host application to exit. Since the occurrence of exceptions can lead to the accumulation of exception counts without causing the host application to exit, unnecessary exception handling can be avoided without significantly affecting the user's UI experience.
[0190] If the number of exceptions exceeds 8 after the update, it can be considered that the host application has crashed indefinitely. In this case, the exception needs to be handled to prevent the host application from continuing to crash indefinitely. Step 712 can be executed to handle the exception and prevent the host application from continuing to crash indefinitely.
[0191] Step 712: Record the card package name and timestamp, without intercepting the host application's exit process, and execute step 713 after the host application restarts. The recording rules include recording the light card first, followed by the JS card.
[0192] Optionally, the corresponding quick app card can be recorded as an exception card in the exception catch-all image to be displayed by recording the card package name.
[0193] In one example, the timestamp recorded in step 712 could be the timestamp of the last time the host application encountered an exception during the execution of the card process, such as the timestamp of when the exception information was obtained in step 703.
[0194] Light cards represent Quick App cards in the release phase, which tend to have a relatively high probability of error. JS cards represent Quick App cards in a stable online state, which tend to have a relatively low probability of error. Therefore, following a priority strategy, light cards can be first recorded as abnormal cards and an error fallback diagram can be displayed. If, after displaying the error fallback diagram for a light card, the host application still encounters errors during card execution, then JS cards can be recorded as abnormal cards and an error fallback diagram can be displayed, until error fallback diagrams are displayed for all Quick App cards in the host application.
[0195] In other feasible examples, the types of Quick App cards may also include card types other than Light Cards and JS Cards, and the priority strategy can be applied to various types of cards without limitation.
[0196] Understandably, if a specific abnormal card is not identified during the abnormal card identification process, the fallback abnormal handling process can sequentially display the fallback abnormal image for each quick app in the host application until the host application is no longer abnormal, or display the fallback abnormal image for all quick app cards in the host application. Therefore, displaying the fallback abnormal image for a particular quick app card during the fallback abnormal handling process does not necessarily mean that the quick app card is actually an abnormal card.
[0197] Step 713: Display the exception catch-all image in the card according to the card package name.
[0198] Referring to steps 712 and 713, if the number of exceptions after the update exceeds 8, the card package name and timestamp can be recorded according to a priority strategy, and the host application's exit process can be left uninterrupted, allowing the host application to exit. After the host application exits and restarts, an exception fallback diagram can be displayed in the corresponding quick app card based on the recorded card package name and timestamp, thus eliminating the need to execute the card process for the corresponding quick app card. If the quick app card is an actual exception card, by not executing the card process for that quick app card, there is no possibility of an exception occurring during the execution of the card process, thus supporting the normal operation of the host application and preventing the host application from continuing to crash and freeze indefinitely.
[0199] Optionally, after the host application starts (e.g., after exiting and restarting), it can determine whether the time interval since the last exception of the host application does not exceed a corresponding threshold based on the recorded card package name and timestamp. If it does not exceed the threshold, an exception fallback image can be displayed in the corresponding quick app card based on the card package name. If it exceeds the threshold, the recorded card package name and timestamp can be cleared.
[0200] See Figure 11 In one embodiment, the exception handling method may include the following steps 1101 to 1106.
[0201] Step 1101: Start the host application.
[0202] After the host application starts, such as after it exits and restarts, the card process can be executed separately for each quick app card in the host application.
[0203] Step 1102: Determine if it is an abnormal card. If yes, proceed to step 1103; otherwise, proceed to step 1106.
[0204] For example, see Figure 12 After the host application exits and restarts, card-runtime can determine whether the corresponding quick app card has been recorded as an abnormal card when it receives a request to create a card instance.
[0205] For example, whether a Quick App card is recorded as an abnormal card can be determined by whether its package name is recorded. If the Quick App card's package name is recorded, it can be determined that the Quick App card is recorded as an abnormal card; otherwise, it is not recorded as an abnormal card.
[0206] Step 1103: Determine whether the time elapsed since the last anomaly in the host application exceeds the time threshold. If yes, proceed to step 1104; otherwise, proceed to step 1105.
[0207] For example, the timestamp and the duration since the last anomaly of the host application can be determined based on the recorded package name and timestamp. If the duration exceeds the duration threshold, it can be indicated that the host application does not currently have the risk of infinite crashes and exits in a short period of time. In this way, the recorded package name and timestamp can be cleared and the card process can be executed.
[0208] If the duration does not exceed the duration threshold, it indicates that the host application is at risk of crashing and exiting indefinitely within a short period of time. In this case, an exception fallback diagram can be displayed in the corresponding quick app card based on the recorded package name, instead of executing the card process.
[0209] Step 1104: Display the exception catch-all diagram in the exception card.
[0210] Step 1105: Clear the package name and timestamp.
[0211] Step 1106: Execute the card process.
[0212] Optionally, after displaying the exception fallback diagram in step 713, if no exceptions occur when the host application executes the card process for other quick app cards, the number of exceptions recorded in step 711 can be reset, for example, to zero.
[0213] Step 714: Increment the number of exceptions recorded by 1. If the updated number of exceptions is greater than 5, proceed to step 716. If the updated number of exceptions is less than or equal to 5, do not intercept the host application's exit process.
[0214] By limiting the execution of step 716 to when the number of exceptions exceeds 5, the general exception handling process can be avoided for exception cards in the event of accidental crashes or freezes of the host application.
[0215] If the number of exceptions after the update is ≤5, the host application's exit process will not be intercepted, and the occurrence of exceptions may cause the host application to exit. After the host application exits and restarts, the card process can be executed again for a quick app card within the host application.
[0216] Step 715: Increment the number of exceptions recorded by 1. If the updated number of exceptions is greater than 5, proceed to step 716. If the updated number of exceptions is less than or equal to 5, do not intercept the host application's exit process.
[0217] If the number of exceptions after the update is ≤5, and the host application's exit process is not intercepted, the occurrence of exceptions can cause the host application to exit. After the host application exits and restarts, the card process is executed again for each quick app card in the host application.
[0218] Step 716: Determine if the child thread is abnormal. If yes, proceed to step 717; otherwise, proceed to step 718.
[0219] If a specific abnormal card is identified during the abnormal card identification process, a general abnormal handling process can be executed on the abnormal card.
[0220] When an exception occurs during the main thread's runtime, it's usually impossible to prevent the host application from exiting by intercepting its exit process. For example, if the host application's Looper crashes when an exception occurs in the main thread, different exception handling methods can be applied to the child thread exception and the main thread exception in the general exception handling process. Looper is a core component in the Android operating system used to manage thread message queues.
[0221] For example, see Figure 9 If an exception occurs while the card-runtime is running the I / O thread "LoadUrl", the exception thread information may include the thread ID of that sub-thread. The exception can be identified by the thread ID. If an exception occurs while the card-runtime is running the UI thread "LoadUrlInternal", the exception thread information may include the thread ID of that main thread. The exception can be identified by the thread ID.
[0222] Step 717: Intercept the host application's exit process, record the card package name and timestamp, and execute step 719.
[0223] Referring to steps 717 and 719, if the thread running when an exception occurs is a sub-thread, it can intercept the host application's exit process to prevent the host application from exiting. It can also record the card package name and timestamp of the identified exception card. Then, based on the recorded card package name and timestamp, it can display the exception fallback diagram in the corresponding quick app card to resolve the exception, support the normal operation of the host application, and prevent the host application from continuing to crash and regress indefinitely.
[0224] Step 718: Record the card package name and timestamp, do not intercept the host application exit process, and execute step 713 after the host application restarts.
[0225] Referring to steps 718 and 719, if the thread running when an exception occurs is the main thread, it can record the card package name and timestamp of the identified exception card without intercepting the host application's exit process, allowing the host application to exit. After the host application exits and restarts, the exception fallback diagram can be displayed in the corresponding quick app card based on the recorded card package name and timestamp. This eliminates the need to execute the card process for the corresponding quick app card, thus preventing exceptions from occurring during card process execution. This supports the normal operation of the host application and effectively prevents the host application from continuing to crash and freeze indefinitely.
[0226] Step 719: Display the exception catch-all image in the card according to the card package name.
[0227] Optionally, after the host application starts (e.g., after exiting and restarting), it can determine whether the time interval since the last exception of the host application does not exceed a corresponding threshold based on the recorded card package name and timestamp. If it does not exceed the threshold, an exception fallback image can be displayed in the corresponding quick app card based on the card package name. If it exceeds the threshold, the recorded card package name and timestamp can be cleared.
[0228] Optionally, after displaying the anomaly catch-all diagram in step 719, the number of anomalies for the card can be reset, for example, to zero.
[0229] Figure 7 The exception handling method provided in the illustrated embodiment can address the problem of exceptions occurring when the host application executes the card process due to exceptions in the Quick App engine, and can prevent the host application from crashing and exiting indefinitely in a short period of time due to exceptions in the Quick App engine.
[0230] See Figure 12 In one embodiment of this application, the exception handling method may include: when an exception occurs during the execution of the card process in the host application, card-runtime determines the cause of the exception. If the cause of the exception is determined to be an exception in the Quick App engine, the exception card is identified and recorded (e.g., the card package name and timestamp are recorded). The host application can then exit and restart. After the host application crashes and restarts, the host service recreates the Quick App cards in the host application and requests card-runtime to create card instances. Based on the request to create card instances, when card-runtime detects that a Quick App card is recorded as an exception card, it does not execute the card process for the Quick App card to intercept the card process and notifies the host service to display an exception fallback image in the Quick App card. Based on the notification to display the exception fallback image in the Quick App card, the host service triggers the card service to perform the card exception fallback image display processing to display the exception fallback image in the Quick App card. By intercepting card processes that may result in exceptions, exception fallback protection can be provided, supporting the normal operation of the host application and preventing the host application from crashing and exiting indefinitely.
[0231] For example, a user adds a Quick App card X from the Quick Service Center to the desktop when the desktop does not yet contain any Quick App cards. The desktop responds to the user's action by executing the card process for Quick App card X. If an exception occurs during the card process, the exception handler can determine the cause of the exception. If the cause is an exception in the Quick App engine, it determines whether there is only one card on the desktop. Since there is only Quick App card X on the desktop, the exception count for Quick App card X is incremented by 1. If the updated exception count does not exceed 5, the desktop exits and restarts. After restarting, the desktop executes the card process for Quick App card X again, and another exception occurs. Thus, the exception count for Quick App card X is incremented again. This cycle repeats until the updated exception count exceeds 5. At this point, the exception handler executes a general exception handling process for Quick App card X. This either displays a fallback image in Quick App card X when an exception occurs in a child thread (in which case the desktop crashes and freezes 5 times in a loop), or displays a fallback image in Quick App card X after the desktop exits and restarts again when an exception occurs in the main thread (in which case the desktop crashes and freezes 6 times in a loop). Thus, an anomaly in the Quick App engine may cause the desktop to crash and recur 5 or 6 times (which can be considered a normal crash and recursion of the host application that is acceptable to the user), but it will not cause the desktop to crash and recur indefinitely.
[0232] Figure 12 The specific technical implementation of the anomaly fallback protection process in the illustrated embodiment can be found in the relevant descriptions in other embodiments of this application, and will not be repeated here.
[0233] See Figure 12 In one embodiment of this application, after executing the exception fallback protection process, the electronic device can also execute an automatic repair process. The automatic repair process may include: the engine service performing version repair on card-runtime to upgrade the engine; the repaired card-runtime re-executing the relevant processing steps in the card process, and no exceptions occurring during the execution, normally completing the rendering steps of the quick app card; and after rendering is completed, notifying the host service to restore the card view based on the rendering result. Then, the host service can use the card service to perform card display processing to show the quick app card created by card-runtime.
[0234] For example, in the event of an anomaly in the Quick App engine, maintainers can upgrade the engine to fix the issue. The upgraded Quick App engine can then be updated on the electronic device; for instance, the device can upgrade the Quick App engine when a user requests to use a Quick App card. After the Quick App engine upgrade, the host application can execute the card process again without encountering an anomaly, thus enabling the creation of Quick App cards. Subsequently, the host service can switch from displaying an anomaly fallback image in the Quick App card to displaying the page content of the created Quick App card, thereby restoring the card view of the Quick App card.
[0235] Optionally, when restoring the card view of a quick app card, the electronic device may delete the record for the corresponding card package name.
[0236] Figure 12 The exception handling method shown can monitor the host application's exceptions through the Quick App Engine without involving cross-process communication, and provide fallback protection against exceptions. Figure 12 The illustrated embodiment can achieve the effects of monitoring, locating, processing, and recovering card anomalies.
[0237] like Figure 13 As shown, this application provides an exception handling method applied to an electronic device, the electronic device including a target application, the method may include steps 1301 to 1304.
[0238] For example, the electronic device can be a smartphone, tablet computer, or other terminal device.
[0239] For example, the target application can be any host application, such as the desktop, the negative one screen, the quick service center, etc.
[0240] Step 1301: A first operation is detected. The first operation is used to request the target application to run a first quick application. The first quick application can be any quick application.
[0241] Optionally, the first operation can be any user operation in other embodiments of this application, such as any user operation exemplified in step 701 above.
[0242] The first quick app can be any quick app that the target app can run. The first quick app can also be any quick app included in the target app, meaning the quick apps included in the target app are those added to the target app from the quick service center, and can include quick apps that have already been added and those that are being added. For example, the first operation could be a request to display quick app cards in the target app, or a request to add the first quick app to the target app.
[0243] Optionally, Quick Apps can exist as Quick App cards. For example, when a user requests to add a Quick App card from the Quick Service Center to the desktop, the desktop can create and display the Quick App card to run it.
[0244] Step 1302: In response to the first operation, the target application executes the first process on the first quick application; wherein, the first process is the process used to run the quick application.
[0245] For example, the first process can be the card process described in any other embodiment of this application, such as... Figure 2 The card flow is shown.
[0246] For example, the specific technical implementation of the first process performed by the target application can be found in the description of step 701 above.
[0247] Step 1303: If an exception occurs when the target application executes the first process on the first application, obtain the exception information.
[0248] During the execution of the first process by the target application on the first application, an exception may or may not occur. For example, for the case where an exception occurs during the execution of the first process, please refer to the relevant description in step 702 above.
[0249] For example, the specific technical implementation for obtaining abnormal information can be found in the relevant description of step 703 above.
[0250] Step 1304: If the exception information indicates that the quick app engine has encountered an exception, execute the processing to intercept the second process; wherein, the second process is used to control the target application to exit the application when an exception occurs when the target application executes the first process on the first quick app.
[0251] In one embodiment, the exception information includes exception stack information; the exception information indicates that the Quick App engine has encountered an exception, including: the exception stack information contains information matching the Quick App engine. For example, see [link to relevant documentation]. Figure 8 In the illustrated embodiment, if the exception stack information in the exception information contains a path name related to the Quick App engine, it can be determined that the exception information indicates that the Quick App engine has encountered an exception, rather than indicating that the target application's own business has encountered an exception.
[0252] For example, see Figure 8 When an exception occurs in the target application, processor 2 can execute the host application exit procedure to control the target application to exit the application. If an exception occurs when the target application executes the first procedure for the first application block, the second procedure can be a processing procedure in which processor 2 executes the host application exit procedure for the target application based on the occurrence of the exception.
[0253] Figure 13 The embodiment shown intercepts the exit of the target application caused by the exception when the host application fails to execute the first process of the quick application due to an exception in the quick application engine. This prevents the target application from exiting the application and avoids the target application from crashing and exiting indefinitely.
[0254] In one embodiment, the exception handling method further includes: displaying first information in the first quick application when the exception information indicates that an exception has occurred in the quick application engine; the first information is information indicating that the quick application has an exception. By displaying the first information in the first quick application, the target application can facilitate the user's awareness that the first quick application has an exception.
[0255] For example, the first information can be the anomaly catch-all image described in other embodiments of this application. In one example, the page content of the anomaly catch-all image of the Quick App card can be as follows: Figure 6b The card page 600 is shown in the image.
[0256] In one embodiment, in response to a first operation, the target application performs a first process on the first quick application, including: in response to the first operation, determining whether the first quick application is recorded as an abnormal quick application; if it is determined that the first quick application is not recorded as an abnormal quick application, the target application performs the first process on the first quick application; the exception handling method further includes: if the exception information indicates that the quick application engine has encountered an exception, recording third information, the third information being used to indicate that the first quick application is recorded as an abnormal quick application.
[0257] For example, third-party information can be recorded by recording the card package name and timestamp.
[0258] For example, it can be determined whether the first quick app is recorded as an abnormal quick app based on whether the card package name of the first quick app is recorded. See, for example, [link to relevant documentation]. Figure 7 After recording the card package name in step 718, the host application exits and restarts. After restarting, the host application can display the exception fallback image in the corresponding quick app card according to the recorded card package name, without executing the card process on the quick app card.
[0259] In one embodiment, in response to the first operation, if it is determined that the first quick app is recorded as an abnormal quick app, the target app can display the first information in the first quick app. See, for example, [link to relevant documentation]. Figure 11 The processing logic in the example shown is that after the host application starts, if the user performs the first operation, the host application can respond to the first operation and determine whether the first quick application is recorded as an abnormal quick application based on whether the third information is recorded. If so, the first information can be displayed in the first quick application; otherwise, the first process can be executed on the first quick application as needed.
[0260] In one embodiment, an exception occurs when the target application executes the first process of the first application, including: an exception occurs in the first thread running when the target application executes the first process of the first application. Thus, the exception information may include exception thread information. For example, referring to step 708 above, the exception thread information can be used to determine the exception application, and referring to step 716 above, the exception thread information can be used to perform different types of exception handling as needed.
[0261] For example, see Figure 4 The first thread can be any thread that runs during the process of the host application calling the card-sdk.
[0262] In one embodiment, the process for intercepting the second process includes: if the exception information indicates that the first thread is a child thread, intercepting the second process, and displaying the first information in the first quick application based on the third information; the first information is information indicating that the quick application has an exception.
[0263] For example, see Figure 7 Step 716, as shown, intercepts the host application's exit process in the event of a sub-thread exception, preventing the exception from causing the host application to exit. Based on the recorded card package name, an exception fallback image is displayed in the corresponding quick app card, replacing the card page content created by executing the card process. Since the exception does not cause the host application to exit, this effectively prevents the target application from crashing indefinitely.
[0264] In one embodiment, the process for intercepting the second process includes: restarting the target application after it exits the application if the exception information indicates that the first thread is the main thread; after the target application restarts, displaying the first information in the first quick application according to the third information; the first information is information indicating that the quick application has an exception; wherein the electronic device displays one of the first information and the second information in the first quick application; the second information is the page content of the first quick application created by the target application executing the first process on the first quick application.
[0265] For example, see Figure 7 In step 716 shown, if the main thread is abnormal, the card package name is recorded and the host application exits. After the host application restarts, the abnormal fallback diagram is displayed in the corresponding quick app card according to the recorded card package name, and the card process is not executed on the quick app card. Therefore, there is no problem of an abnormality occurring when executing the card process on the quick app card. Thus, there is no problem of the abnormality causing the host application to exit. This can avoid the target application from crashing and exiting indefinitely.
[0266] In the event of an exception in the main thread, the host application can be prevented from exiting by not executing the card process after the host application exits and restarts, thus preventing the exception from occurring and avoiding the host application from crashing and exiting indefinitely.
[0267] In one embodiment, recording the third information includes: recording the third information when the number of quick apps included in the target application is one; wherein the quick apps included in the target application are quick apps added to the target application from the quick service center, and the target application includes a first quick app. If the number of quick apps included in the target application is one, it can indicate that an abnormal quick app has been detected, and the detected abnormal quick app is the first quick app.
[0268] For example, see Figure 7 In step 706 shown, if there is only one Quick App card in the host application, the Quick App card can be identified as an abnormal card, thus enabling accurate identification of abnormal cards.
[0269] In one embodiment, the exception information includes exception thread information; the first process includes a sub-process for creating a first quick application; the exception handling method further includes: updating mapping information when the target application executes the sub-process on the first quick application, the mapping information describing the mapping relationship between the first quick application and the threads running in the target application; recording third information, including: recording the third information if the exception thread information matches the thread information in the mapping information. If they match, it can indicate that an exception quick application has been detected, and the detected exception quick application is the first quick application.
[0270] For example, the mapping information can be a mapping relationship between a quick app ID and a thread ID.
[0271] For example, see Figure 7 Steps 708 and 709 shown can be used to match cards based on mapping information and abnormal thread information. If a quick app card is matched, the quick app card can be identified as an abnormal card, thus enabling accurate identification of abnormal cards.
[0272] In one embodiment, the exception handling method further includes: when an exception occurs during the execution of the first process by the target application on the first application, determining whether the time interval between the last exception of the target application and the last exception exceeds an interval threshold (e.g., 5 minutes); if it is determined that the time interval between the last exception of the target application and the last exception exceeds the interval threshold, clearing the exception count of the first application; and recording third information, including: incrementing the exception count of the first application by 1; and recording the third information if the updated exception count of the first application exceeds the first count threshold (e.g., 5 times).
[0273] For example, see Figure 7Steps 714 and 715 shown can record the card package name only when the number of exceptions of the abnormal card exceeds the threshold. This can avoid performing the general exception handling process on abnormal cards in the event of accidental crashes or freezes of the host application.
[0274] For example, see Figure 7 Steps 704 and 705 shown can clear the number of exceptions for the abnormal card as needed, which can accurately deal with the problem of the host application crashing and disappearing indefinitely in a short period of time, and can avoid misjudgment caused by the accumulation of the number of exceptions.
[0275] In one embodiment, recording the third information includes: recording the third information when the survival time of the first quick application included in the target application does not exceed a duration threshold (e.g., 10 seconds), and the survival time of one or more other quick applications included in the target application exceeds the duration threshold. If only the survival time of the first quick application does not exceed the duration threshold, it can be indicated that an abnormal quick application has been detected, and the detected abnormal quick application is the first quick application.
[0276] For example, see Figure 7 Step 710 shown can accurately identify usage scenarios with multiple cards and abnormal new card issuance based on the lifespan of the Quick App card, and can accurately determine the abnormal card in this scenario.
[0277] In one embodiment, the exception handling method further includes: detecting abnormal quick applications from the quick applications included in the target application based on exception information; wherein the quick applications included in the target application are quick applications added to the target application from the quick service center, and the target application includes a first quick application; recording third information includes: determining abnormal quick applications according to priority rules when no abnormal quick applications are detected; and recording third information when the first quick application is determined to be an abnormal quick application; wherein the priority rules include: determining abnormal quick applications in descending order of priority, with quick applications in the release state having a higher priority than quick applications in the online state.
[0278] For example, a quick app in the release state can be the light card mentioned above, and a quick app in the online state can be the JS card mentioned above.
[0279] For example, see Figure 7 Step 711 shown can determine the exception card according to the priority rule if the exception card determination process fails to determine the specific exception card, so as to carry out the fallback exception handling process. This can deal with the problem of infinite crashes and exits of the host application in this case.
[0280] In one embodiment, the exception handling method further includes: when an exception occurs when the target application executes the first process of the first quick application, determining whether the time interval between the last exception of the target application and the last exception exceeds an interval threshold (e.g., 5 minutes); if it is determined that the time interval between the last exception of the target application and the last exception exceeds the interval threshold, clearing the target exception count; if no abnormal quick application is detected, incrementing the target exception count by 1; and recording third information, including: recording the third information if the updated target exception count exceeds a second threshold (e.g., 8 times).
[0281] For example, the target number of anomalies could be the number of anomalies recorded in step 711 above.
[0282] For example, see Figure 7 Steps 714 and 715 shown can record the card package name only when the number of target exceptions exceeds the threshold. This can avoid executing the fallback exception handling process in case of accidental crashes or freezes of the host application.
[0283] For example, see Figure 7 Steps 704 and 705 shown can clear the target number of exceptions as needed, which can accurately deal with the problem of the host application crashing and exiting indefinitely in a short period of time, and can avoid misjudgment caused by the accumulation of exceptions.
[0284] In one embodiment, the exception handling method further includes: if the updated target exception count does not exceed the third threshold (e.g., 5 times), the target application exits the application; if the updated target exception count exceeds the third threshold but does not exceed the second threshold, processing to intercept the second process is performed. The third threshold is less than the second threshold.
[0285] For example, see Figure 7 As shown in step 711, if the number of exceptions after the update does not exceed 5, the second process can be left uninterrupted, thus avoiding unnecessary exception handling without significantly impacting the user experience. If the number of exceptions after the update exceeds 5 but does not exceed 8, the exceptions can be left unhandled, but the host application's exit process can be blocked. This avoids unnecessary exception handling without significantly impacting the user's UI experience.
[0286] Figure 13 The specific technical implementation of the exception handling method shown can be found in the relevant technical descriptions in other embodiments of this application, and will not be repeated here.
[0287] The method provided in any embodiment of this application can be applied to electronic devices such as mobile phones, tablets, personal digital assistants (PDAs), desktops, laptops, notebook computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, and wearable devices. This application does not impose any special limitations on the specific form of the aforementioned electronic devices.
[0288] The method provided in any embodiment of this application can be applied to... Figure 14 In the electronic device 100 shown. Figure 14 A schematic diagram of the structure of the electronic device 100 is shown.
[0289] Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.
[0290] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0291] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.
[0292] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0293] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0294] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0295] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0296] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0297] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0298] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory located in the processor.
[0299] A touch sensor, also known as a "touch device," can be located on the display screen 194. The touch sensor and the display screen 194 together form a touchscreen, also known as a "touchscreen." The touch sensor detects touch operations applied to or near it. The touch sensor can then transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In some embodiments, the touch sensor may also be located on the surface of the electronic device 100, in a different position than the display screen 194.
[0300] In addition, the electronic device runs an operating system on top of the aforementioned components. For example... operating system, operating system, Operating systems, etc. Applications can be installed and run on an operating system.
[0301] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0302] Figure 15 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into multiple layers, from top to bottom: application layer, application framework layer (Framework, FWK), system library and runtime layer, hardware abstraction layer (HAL), and kernel layer.
[0303] The application layer can include a series of application packages, such as camera, gallery, calendar, calling, map, navigation, WLAN, Bluetooth, music, video, SMS and other applications.
[0304] The application framework layer provides an Application Programming Interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example... Figure 15 As shown, the application framework layer may include a view system, a phone manager, a notification manager, a resource manager, a window manager, a content provider, etc.
[0305] The system library and runtime layer includes the system library and the Android Runtime.
[0306] System libraries can include multiple functional modules. For example: 3D graphics processing libraries (e.g., OpenGL ES), surface managers, 2D graphics engines (e.g., SGL), media libraries, etc.
[0307] The Android runtime consists of the core libraries and the virtual machine. The Android runtime is responsible for scheduling and managing the Android system. The core libraries comprise two parts: one part contains the functionalities that Java calls, and the other part is the core Android library itself. The application layer and application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0308] The Hardware Abstraction Layer (HAL) acts as a bridge between software and hardware. It encapsulates the underlying hardware driver, providing a generic interface for the application framework to call the driver. The HAL is an abstract interface for the device kernel driver, providing application programming interfaces (APIs) for accessing the underlying device to higher-level Java API frameworks. The HAL contains multiple library modules, each implementing an interface for a specific type of hardware component. The HAL provides APIs for higher-level Java API frameworks to access the underlying device; when an API framework requests access to the electronic device's hardware, the Android system loads the corresponding library module for that hardware component.
[0309] The Hardware Abstraction Layer (HAL) can communicate with the application framework layer through the Hardware Abstraction Layer Interface Definition Language (HIDL). HIDL is an interface description language that specifies the interface between HAL and FWK.
[0310] The kernel layer is the layer between hardware and software. It can include camera drivers, display drivers, Bluetooth drivers, audio drivers, sensor drivers, as well as Ultra Wide Band (UWB) drivers, touchscreen drivers, IoT device management drivers, and more. The kernel layer is the foundation of the Android system, through which the system's final functionalities are implemented.
[0311] Understandable, Figure 15 The layers in the illustrated software structure and the components contained in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer layers than illustrated, and each layer may include more or fewer components; this application does not impose any limitations.
[0312] This application also provides a chip, which is installed in an electronic device. The chip includes a processor for executing computer program instructions stored in a memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to execute the method steps provided in any method embodiment of this application.
[0313] This application also proposes a terminal device, which includes a communication module, a memory for storing computer program instructions, and a processor for executing the program instructions. When the computer program instructions are executed by the processor, the terminal device is triggered to execute the method steps provided in any method embodiment of this application.
[0314] This application also proposes a server device, which includes a communication module, a memory for storing computer program instructions, and a processor for executing the program instructions. When the computer program instructions are executed by the processor, the server device is triggered to execute the method steps provided in any method embodiment of this application.
[0315] This application also provides an electronic device, which includes multiple antennas, a memory for storing computer program instructions, a processor for executing the computer program instructions, and a communication device (such as a communication module that can implement 5G communication based on the NR protocol). When the computer program instructions are executed by the processor, the electronic device is triggered to execute the method steps provided in any method embodiment of this application.
[0316] Specifically, in the embodiments of this application, one or more computer programs are stored in the aforementioned memory, and the one or more computer programs include instructions that, when executed by the aforementioned device, cause the aforementioned device to perform the method steps described in the embodiments of this application.
[0317] Furthermore, the devices, apparatuses, and modules described in the embodiments of this application may be implemented by computer chips or physical entities, or by products with certain functions.
[0318] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.
[0319] In the several embodiments provided in this application, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0320] Specifically, this application also provides a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to execute the method steps provided in this application.
[0321] This application also provides a computer program product, which includes a computer program that, when run on a computer, causes the computer to perform the method steps provided in this application.
[0322] In this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0323] Those skilled in the art will readily understand that, for the sake of convenience and brevity, similar or identical parts between the various embodiments of this application can be referred to mutually. For example, the specific working processes of the systems, devices, and units described in the embodiments of this application can be referred to the corresponding processes in the method embodiments of this application, and will not be repeated here.
[0324] The above description is merely a specific embodiment of this application and is not intended to limit this application. The scope of protection of this application shall be determined by the claims.
Claims
1. An abnormality processing method characterized by comprising: Applied to an electronic device, the electronic device including a target application, the method includes: A first operation is detected, the first operation being used to request the target application to run a first quick application, the first quick application being any quick application; In response to the first operation, the target application executes a first process on the first quick application; wherein, the first process is a process for running the quick application; If an exception occurs when the target application executes the first process on the first fast application, obtain exception information; If the error message indicates that the Quick App Engine has encountered an error, the process for intercepting the second process is executed; The second process is used to control the target application to exit the application if an exception occurs when the target application executes the first process on the first application.
2. The method of claim 1, wherein, The method further includes: When the abnormal information indicates that the quick app engine has malfunctioned, first information is displayed in the first quick app; the first information is information indicating that the quick app has malfunctioned.
3. The method of claim 1, wherein, In response to the first operation, the target application executes a first process on the first fast application, including: In response to the first operation, determine whether the first quick app is recorded as an abnormal quick app; If it is determined that the first quick application has not been recorded as an abnormal quick application, the target application executes the first process on the first quick application; The method further includes: When the abnormal information indicates that the quick app engine has malfunctioned, a third piece of information is recorded, which indicates that the first quick app is recorded as an abnormal quick app.
4. The method of claim 3, wherein, An exception occurred when the target application executed the first process on the first fast application, including: An exception occurred in the first thread running when the target application executed the first process on the first fast application.
5. The method of claim 4, wherein, The execution of the process for intercepting the second process includes: If the exception information indicates that the first thread is a child thread, the second process is intercepted, and the first information is displayed in the first quick application according to the third information; the first information is information indicating that the quick application has an exception.
6. The method of claim 4, wherein, The execution of the process for intercepting the second process includes: If the exception message indicates that the first thread is the main thread, the target application will be restarted after exiting the application. After the target application is restarted, the first information is displayed in the first quick application according to the third information; the first information is information indicating that the quick application has an anomaly. The electronic device displays one of the first information and the second information in the first quick application; the second information is the page content of the first quick application created by the target application executing the first process on the first quick application.
7. The method of claim 3, wherein, The recorded third information includes: If the number of quick apps included in the target application is one, the third information is recorded; The target application includes quick applications added from the quick service center to the target application, and the target application includes the first quick application.
8. The method of claim 3, wherein, The abnormal information includes abnormal thread information; The first process includes a sub-process for creating the first quick application; The method further includes: When the target application executes the sub-process on the first fast application, the mapping information is updated. The mapping information is used to describe the mapping relationship between the first fast application and the threads running in the target application. The recorded third information includes: If the abnormal thread information matches the thread information in the mapping information, the third information is recorded.
9. The method according to claim 7 or 8, characterized in that, The method further includes: If an exception occurs when the target application executes the first process on the first fast application, determine whether the time interval since the last exception occurred in the target application exceeds an interval threshold. If it is determined that the time interval between the last occurrence of an anomaly in the target application exceeds the interval threshold, the number of anomalies in the first application is cleared. The third information recorded includes: Increment the number of exceptions for the first fast application by 1; If the number of anomalies in the updated first application exceeds the threshold of the first time, the third information is recorded.
10. The method of claim 3, wherein, The recorded third information includes: If the survival time of the first quick application included in the target application does not exceed the duration threshold, or if the survival time of one or more other quick applications included in the target application exceeds the duration threshold, the third information is recorded.
11. The method of claim 3, wherein, The method further includes: Based on the anomaly information, detect abnormal quick applications from the quick applications included in the target application; The target application includes quick applications added from the quick service center to the target application, and the target application includes the first quick application; The recorded third information includes: If no abnormal fast app is detected, the abnormal fast app is identified according to the priority rules. If the first fast application is determined to be an abnormal fast application, the third information is recorded; The priority rules include: determining abnormal quick apps in descending order of priority, with quick apps in the release state having a higher priority than quick apps in the online state.
12. The method of claim 11, wherein, The method further includes: If an exception occurs when the target application executes the first process on the first fast application, determine whether the time interval since the last exception occurred in the target application exceeds an interval threshold. If it is determined that the time interval since the last anomaly in the target application exceeds the interval threshold, the target anomaly count is cleared. If no abnormal fast application is detected, increment the target abnormal count by 1; The third information recorded includes: If the number of target anomalies exceeds the second threshold after the update, the third information is recorded.
13. The method of claim 12, wherein, The method further includes: If the updated number of target anomalies does not exceed the third threshold, the target application exits the application. If the updated number of target anomalies exceeds the third threshold but does not exceed the second threshold, then the process for intercepting the second process is executed.
14. The method of claim 1, wherein, The exception information includes exception stack information; The exception information indicates that the Quick App engine has encountered an error, including: the exception stack information contains information that matches the Quick App engine.
15. A chip, characterized by include: A processor for executing computer program instructions stored in memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to perform the method as described in any one of claims 1-14.
16. An electronic device, comprising: The electronic device includes one or more memories for storing computer program instructions and one or more processors, wherein when the computer program instructions are executed by the one or more processors, the electronic device is triggered to perform the method as described in any one of claims 1-14.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1-14.
18. A computer program product, characterized in that, The computer program product includes a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1-14.
