An application self-repairing method, device, equipment and storage medium

By using the application self-healing method, the native components automatically obtain exception information and generate patch files to repair the front-end components, solving the problem of relying on manual and internet-based repair in existing technologies and achieving fast and automatic application repair.

CN113806118BActive Publication Date: 2025-12-23TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202010544714.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-15
Publication Date
2025-12-23
Estimated Expiration
2040-09-10

AI Technical Summary

Technical Problem

In existing technologies, when an application malfunctions, technical personnel are required to locate the defect and fix the code, and patch packages are distributed via the Internet, resulting in high costs in terms of manpower, network resources, and time.

Method used

The application's self-repair method automatically obtains exception information through native components, analyzes the target file using a syntax analyzer and generates a patch file for repair, thus achieving autonomous repair.

Benefits of technology

It reduced reliance on technical personnel and network resources, significantly improved repair speed and efficiency, and reduced manpower and communication costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113806118B_ABST
    Figure CN113806118B_ABST
Patent Text Reader

Abstract

The application discloses an application program self-repairing method and device, equipment and storage medium, the method comprises the following steps: acquiring the abnormal information generated by the front-end component, wherein the abnormal information comprises abnormal type information and abnormal position information; reading the target file pointed by the abnormal position information; obtaining the corresponding syntax analysis matcher according to the abnormal type information; analyzing the target file based on the syntax analysis matcher and the abnormal position information to obtain a target abnormal code segment; repairing the target abnormal code segment according to the abnormal type information to obtain a patch file; and repairing the front-end component based on the patch file. The application can automatically locate and correct the abnormality of the front-end component, repair the front-end component in the form of the patch file, does not need manual participation, can be automatically implemented, and does not need to interact with the server, so that the repair speed can be improved, the labor cost and the communication cost can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of application program repair, and in particular to an application program self-repair method, device, equipment and storage medium. BACKGROUND

[0002] The hybrid development mode has gradually become the mainstream mode of application program development in the smart terminal market. Compared with traditional native development and page development, the hybrid development mode can significantly improve the repair speed of the application program because it can support hot update technology for application program repair.

[0003] However, if the application program has an exception, even if the hot update technology is used, technical personnel need to be involved in defect positioning and code repair, and then a patch package is generated, which is then distributed to the smart terminal to achieve the repair of the application program. This process will produce a large time delay, and the dependence on technical personnel is high, the demand for network resources is also high, and it cannot be repaired in an offline state. Moreover, the hot update technology is subject to the publisher of the operating system to some extent, and it is also difficult to freely implement full autonomous hot update. SUMMARY

[0004] Based on the hot update technology, the application program running on the smart terminal needs to rely on technical personnel to locate defects and repair codes to generate a patch package, and needs to rely on the Internet to distribute the patch package from the server to the smart terminal before the application program running on the smart terminal can be repaired. This process has high labor cost, network resource cost and time cost. In order to solve this technical problem, the present application embodiment discloses an application program self-repair method, device, equipment and storage medium.

[0005] On the one hand, the present application provides an application program self-repair method, the application program comprising a front-end component and a native-end component, the method being applied to the native-end component, and the method comprising:

[0006] If the front-end component has an exception, obtaining exception information generated by the front-end component, the exception information comprising exception type information and exception location information;

[0007] If the self-repair mechanism is started to repair the exception, reading a target file pointed to by the exception location information;

[0008] According to the exception type information, obtaining a corresponding syntax analysis matcher;

[0009] Based on the syntax analysis matcher and the exception location information, analyzing the target file to obtain a target exception code segment;

[0010] According to the exception type information, repairing the target exception code segment to obtain a patch file;

[0011] repairing the front-end component based on the patch file.

[0012] In another aspect, the present application provides an application program self-repairing device, the application program comprising a front-end component and a native end component, the device comprising:

[0013] an exception information capturing module configured to capture exception information generated by the front-end component, the exception information comprising exception type information and exception location information;

[0014] a target file reading module configured to read a target file pointed to by the exception location information if the self-repairing mechanism is started to repair the exception;

[0015] a syntax analysis matcher obtaining module configured to obtain a corresponding syntax analysis matcher according to the exception type information;

[0016] a target exception code segment positioning module configured to analyze the target file based on the syntax analysis matcher and the exception location information to obtain a target exception code segment;

[0017] a patch file generating module configured to repair the target exception code segment according to the exception type information to obtain a patch file;

[0018] a repairing module configured to repair the front-end component based on the patch file.

[0019] In another aspect, the present application provides a computer readable storage medium, characterized in that the computer readable storage medium stores at least one instruction or at least one program, the at least one instruction or at least one program is loaded and executed by a processor to implement the above-mentioned application program self-repairing method.

[0020] In another aspect, the present application provides an application program self-repairing device, characterized in that the device comprises a processor and a memory, the memory stores at least one instruction or at least one program, the at least one instruction or at least one program is loaded and executed by the processor to implement the above-mentioned application program self-repairing method.

[0021] The present application provides an application program self-repairing method, device, equipment and storage medium. When an exception occurs in the front-end component of an application program, the native end component of the application program can automatically locate and correct the exception of the front-end component, and repair the front-end component in the form of a patch file. This process does not require human intervention and can be fully automated. Moreover, it is not mandatory to interact with a server, which can significantly improve the repair speed and reduce labor costs and communication costs. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. Obviously, the accompanying drawings in the following description only show some embodiments of the present application, and for those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0023] Figure 1 is a flowchart of an application self-repairing method provided by the present application;

[0024] Figure 2 is a schematic diagram of a hybrid development mode architecture provided by the present application;

[0025] Figure 3 is a flowchart of obtaining exception information generated by the front-end component provided by the present application;

[0026] Figure 4 is a flowchart of starting judgment of the self-repairing mechanism provided by the present application;

[0027] Figure 5 is a flowchart of analyzing the target file based on the syntax analysis matcher and the exception position information, and obtaining a target exception code segment provided by the present application;

[0028] Figure 6 is a first matching flowchart provided by the present application;

[0029] Figure 7 is a flowchart of repairing the target exception code segment according to the exception type information, and obtaining a patch file provided by the present application;

[0030] Figure 8 is a flowchart of repairing the front-end component based on the patch file provided by the present application;

[0031] Figure 9 is a flowchart of starting failure processing provided by the present application;

[0032] Figure 10 is a schematic diagram of a product interface of hot updating in the prior art provided by the present application;

[0033] Figure 11 is a schematic diagram of a product interface corresponding to the embodiments of the present application provided by the present application;

[0034] Figure 12 is a block diagram of an application self-repairing device provided by the present application;

[0035] Figure 13 is a schematic diagram of a hardware structure of a device for implementing the method provided by the embodiments of the present application. DETAILED DESCRIPTION

[0036] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0037] It should be noted that the terms "first", "second" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or server including a series of steps or units need not be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0038] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the embodiments of the present application, and are not used to limit the embodiments of the present application.

[0039] Hereinafter, the terms "first", "second" are only used for description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more features. In the description of the embodiments, unless otherwise specified, the meaning of "a plurality of" is two or more. In order to facilitate the description of the embodiments of the present application, first, the technical terms related to the embodiments of the present application are described:

[0040] Hybrid: There are three development methods for applications running on smart terminals, namely, native development, HTML5 development and hybrid development. Native development is developed on a smart operating system (Android, iOS) using the official development language, development library and development tool. Native development cannot be cross-platform and can only be applied to the corresponding operating system. HTML5 development is developed using page technology, which can be cross-platform but has great limitations in functionality and cannot interact with the hardware resources of the smart terminal. Hybrid development is a development mode that combines native development and HTML5 development to achieve the effect of taking the advantages of each other. It is usually composed of two parts, page front-end development and client-side development, and has the significant advantages of realizing multiple functions and fast iteration speed.

[0041] Hot update: It is a common update method in hybrid development mode. After the application is installed on the smart terminal, it can be updated immediately by interacting with the server to obtain the patch file when it is opened. Hot update dynamically issues code, which enables developers to fix defects and release functions without publishing new versions, allowing developers to bypass the review mechanism of Apple and avoid long waiting for review and the cost caused by multiple rejections. However, it is also restricted by Apple, for example, Apple App Store can require the publisher of the application related to hot update to remove the relevant code and accept the review.

[0042] Smart terminal: Also known as mobile smart terminal, it refers to a class of devices with rich human-computer interaction methods, internet access capability, various smart operating systems and strong processing capability. Mobile smart terminals include smartphones, tablet computers, vehicle-mounted terminals, handheld game consoles, etc. The smart operating system includes but is not limited to Android operating system and iOS operating system.

[0043] JIT: Dynamic compilation, which means "compiling at runtime", is the compilation of a piece of code when it is about to be executed for the first time, which can also be called "just-in-time compilation". JIT compilation can also be considered as a special case of dynamic compilation in some scenarios.

[0044] ReactNative: An open-source cross-platform mobile application development framework.

[0045] Weex: A framework for developing high-performance native applications using page development experience.

[0046] JSBridge: It is a communication interface that allows the front-end part of hybrid development to easily use native functions, and it is a bridge between native components and non-native components. Its core is to build a channel for message communication between native components and non-native components, and this communication channel is bidirectional.

[0047] Bundle: A new application resource package launched by Google, which can effectively reduce the package size and improve startup speed.

[0048] Repairing applications running on smart terminals using hot update technology requires technical personnel to locate defects and repair code to generate patch packages. Furthermore, the patch packages need to be distributed from the server to the smart terminal via the internet before the application can be repaired. This process incurs high costs in terms of manpower, network resources, and time. To address this technical problem, this invention provides an application self-repair method. This method enables applications to automatically repair their own defects while running on smart terminals, reducing reliance on technical personnel and network resources, significantly improving repair efficiency, and shortening repair time.

[0049] This invention provides a self-healing method for an application, wherein the application includes a front-end component and a native component, and the method is applied to the native component, such as... Figure 1 As shown, it includes:

[0050] S101. If an exception occurs during the operation of the front-end component, obtain the exception information generated by the front-end component, the exception information including exception type information and exception location information.

[0051] like Figure 2 As shown, the hybrid development model consists of two parts: front-end development and client-side development. Front-end development yields front-end components, while client-side development yields native components. The interaction between these front-end and native components enables the application to run on smart devices. Front-end components can be dynamically compiled and executed on smart devices. These components are typically cross-platform, written using cross-platform frameworks and languages, such as React Native or Weex. Native components run on the client-side and can be components that run on Android or iOS.

[0052] Specifically, the exception type information is used to indicate the type of exception. In fact, analysis of application crash scenarios reveals that the causes of application crashes can be categorized into a limited number, such as crashes caused by boundary issues or non-standard coding. These crash causes can be captured by the front-end components when the application crashes, thereby generating exception type information.

[0053] In one embodiment, the anomaly location information includes the error file name and the error location, wherein the error location can be characterized by the row and column numbers in the error file.

[0054] In another embodiment, the exception information can further include additional error information, which can be used to record other information related to the exception, and the additional error information can be optional, and the content of the additional error information can be configured based on a first preset template.

[0055] In one embodiment, the front-end component can generate exception information based on the exception, and send the exception information to the native end component based on a bidirectional communication channel. Specifically, the bidirectional communication channel can be JSBridge.

[0056] In another embodiment, the front-end component can generate exception information based on the exception, and send the exception information to the native end component based on a bidirectional communication channel. Specifically, the bidirectional communication channel can be JSBridge. Figure 3 As shown, the method comprises the following steps:

[0057] S1011. Setting a monitoring thread.

[0058] S1013. Capturing exception information based on the monitoring thread, wherein the exception information is generated and thrown by the front-end component based on the exception.

[0059] S103. If the self-repair mechanism is started to repair the exception, reading a target file pointed by the exception location information.

[0060] In one embodiment, the self-repair mechanism can be selectively triggered. When the self-repair mechanism is configured to be turned on, the exception can be repaired based on the self-repair mechanism, i.e., the application self-repair method according to the embodiments of the present application is executed. When the self-repair mechanism is configured to be turned off, the exception is not repaired based on the self-repair mechanism. In one optional embodiment, when the self-repair mechanism is configured to be turned off, the exception information can be uploaded to a server by the native end component, so that the server repairs the application based on a hot update method.

[0061] In another embodiment, the exception type can also be selectively set. Only limited exception types can be set to support self-repair, and only the exception types set to support self-repair can be repaired based on the application self-repair method according to the embodiments of the present application.

[0062] In one embodiment, the selective triggering of the self-repair mechanism can be configured in a second preset template, the abnormal type can be configured in a third preset template, and the second preset template, the third preset template and the first preset template can be combined. The first preset template, the second preset template and the third preset template can be recorded in the form of a configuration table, the configuration table can be issued by a server and stored locally in an intelligent terminal, and the configuration table can organize data in the form of a Map. The Map can be understood as a dictionary data structure.

[0063] Specifically, before step S103, as shown in the figure, it further includes: Figure 4

[0064] S1. determining whether to start the self-repair mechanism in the second preset template;

[0065] S3. If yes, determining whether the abnormal type pointed to by the abnormal type information is configured to support self-repair in the third preset template;

[0066] S5. If yes, determining to start the self-repair mechanism to repair the abnormality.

[0067] If it is determined not to start the self-repair mechanism to repair the abnormality, the abnormality information is uploaded to the server by the native end component, so that the server repairs the application program based on a hot update method.

[0068] In one embodiment, the reading of the target file pointed to by the abnormal position information includes:

[0069] S10. finding the target file with an abnormality under the resource directory according to the abnormal position information.

[0070] S30. performing a file stream reading operation on the target file to load the target file in the memory.

[0071] In one embodiment, the resources related to the front-end component can be organized by a Bundle, and the target file and the subsequent patch file can be organized in the form of a Bundle.

[0072] S105. obtaining a corresponding syntax analysis matcher according to the abnormal type information.

[0073] In the embodiment of the application, different abnormal types can be configured with adaptive syntax analysis matchers. If the abnormal type is a boundary overflow abnormality, a syntax analysis matcher for analyzing boundary problems is obtained; if the abnormal type is an abnormality of non-standard coding, a syntax analysis matcher for analyzing coding standards is obtained.

[0074] ​S107. Analyzing the target file based on the syntax analysis matcher and the abnormal position information to obtain a target abnormal code segment.

[0075] Specifically, the target file is analyzed based on the syntax analysis matcher and the abnormal position information to obtain a target abnormal code segment, as shown in Figure 5

[0076] S1071. Determining a starting position of analysis according to the abnormal position information.

[0077] Specifically, the starting position can be a position pointed by a line and column number in the abnormal position information.

[0078] S1073. Calling the syntax analysis matcher to perform a first matching forwardly and a second matching backwardly from the starting position.

[0079] Specifically, the first matching and the second matching can be performed in sequence or simultaneously, and the embodiments of the present application do not limit the execution sequence.

[0080] Specifically, the first matching and the second matching have the same matching method, and the difference lies in the matching direction. The first matching is used for syntax analysis of code before the starting position, and the second matching is used for syntax analysis of code after the starting position.

[0081] Specifically, the first matching includes the following steps of Figure 6

[0082] S10731. Obtaining a matching step length according to the syntax analysis matcher.

[0083] For different syntax analysis matchers, the matching step length can be different, which also reflects that the analysis granularity of different abnormal types is different.

[0084] S10733. Initializing a current starting position as the starting position.

[0085] S10735. Determining a matching interval according to the current starting position and the matching step length, and the current starting position being a right boundary of the matching interval.

[0086] In one embodiment, if the current starting position is close to a starting position of the target file, the distance between the current starting position and the starting position of the target file can be smaller than the matching interval. In this case, the distance between the current starting position and the starting position of the target file is directly determined as the matching interval.

[0087] ​​S10737. Based on the syntax analysis matcher, the current code segment in which the target file is located is matched and analyzed to determine whether the current code segment is an abnormal code segment.

[0088] Specifically, the code of the current code segment can be matched with the analysis rule in the syntax analysis matcher.

[0089] S10739. It is determined whether the current code segment covers the starting position of the target file. If not, the current starting position is updated according to the current code segment, and step S10735 is repeated.

[0090] Specifically, the determination of whether the current code segment covers the starting position of the target file can be that it is determined whether the left boundary of the current code segment is the starting position of the target file. If yes, it represents the end of the first matching.

[0091] The updating of the current starting position according to the current code segment is that the left boundary of the current code segment is determined as the updated current starting position.

[0092] S1075. The union of the code determined as the abnormal code segment in the first matching and the code determined as the abnormal code segment in the second matching is determined as the target abnormal code segment.

[0093] S109. The target abnormal code segment is repaired according to the abnormal type information to obtain a patch file.

[0094] In an embodiment, in order to improve the security of the application, the patch file can also be obfuscated to obtain a more secure patch file, and subsequent repair, uploading to the server and the like are performed according to the obfuscated patch file. Whether to obfuscate the patch file can be configured in a fourth preset template, and the fourth preset template can also be combined with the first preset template, the second preset template and / or the third preset template.

[0095] Specifically, different repair strategies can be selected according to different abnormal type information to repair the target abnormal code segment. The repair strategy can be deletion, addition of non-empty detection and abnormal internal capture. The non-empty detection can be processed according to the detection result, so that the abnormality caused by the null pointer or empty data can be avoided. The abnormal internal capture can capture the abnormality for processing, so that the crash caused by the abnormality of the front-end component during running can be avoided.

[0096] Specifically, the repairing of the target abnormal code segment according to the abnormal type information to obtain a patch file, as shown in Figure 7 includes:

[0097] S1091. Repairing the target abnormal code segment according to the abnormal type information to obtain a patch code segment;

[0098] S1093. Writing the patch code segment into a target storage location in a file stream format;

[0099] S1095. Generating a patch file according to the patch code segment in the target storage location.

[0100] S1011. Repairing the front-end component based on the patch file.

[0101] Specifically, the repairing of the front-end component based on the patch file includes: Figure 8 as shown in the following table:

[0102] S10111. Re-loading a file corresponding to the front-end component, and loading the patch file.

[0103] Specifically, the patch file can be placed in a directory of the file corresponding to the front-end component, and all files in the directory are loaded together by the native end component. The front-end component running mechanism determines that the patch file can replace the code corresponding to the patch file in the file related to the front-end component, so that the patch is successfully implanted in the front-end component.

[0104] S10113. Starting the front-end component according to the loading result.

[0105] If the front-end component is successfully started, the patch takes effect, and the patch file can also be uploaded to a server, so that the server distributes the patch file to other intelligent terminals, and performs hot updating on the front-end components of the other intelligent terminals.

[0106] The embodiment of the present application provides a self-repairing method, which does not rely on manual code analysis, code repair and code verification, and thus cannot exclude the case of repair failure. In order to improve the robustness of self-repairing, in an embodiment, after the front-end component is repaired based on the patch file, the method further includes:

[0107] If the front-end component cannot be normally started, a start failure processing is performed.

[0108] Specifically, the start failure processing includes: Figure 9 as shown in the following table:

[0109] S201. Obtaining start failure information.

[0110] S203. Analyzing stack information in the start failure information, and determining whether the loaded file has format content error according to the analysis result.

[0111] S205. If there is, determine the file that has format content error.

[0112] S207. If the file is the patch file, delete the patch file.

[0113] Specifically, the determination of the file that has format content error can be: extracting the name of the file that has format content error; and accordingly, judging whether the name is the same as the name of the patch file, if yes, determining that the file is the patch file.

[0114] In one embodiment, after deleting the patch file, each file corresponding to the front-end component can be reloaded so as to re-run the front-end component.

[0115] Since the front-end component cannot be normally started, it needs to rely on the server for hot update, therefore, in one embodiment, it further includes a step of reporting the start failure information to the server if the front-end component cannot be normally started, so that the server can realize the repair of the front-end component through hot update.

[0116] Please refer to Figure 10 , which shows the product interface schematic diagram of the hot update in the prior art. Please refer to Figure 11 , which shows the product interface schematic diagram corresponding to the embodiment of the present application. It can be seen from Figure 10 that the prior art needs to download the patch file from the server under the networking condition, and then can perform the hot update, Figure 11 the embodiment of the present application can repair the front-end component locally and offline in the intelligent terminal.

[0117] The embodiment of the present application discloses an application program self-repairing method, when the front-end component of the application program is abnormal, the native end component of the application program can automatically locate and correct the abnormality of the front-end component, and repair the front-end component in the form of a patch file. This process does not need manual participation, can be fully automatically implemented, and does not need to interact with the server, which can significantly improve the repair speed and reduce the labor cost and communication cost. In fact, the hot update technology in the prior art is time-consuming, and the self-repairing method of the present application can directly limit the repair speed to seconds, which is very obvious in saving time.

[0118] The embodiment of the present application further provides an application program self-repairing device, the application program includes a front-end component and a native end component, as shown in Figure 12 , the device includes:

[0119] An abnormal information capturing module 301 is configured to acquire abnormal information generated by the front-end component, the abnormal information including abnormal type information and abnormal position information.

[0120] The target file reading module 303 is configured to read a target file pointed by the exception position information if the self-repair mechanism is started to repair the exception.

[0121] The syntax analysis matcher obtaining module 305 is configured to obtain a corresponding syntax analysis matcher according to the exception type information.

[0122] The target exception code segment positioning module 307 is configured to analyze the target file based on the syntax analysis matcher and the exception position information to obtain a target exception code segment.

[0123] The patch file generating module 309 is configured to repair the target exception code segment according to the exception type information to obtain a patch file.

[0124] The repair module 3011 is configured to repair the front-end component based on the patch file.

[0125] Specifically, the target exception code segment positioning module 307 includes:

[0126] The start position determining unit is configured to determine an analysis start position according to the exception position information.

[0127] The matching unit is configured to call the syntax analysis matcher to perform a first matching from the start position and a second matching backward.

[0128] The target exception code segment determining unit is configured to determine a union of code determined as an exception code segment in the first matching and code determined as an exception code segment in the second matching as a target exception code segment.

[0129] The matching unit includes a first matching unit and a second matching unit, and the first matching unit and the second matching unit have similar logical structures. Taking the first matching unit as an example, the first matching unit includes:

[0130] The matching step determining unit is configured to obtain a matching step according to the syntax analysis matcher.

[0131] The current start position initializing unit is configured to initialize a current start position as the start position.

[0132] The matching interval interval determining unit is configured to determine a matching interval according to the current start position and the matching step, and the current start position is a right boundary of the matching interval.

[0133] The matching analysis unit is configured to perform matching analysis on the current code segment of the target file located in the matching interval based on the syntax analysis matcher, and determine whether the current code segment is an abnormal code segment.

[0134] The flow control unit is configured to determine whether the current code segment covers the starting position of the target file, and if not, update the current starting position according to the current code segment, and re-call the matching interval determination unit.

[0135] An application self-repairing device and method are disclosed based on the same inventive concept, which will not be described again.

[0136] The application further provides a computer readable storage medium, which can store a plurality of instructions. The instructions can be loaded by a processor and used to execute the application self-repairing method, which at least includes the following steps:

[0137] An application self-repairing method, the application includes a front-end component and a native-end component, the method is applied to the native-end component, and the method includes the following steps:

[0138] If the front-end component runs abnormally, abnormal information generated by the front-end component is obtained, and the abnormal information includes abnormal type information and abnormal position information;

[0139] If the self-repairing mechanism is started to repair the abnormality, a target file pointed by the abnormal position information is read;

[0140] A corresponding syntax analysis matcher is obtained according to the abnormal type information;

[0141] The target file is analyzed based on the syntax analysis matcher and the abnormal position information, and a target abnormal code segment is obtained;

[0142] The target abnormal code segment is repaired according to the abnormal type information, and a patch file is obtained;

[0143] The front-end component is repaired based on the patch file.

[0144] Further, Figure 13 A hardware structure schematic diagram of a device for implementing the method provided by the embodiment of the application is shown, which can participate in constituting or containing the device or system provided by the embodiment of the application. As shown in Figure 13As shown, the device 10 can include one or more processors 102 (the processor 102 can include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it can also include a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. Those skilled in the art can understand that Figure 13 The structure shown is only schematic, which does not limit the structure of the above-mentioned electronic device. For example, the device 10 can also include more or fewer components than those shown in Figure 13 or have a different configuration than that shown in Figure 13 .

[0145] It should be noted that the one or more processors 102 and / or other data processing circuits described above can be referred to herein generally as "data processing circuits". The data processing circuits can be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuits can be a single independent processing module, or all or part of any one of the other elements incorporated into the device 10 (or mobile device). As referred to in the embodiments of the present application, the data processing circuits serve as a processor to control (for example, selection of a variable resistance terminal path connected to an interface).

[0146] The memory 104 can be used to store software programs and modules of application software, and program instructions / data storage devices corresponding to the method described in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned application program self-repairing method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 can further include a memory remotely disposed relative to the processor 102, which can be connected to the device 10 through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0147] The transmission device 106 is configured to receive or send data via a network. The network can include, for example, a wireless network provided by a communication provider of the device 10. In one example, the transmission device 106 includes a network interface controller (NIC) that can connect to other network devices through a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module that is configured to communicate with the Internet via a wireless connection.

[0148] The display can be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the device 10 (or mobile device).

[0149] It is to be noted that the above-mentioned sequence of the embodiments of the present application is merely for description, and does not represent the advantages or disadvantages of the embodiments. The above-mentioned embodiments of the present application are described in the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than the order in which they are recited and still achieve desirable results. In addition, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.

[0150] Each of the embodiments in the specification is described in a progressive manner, and the same or similar parts of each of the embodiments can be referred to each other. Each of the embodiments focuses on the differences from other embodiments. In particular, the device and server embodiments are described simply because they are basically similar to the method embodiments, and the relevant parts can be referred to the part of the method embodiments.

[0151] A person of ordinary skill in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program instructions to instruct related hardware, and the program can be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk.

[0152] The above-mentioned is only the preferred embodiment of the present application, and does not limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. An application self-repairing method, the application comprising a front-end component running on a mobile terminal and a native-end component running on a mobile terminal, characterized in that, The method comprises: If the front-end component operation is abnormal, the native end component running on the mobile terminal acquires abnormal information generated by the front-end component, and the abnormal information comprises abnormal type information and abnormal position information; If the self-repair mechanism is started to repair the abnormality, the native end component running on the mobile terminal reads a target file pointed by the abnormal position information; The native end component running on the mobile terminal configures an adaptive syntax analysis matcher for different abnormal types, and acquires a corresponding syntax analysis matcher according to the abnormal type information; The native end component running on the mobile terminal calls the syntax analysis matcher according to the starting position of analysis determined according to the abnormal position information, and performs first matching forward and second matching backward from the starting position, wherein the first matching comprises acquiring a matching step length according to the syntax analysis matcher; initializing a current starting position as the starting position; determining a matching interval according to the current starting position and the matching step length, and the current starting position is the right boundary of the matching interval; performing matching analysis on a current code segment in the matching interval of the target file based on the syntax analysis matcher, to determine whether the current code segment is an abnormal code segment; and judging whether the current code segment covers a starting position of the target file, if not, updating the current starting position according to the current code segment, and repeating the following steps: determining a matching interval according to the current starting position and the matching step length, and the current starting position is the right boundary of the matching interval; and determining a union of codes determined as abnormal code segments in the first matching and the second matching as a target abnormal code segment. The native end component running on the mobile terminal repairs the target abnormal code segment according to the abnormal type information, to obtain a patch file, and repairs the front-end component based on the patch file.

2. The method of claim 1, wherein, Before the reading of the target file pointed by the abnormal position information, if the self-repair mechanism is started to repair the abnormality, the method further comprises: Judging whether the self-repair mechanism is started in a second preset template; If yes, judging whether an abnormal type pointed by the abnormal type information is configured as supporting self-repair in a third preset template; If yes, determining that the self-repair mechanism is started to repair the abnormality.

3. The method of claim 1, wherein, The reading of the target file pointed by the abnormal position information comprises: Finding a target file in which an abnormality occurs under a resource directory according to the abnormal position information; Performing a file stream reading operation on the target file, to load the target file in a memory.

4. The method of claim 1, wherein: After the repairing of the front-end component based on the patch file, the method further comprises: If the front-end component cannot be normally started, performing a start failure processing.

5. The method of claim 4, wherein, The start failure processing comprises: Acquiring start failure information; Analyzing stack information in the start failure information, to determine whether a loaded file has a format content error according to an analysis result; If there is, determine the file that has format error; If the file is the patch file, delete the patch file, reload the corresponding file of the front-end component to re-run the front-end component.

6. An application self-repairing apparatus, the application including a front-end component running on a mobile terminal and a native-end component running on a mobile terminal, characterized by, The device belongs to the native end component running on the mobile terminal, comprising: An exception information capturing module, configured to acquire, by the native end component running on the mobile terminal, exception information generated by the front-end component, the exception information comprising exception type information and exception location information; A target file reading module, configured to read, by the native end component running on the mobile terminal, a target file pointed to by the exception location information if the self-repair mechanism is started to repair the exception. A syntax analysis matcher obtaining module, configured to configure, by the native end component running on the mobile terminal, an adaptive syntax analysis matcher for different exception types, and obtain a corresponding syntax analysis matcher according to the exception type information. A target exception code segment positioning module, configured to determine, by the native end component running on the mobile terminal, an analysis start position according to the exception location information, and call the syntax analysis matcher, wherein the native end component running on the mobile terminal performs a first match forward and a second match backward from the start position, wherein the first match comprises obtaining a matching step length according to the syntax analysis matcher; initializing a current start position as the start position; determining a matching interval according to the current start position and the matching step length, and taking the current start position as a right boundary of the matching interval; performing matching analysis on a current code segment of the target file located in the matching interval based on the syntax analysis matcher to determine whether the current code segment is an exception code segment; and judging whether the current code segment covers a start position of the target file, and if not, updating the current start position according to the current code segment, and repeating the following steps: determining a matching interval according to the current start position and the matching step length, and taking the current start position as a right boundary of the matching interval; and determining a union of codes determined as exception code segments in the first match and the second match as a target exception code segment by the native end component running on the mobile terminal. A patch file generating module, configured to repair the target exception code segment according to the exception type information by the native end component running on the mobile terminal to obtain a patch file. A repairing module, configured to repair the front-end component based on the patch file.

7. A computer-readable storage medium, characterized in that, The computer readable storage medium stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the application program self-repairing method of any one of claims 1 to 5.

8. An application self-repairing device, characterized by comprising: The device comprises a processor and a memory, and the memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the application program self-repairing method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method, device and system for repairing application program of client

    CN108008972A

  • Application program exception analysis method and device, computer equipment and storage medium

    CN108491320A

  • Application exception analysis method and apparatus, and electronic device

    CN110347565A