ANR problem positioning method and device and electronic equipment

By receiving and analyzing the client's stack information and time-printing log data on the server side, and automatically determining the target problem of ANR events, the problem of low positioning efficiency of ANR problems in the prior art is solved, and the positioning efficiency and accuracy are improved.

CN119311462APending Publication Date: 2025-01-14ZHEJIANG UNIVIEW TECH CO LTD

Patent Information

Application Number
CN202411836525.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In the prior art, the positioning efficiency of ANR problems is low, and relying on manual collection and analysis, which easily misses details, resulting in low positioning efficiency and accuracy.

Method used

By receiving the current stack information and time-printing log data sent by the client on the server side, analyzing the execution time of the target method, automatically determining the target problem method that causes ANR events, reducing manual intervention, and improving positioning efficiency and accuracy.

Benefits of technology

Automatic positioning of ANR problems is realized, positioning efficiency and accuracy is improved, detailed omissions during manual collection are reduced, and sufficient data is provided to support subsequent analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311462A_ABST
    Figure CN119311462A_ABST
Patent Text Reader

Abstract

The invention provides an ANR problem positioning method and device and electronic equipment, and relates to the technical field of computers, and the method comprises the steps: receiving current stack information and time printing log data sent by a client; the current stack information is used for representing states corresponding to all the target methods when the client generates the ANR event for the first time; the time printing log data is used for representing time information corresponding to all target methods when the client side generates the ANR event again; based on the time printing log data, determining execution duration corresponding to each target method in the current stack information; and based on all the execution durations, determining a target problem method which causes the ANR event to occur in the client from all the target methods. According to the invention, automatic positioning of the target problem method causing the ANR problem can be realized, and the positioning efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an ANR problem locating method, device and electronic equipment. Background Art

[0002] In modern mobile application development, Application Not Response (ANR) is a common and serious problem. When a user operates an application, if the main thread is blocked for more than a certain period of time (for example, 5 seconds), the system will throw an ANR error. ANR not only affects the user experience, but may also cause user loss.

[0003] In the prior art, developers generally manually collect the main thread stack information when ANR occurs through the " / data / anr / traces.txt" file generated by the system to locate the cause of ANR. However, the collection and analysis of ANR stack information requires manual operation and may miss details, resulting in low efficiency in locating ANR problems. Summary of the invention

[0004] The present invention provides an ANR problem locating method, device and electronic device, which are used to solve the defect of low efficiency in locating ANR problems in the prior art, realize automatic locating of the target problem method causing the ANR problem, and improve the locating efficiency.

[0005] The present invention provides an ANR problem locating method, which is applied to a server side, and the method comprises: Receive current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; Based on the time printing log data, determining the execution time corresponding to each of the target methods in the current stack information; Based on all execution times, a target problem method causing an ANR event to occur on the client is determined from among all target methods.

[0006] According to the ANR problem locating method provided by the present invention, the target problem method causing the ANR event to occur on the client is determined from all the target methods based on all the execution times, including: Determine a comparison result between each of the execution durations and a first preset duration; Based on all comparison results, the target problem method causing the ANR event to occur on the client is determined from all the target methods.

[0007] According to the ANR problem locating method provided by the present invention, the target problem method causing the ANR event to occur on the client is determined from all target methods based on all comparison results, including: In the case where there is at least one first comparison result indicating that the execution time is greater than or equal to the first preset time in all comparison results, determining the target method corresponding to each of the at least one first comparison results as the target problem method causing the ANR event to occur on the client; When all the comparison results indicate that the execution time is less than the first preset time, the target method with the longest execution time is determined as the target method that causes the ANR event to occur on the client.

[0008] According to the ANR problem locating method provided by the present invention, the determining of the execution time corresponding to each of the target methods in the current stack information based on the time printing log data includes: For each target method in the current stack information, based on the time printing log data, determine the time information corresponding to the target method; In the case where the time information includes an entry time and an exit time, determining the difference between the exit time and the entry time as the execution duration corresponding to the target method; When the time information includes the entry time, the time corresponding to when the ANR event occurs again on the client is determined as the end time corresponding to the target method; the difference between the end time and the entry time is determined as the execution duration corresponding to the target method.

[0009] According to the ANR problem locating method provided by the present invention, before receiving the time printing log data sent by the client, the method further includes: Marking all the target methods in the current stack information, and updating the ANR method whitelist based on all the target methods; The updated ANR method whitelist is sent to the client, and the client is used to monitor all target methods in the ANR method whitelist.

[0010] According to the ANR problem locating method provided by the present invention, the method further includes: Send the target problem method to the developer's corresponding terminal for display; After receiving the developer's confirmation information on the target problem method, the mark corresponding to the ANR event is updated, and other target methods except the target problem method in the ANR method whitelist are deleted.

[0011] The present invention also provides an ANR problem locating method, which is applied to a client, and the method comprises: When an ANR event is detected for the first time, current stack information is sent to the server, where the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; Receive the ANR method whitelist sent by the server, and monitor all target methods in the ANR method whitelist; When the ANR event is detected again, time print log data is sent to the server, where the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0012] The present invention also provides an ANR problem locating device, which is applied to a server side, and the device comprises: A first receiving module is used to receive current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; A first determination module, configured to determine the execution time corresponding to each of the target methods in the current stack information based on the time printing log data; The second determination module is used to determine the target problem method that causes the ANR event to occur in the client from all the target methods based on all the execution times.

[0013] The present invention also provides an ANR problem locating device, which is applied to a client, and the device comprises: A first sending module is used to send current stack information to the server when an ANR event is detected for the first time, wherein the current stack information is used to represent the states corresponding to all target methods when an ANR event occurs for the first time on the client; A second receiving module is used to receive the ANR method whitelist sent by the server and monitor all target methods in the ANR method whitelist; The second sending module is used to send time printing log data to the server when the ANR event is detected again. The time printing log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the ANR problem locating method as described above is implemented.

[0015] The present invention also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the ANR problem locating method as described in any one of the above is implemented.

[0016] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned ANR problem locating methods.

[0017] The ANR problem locating method, device and electronic device provided by the present invention obtain the current stack information corresponding to all target methods when the ANR event occurs for the first time on the client, and obtain the time print log data corresponding to all target methods when the ANR event occurs again on the client, analyze the execution time corresponding to all target methods through the time print log, and accurately locate the target problem method that caused the ANR event to occur on the client from all target methods through all execution times, thereby reducing manual intervention in the entire problem locating process and avoiding manual omission of details, thereby improving the positioning efficiency and positioning accuracy of the entire problem locating process. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 This is one of the flow charts of the ANR problem locating method provided in an embodiment of the present invention.

[0020] Figure 2 This is the second flow chart of the ANR problem locating method provided in an embodiment of the present invention.

[0021] Figure 3 is a schematic diagram of an example thread stack provided by an embodiment of the present invention.

[0022] Figure 4 This is the third flow chart of the ANR problem locating method provided in an embodiment of the present invention.

[0023] Figure 5 It is one of the structural schematic diagrams of the ANR problem locating device provided in an embodiment of the present invention.

[0024] Figure 6 This is the second structural diagram of the ANR problem locating device provided in an embodiment of the present invention.

[0025] Figure 7 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] In the client, if an application does not respond to user operations within a certain period of time, the system corresponding to the client will consider that an ANR event has occurred in this application. When an ANR event occurs, it is generally because the method called by the thread corresponding to the application is blocked. At this time, the thread cannot continue to execute subsequent methods, which makes it unable to respond to user operations. There are many reasons for the occurrence of ANR events, such as waiting for I / O (Input / Output) operations, waiting for synchronization locks, waiting for inter-thread communication, and wireless loops.

[0028] In the prior art, developers generally manually collect the main thread stack information and logs when ANR (Application Not Response) occurs through the " / data / anr / traces.txt" file generated by the system to locate the specific cause of ANR. However, there are the following problems when manually collecting ANR stack information and logs for problem location.

[0029] (1) The manual collection process is cumbersome and may miss details, especially in multi-threaded competition problems. As a result, the collected data has certain limitations and cannot provide sufficiently detailed data support for subsequent problem location analysis, resulting in low location efficiency and accuracy in the subsequent manual analysis process.

[0030] (2) Existing methods rely on post-analysis and have a certain lag.

[0031] In view of the above problems in the prior art, an embodiment of the present invention provides an ANR problem locating method, which is applied to a server side. Figure 1 FIG. 1 is one of the flow charts of the ANR problem location method provided by an embodiment of the present invention. Figure 1 As shown, the method includes the following steps 110 to 130.

[0032] Step 110, receiving the current stack information and time print log data sent by the client; the current stack information is used to represent the corresponding states of all target methods when the ANR event occurs on the client for the first time; the time print log data is used to represent the corresponding time information of all target methods when the ANR event occurs on the client again.

[0033] Specifically, when an ANR event occurs on the client, the server can obtain the current stack information and time print log data sent by the client in real time and in sequence, that is, when the ANR event occurs on the client for the first time, the server first receives the current stack information captured by the client in real time, that is, the server can first obtain the state of the target method called by each thread when the ANR event occurs for the first time. Afterwards, when the ANR event occurs again on the client, the server receives the time print log data captured by the client in real time, that is, the server can also obtain the time information of all target methods printed by the time print code when the ANR event occurs again in the client. By automatically recording the current stack information and time print log data when the ANR event occurs, the lag of the data is overcome, the manual intervention in the collection process is reduced, the data collection efficiency in the problem location process is improved, and the location efficiency of the problem location is improved. At the same time, the automatic collection of data can reduce the probability of missing details during manual collection, and provide sufficient data for the automatic analysis of subsequent problem location, thereby improving the accuracy of problem location.

[0034] It should be noted that the current stack information includes the target method called by each thread in the client and the state corresponding to the target method, the method call sequence and system information. Among them, the state corresponding to the target method may include a running state, a blocking state, a waiting state or a termination state. The method call sequence may include a call path from a program entry point (such as the main method) to the current execution point in the target method, and the call path may include the name of each method involved, the call parameters, and the source code file and line number where the call is located. The system information may include the operating system version, device signal and application version corresponding to the client. The current stack information may also include other information, which is not limited in the embodiment of the present invention.

[0035] It should be noted that the time information may include the entry time of the target method in the state, or the entry time and the exit time. The entry time can be understood as the start time point of the target method in the state, and the exit time can be understood as the end time point of the target method in the state.

[0036] It should be noted that the target method refers to the function being called by each thread in the application when an ANR event occurs. The target method encapsulates a series of program codes, and the target method can be called by the thread to perform a specific task.

[0037] Furthermore, before receiving the time printing log data sent by the client, the method further includes: Marking all the target methods in the current stack information, and updating the ANR method whitelist based on all the target methods; The updated ANR method whitelist is sent to the client, and the client is used to monitor all target methods in the ANR method whitelist.

[0038] Specifically, Figure 2 FIG. 2 is a flow chart of the ANR problem location method provided by an embodiment of the present invention. Figure 2 As shown, after the server obtains the current stack information captured when the ANR event occurs for the first time on the client, the target method corresponding to each thread in the current stack information can be marked. The mark is used to instruct the client to monitor the time information of the marked target method after it is called, that is, the marked target method may be the cause of the ANR event on the client. After marking all target methods, all marked target methods are added to the ANR method whitelist, and the ANR method whitelist is sent to the client, so that the client monitors all target methods in the ANR method whitelist, and after the ANR event occurs again on the client, the time information of all target methods is printed to form time print log data, and then the time print log data is sent to the server in real time. That is, the target method included in the time print log data is the same as the target method included in the current stack information.

[0039] It should be noted that, during the application packaging process on the client side, a script is used in advance to automatically insert time printing codes at the beginning and end of each method in the application. These time printing codes can record the time information of the corresponding method. By default, each method does not execute the time printing code, that is, each method does not print the time information, in order to reduce performance overhead.

[0040] Step 120: Determine the execution time corresponding to each of the target methods in the current stack information based on the time printing log data.

[0041] Specifically, after obtaining the time print log data sent by the client after the ANR event occurs again, the time information automatically recorded by each target method can be analyzed to calculate the execution time corresponding to each target method. The execution time refers to the time interval between the start of execution of each target method and the occurrence of the ANR event again.

[0042] Further, the determining the execution time corresponding to each of the target methods in the current stack information based on the time printing log data includes: For each target method in the current stack information, based on the time printing log data, determine the time information corresponding to the target method; In the case where the time information includes an entry time and an exit time, determining the difference between the exit time and the entry time as the execution duration corresponding to the target method; When the time information includes the entry time, the time corresponding to when the ANR event occurs again on the client is determined as the end time corresponding to the target method; the difference between the end time and the entry time is determined as the execution duration corresponding to the target method.

[0043] Specifically, after obtaining the time print log data, the time information corresponding to each target method can be determined respectively. For each target method, the entry time is the starting time point when the thread calls the target method, and the exit time is the end time point of the execution of the target method. If the time information of the target method includes the entry time and the exit time, it indicates that the target method is executed just at the exit time after being called by the corresponding thread. At this time, the difference between the exit time and the entry time can be calculated, and the difference is the execution time of the target method. If the time information of the target method only includes the entry time, it indicates that the target method is still in operation when the ANR event occurs again on the client. At this time, the time when the ANR event occurs again on the client can be used as the end time of the target method, and the difference between the end time and the entry time is calculated, and the difference is the execution time of the target method.

[0044] Step 130: Based on all execution times, determine the target problem method that causes the ANR event to occur on the client from among all the target methods.

[0045] Specifically, after calculating the execution time corresponding to each target method, all execution times can be analyzed to accurately locate the target problem method that causes the ANR event to occur on the client from among all target methods.

[0046] Further, the determining, based on all execution times, from all target methods, a target problem method causing an ANR event to occur on the client includes: Determine a comparison result between each of the execution durations and a first preset duration; Based on all comparison results, the target problem method causing the ANR event to occur on the client is determined from all the target methods.

[0047] Specifically, after all execution times are determined, for each execution time, each execution time can be compared with the first preset time to determine the comparison result corresponding to each execution time, that is, to determine whether each execution time is greater than or equal to the first preset time, or less than the first preset time. Then, according to all comparison results, the target problem method is automatically and accurately located from all target methods.

[0048] It should be noted that the first preset time length can be set according to experience. For example, the first preset time length can be 5 seconds, 7 seconds, 10 seconds, etc., and the embodiment of the present invention is not limited to this.

[0049] Further, the method of determining the target problem method causing the ANR event to occur on the client from all target methods based on all comparison results includes: In the case where there is at least one first comparison result indicating that the execution time is greater than or equal to the first preset time in all comparison results, determining the target method corresponding to each of the at least one first comparison results as the target problem method causing the ANR event to occur on the client; When all the comparison results indicate that the execution time is less than the first preset time, the target method with the longest execution time is determined as the target method that causes the ANR event to occur on the client.

[0050] Specifically, after determining all comparison results, for each comparison result, if the comparison result is that the execution time of the target method is greater than or equal to the first preset time, it indicates that the target method corresponding to the comparison result may have blocked the execution of the corresponding thread, causing an ANR event to occur on the client. At this time, the target method corresponding to the comparison result can be determined as the target problem method that causes the ANR event. After analyzing all comparison results, all target problem methods that may cause the ANR event can be determined. If in all comparison results, the execution time is less than the first preset time, the execution times are sorted in order from long to short, and the target method with the longest execution time is determined as the target problem method that causes the ANR event, that is, the target method whose execution time is closest to the first preset time is most likely to cause an ANR event on the client.

[0051] For example, Figure 3 is a schematic diagram of an example thread stack provided by an embodiment of the present invention, such as Figure 3As shown, taking the first preset duration of 5 seconds as an example, the thread stack corresponding to the client includes four threads, namely thread 1 (Thread1), thread 2 (Thread2), thread 3 (Thread3) and thread 4 (Thread4), wherein thread 1 is a UI thread, which is used to process all events of the user interface, such as user input events, interface update events, etc. Thread 1 is in a waiting state at time T2, that is, thread 1 starts waiting for the release of the synchronization lock (lockA) at time T2, and the synchronization lock was acquired by thread 3 as early as time T1, and thread 3 has been in a running state since acquiring the synchronization lock. Since thread 1 has not acquired the synchronization lock, thread 1 has been in a waiting state until after waiting for 5 seconds, since thread 1 has not responded, the system in the client triggers an ANR event at time T3, collects the current stack information corresponding to time T3, and sends the current stack information to the server.

[0052] After receiving the current stack information, the server can identify the target method 1 being called by thread 1, the target method 2 being called by thread 2, the target method 3 being called by thread 3, and the target method 4 being called by thread 4 when the ANR event first occurs on the client. Afterwards, target method 1, target method 2, target method 3, and target method 4 are marked respectively, and target method 1, target method 2, target method 3, and target method 4 are added to the ANR method whitelist, and the ANR method whitelist is sent to the client, notifying the client to monitor the four target methods in the ANR method whitelist. After receiving the ANR method whitelist, the client enables the time printing code permissions for the four target methods.

[0053] When the ANR event occurs again in the client, the time printing log data includes: Thread 1 prints the entry time at T2, but because Thread 1 is in a waiting state until the ANR event occurs again, the target method 1 in Thread 1 only prints the entry time, but not the exit time. At this time, the server can use the time when the ANR event is triggered again as the end time of the target method 1, and then calculate the execution time of the target method 1 as 5 seconds. Similarly, Thread 3 prints the entry time at T1, but because Thread 3 is in a running state until the ANR event occurs again, the target method 3 in Thread 3 only prints the entry time, but not the exit time. At this time, the server can use the time when the ANR event is triggered again as the end time of the target method 3, and then calculate the execution time of the target method 3 as 7 seconds. Thread 2 and Thread 4 both print the entry time and exit time. The server can calculate the execution time of the target method 2 in Thread 2 as 3 seconds, and the execution time of the target method 4 in Thread 4 as 2 seconds.

[0054] After calculating the execution time of each of the four target methods on the server side, since the execution time of target method 1 is equal to 5 seconds, the execution time of target method 3 is greater than 5 seconds, and the execution time of target method 2 and target method 4 is less than 5 seconds, target method 1 and target method 3 are determined as the target problem methods that cause the ANR event on the client. Combining the current stack information and the time print log data analysis, it can be seen that the ANR event is triggered after target method 1 waits for 5 seconds without responding. The reason is that target method 3 obtains the synchronization lock earlier than target method 1 and has been in a running state until the ANR event is triggered and the synchronization lock is not released.

[0055] For complex ANR problems, for example, if Figure 3 The synchronization lock in is first occupied by the target method 2 in thread 2 for 3 seconds at time T1, and then, after the target method 2 is released, it is occupied by the target method 3 in thread 3 for 4 seconds at time T4. At this time, the target method 1 in thread 1 cannot respond to user operations within 5 seconds and triggers the ANR event. In this scenario, it is necessary to report the current stack information and time printing log data corresponding to the ANR event multiple times to locate the target problem method that causes the ANR event. For example, when the ANR event occurs for the first time, the current stack information reported is the target method 1 in thread 1, the target method 5 in thread 2, the target method 3 in thread 3, and the target method 4 in thread 4, among which the target method 5 in thread 2 is the target method called after the target method 2 in thread 2 obtains the synchronization lock at time T1 and executes. When the ANR event occurs again, the printed time printing log data includes the entry time of the target method 1, the entry time of the target method 5, the entry time of the target method 3, and the entry time and exit time of the target method 4. However, since the target method 2 in thread 2 has been executed, the time information of the target method 2 is not printed. Afterwards, it can be calculated that the execution time of target method 1 is 5 seconds, the execution time of target method 5 is 3 seconds, the execution time of target method 3 is 4 seconds, and the execution time of target method 4 is 3 seconds. At this point, target method 1 can be determined as the target problem method that causes the ANR event. When the ANR event occurs three times, the time information of target method 1 can be eliminated, and target method 3 can be determined again as the target problem method that causes the ANR event from target method 5, target method 3, and target method 4.

[0056] In addition, the target problem method can also be determined in combination with other types of ANR events in adjacent time periods. For example, the synchronization lock was first occupied by target method 4 of thread 4 for 3 seconds at time T1, and then occupied by target method 2 of thread 2 for 4 seconds, resulting in thread 1 not responding to user operations within 5 seconds and triggering an ANR event. In this case, through three ANR events, the target problem methods can be determined to be target method 1 and target method 2. At this time, target method 1, target method 2, and target method 3 can all be determined as target problem methods.

[0057] Furthermore, if Figure 2 As shown, the method also includes: Send the target problem method to the developer's corresponding terminal for display; After receiving the developer's confirmation information on the target problem method, the mark corresponding to the ANR event is updated, and other target methods except the target problem method in the ANR method whitelist are deleted.

[0058] Specifically, after locating the target problem method, the target problem method can be sent to the developer's corresponding terminal for display. After the developer confirms that the target problem method does cause the ANR event, the ANR event mark can be updated to resolved, and the target methods that need to be monitored in the ANR method whitelist can be dynamically adjusted, that is, other target methods except the target problem method can be deleted from the ANR method whitelist to save resources and avoid long-term impact on application performance.

[0059] The ANR problem locating method provided by the embodiment of the present invention obtains the current stack information corresponding to all target methods when the ANR event occurs for the first time on the client, and obtains the time print log data corresponding to all target methods when the ANR event occurs again on the client, analyzes the execution time corresponding to all target methods through the time print log, and accurately locates the target problem method that causes the ANR event to occur on the client from all target methods through all execution times, thereby reducing manual intervention in the entire problem locating process and avoiding manual omission of details, thereby improving the locating efficiency and accuracy of the entire problem locating process.

[0060] The embodiment of the present invention also provides an ANR problem locating method, which is applied to a client. Figure 4 FIG. 3 is a flow chart of the ANR problem location method provided by an embodiment of the present invention. Figure 4 As shown, the method includes the following steps 410 to 430.

[0061] Step 410: When an ANR event is detected for the first time, current stack information is sent to the server, where the current stack information is used to represent the states corresponding to all target methods when an ANR event occurs for the first time on the client.

[0062] Step 420: Receive the ANR method whitelist sent by the server, and monitor all target methods in the ANR method whitelist.

[0063] Step 430: When the ANR event is detected again, time print log data is sent to the server, where the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0064] Specifically, when the ANR event is triggered for the first time in the client, the client can collect the status of the target method called by each thread in the client when the ANR event is triggered through the callback method, thereby forming the current stack information, and sending the current stack information to the target server. Afterwards, after receiving the current stack information, the server updates the ANR method whitelist according to all the target methods in the current stack information, and sends the ANR method whitelist to the client. After receiving the ANR method whitelist, the client enables the permission of the time printing code of all target methods in the ANR method whitelist to monitor each target method. When the ANR event is triggered again, the time information of each target method is printed through each time printing code to form time printing log data, and the time printing log data is sent to the server to assist the server in real-time and accurately locating the target problem method that caused the ANR event.

[0065] The ANR problem locating method provided in the embodiment of the present invention automatically records the current stack information corresponding to all target methods when the ANR event occurs for the first time on the client, and sends the current stack information to the server in real time. When the ANR event occurs again on the client, the time print log data corresponding to all target methods is automatically recorded again, and the time print log data is sent to the server in real time, to assist the server in accurately locating the target problem method that caused the ANR event on the client. By automatically collecting data, human intervention in the data collection process is reduced, and details caused by human intervention are avoided, thereby improving the locating efficiency and accuracy of the entire problem locating process.

[0066] The ANR problem locating device provided by the present invention is described below. The ANR problem locating device described below and the ANR problem locating method described above can be referenced to each other.

[0067] The embodiment of the present invention also provides an ANR problem locating device, which is applied to a server side. Figure 5is one of the structural diagrams of the ANR problem locating device provided by an embodiment of the present invention, such as Figure 5 As shown, the ANR problem locating device 500 includes: a first receiving module 510 , a first determining module 520 and a second determining module 530 .

[0068] The first receiving module 510 is used to receive the current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; A first determination module 520, configured to determine the execution time corresponding to each of the target methods in the current stack information based on the time printing log data; The second determination module 530 is used to determine the target problem method that causes the ANR event to occur in the client from all the target methods based on all the execution times.

[0069] The ANR problem locating device provided by the embodiment of the present invention obtains the current stack information corresponding to all target methods when the ANR event occurs on the client for the first time, and obtains the time print log data corresponding to all target methods when the ANR event occurs on the client again, analyzes the execution time corresponding to all target methods through the time print log, and accurately locates the target problem method that causes the ANR event to occur on the client from all target methods through all execution times, thereby reducing manual intervention in the entire problem locating process and avoiding manual omission of details, thereby improving the locating efficiency and accuracy of the entire problem locating process.

[0070] Optionally, the first determining module 520 is specifically configured to: For each target method in the current stack information, based on the time printing log data, determine the time information corresponding to the target method; In the case where the time information includes an entry time and an exit time, determining the difference between the exit time and the entry time as the execution duration corresponding to the target method; When the time information includes the entry time, the time corresponding to when the ANR event occurs again on the client is determined as the end time corresponding to the target method; the difference between the end time and the entry time is determined as the execution duration corresponding to the target method.

[0071] Optionally, the second determining module 530 is specifically configured to: Determine a comparison result between each of the execution durations and a first preset duration; Based on all comparison results, the target problem method causing the ANR event to occur on the client is determined from all the target methods.

[0072] Optionally, the second determining module 530 is specifically configured to: In the case where there is at least one first comparison result indicating that the execution time is greater than or equal to the first preset time in all comparison results, determining the target method corresponding to each of the at least one first comparison results as the target problem method causing the ANR event to occur on the client; When all the comparison results indicate that the execution time is less than the first preset time, the target method with the longest execution time is determined as the target method that causes the ANR event to occur on the client.

[0073] Optionally, the ANR problem locating device 500 further includes: a first updating module, wherein the first updating module is specifically configured to: Marking all the target methods in the current stack information, and updating the ANR method whitelist based on all the target methods; The updated ANR method whitelist is sent to the client, and the client is used to monitor all target methods in the ANR method whitelist.

[0074] Optionally, the ANR problem locating device 500 further includes: a second updating module, wherein the second updating module is specifically configured to: Send the target problem method to the developer's corresponding terminal for display; After receiving the developer's confirmation information on the target problem method, the mark corresponding to the ANR event is updated, and other target methods except the target problem method in the ANR method whitelist are deleted.

[0075] The embodiment of the present invention also provides an ANR problem locating device, which is applied to a client. Figure 6 2 is a schematic diagram of the structure of the ANR problem location device provided by an embodiment of the present invention. Figure 6 As shown, the ANR problem locating device 600 includes: a first sending module 610 , a second receiving module 620 and a second sending module 630 .

[0076] The first sending module 610 is used to send current stack information to the server when an ANR event is detected for the first time, wherein the current stack information is used to represent the states corresponding to all target methods when an ANR event occurs for the first time on the client; The second receiving module 620 is used to receive the ANR method whitelist sent by the server and monitor all target methods in the ANR method whitelist; The second sending module 630 is used to send time printing log data to the server when the ANR event is detected again. The time printing log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0077] The ANR problem locating device provided in the embodiment of the present invention automatically records the current stack information corresponding to all target methods when the ANR event occurs for the first time on the client, and sends the current stack information to the server in real time. When the ANR event occurs again on the client, it automatically records the time print log data corresponding to all target methods again, and sends the time print log data to the server in real time, to assist the server in accurately locating the target problem method that caused the ANR event on the client. By automatically collecting data, human intervention in the data collection process is reduced, and details caused by human intervention are avoided, thereby improving the positioning efficiency and positioning accuracy of the entire problem locating process.

[0078] Figure 7 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the ANR problem location method, which includes: Receive current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; Based on the time printing log data, determining the execution time corresponding to each of the target methods in the current stack information; Based on all execution times, determine the target problem method that causes the ANR event to occur on the client from among all the target methods; or, When an ANR event is detected for the first time, current stack information is sent to the server, where the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; Receive the ANR method whitelist sent by the server, and monitor all target methods in the ANR method whitelist; When the ANR event is detected again, time print log data is sent to the server, where the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0079] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0080] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the ANR problem location method provided by the above methods, the method includes: Receive current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; Based on the time printing log data, determining the execution time corresponding to each of the target methods in the current stack information; Based on all execution times, determine the target problem method that causes the ANR event to occur on the client from among all the target methods; or, When an ANR event is detected for the first time, current stack information is sent to the server, where the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; Receive the ANR method whitelist sent by the server, and monitor all target methods in the ANR method whitelist; When the ANR event is detected again, time print log data is sent to the server, where the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0081] In another aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for locating the ANR problem provided by the above methods is implemented, and the method includes: Receive current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; Based on the time printing log data, determining the execution time corresponding to each of the target methods in the current stack information; Based on all execution times, determine the target problem method that causes the ANR event to occur on the client from among all the target methods; or, When an ANR event is detected for the first time, current stack information is sent to the server, where the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; Receive the ANR method whitelist sent by the server, and monitor all target methods in the ANR method whitelist; When the ANR event is detected again, time print log data is sent to the server, where the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

[0082] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0083] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for locating an ANR problem, characterized in that: Applied to the server side, the method includes: Receive current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; Based on the time printing log data, determining the execution time corresponding to each of the target methods in the current stack information; Based on all execution times, a target problem method causing an ANR event to occur on the client is determined from among all target methods.

2. The ANR problem locating method according to claim 1, characterized in that: The step of determining the target problem method causing the ANR event to occur on the client from among all the target methods based on all the execution times includes: Determine a comparison result between each of the execution durations and a first preset duration; Based on all comparison results, the target problem method causing the ANR event to occur on the client is determined from all the target methods.

3. The ANR problem locating method according to claim 2, characterized in that: The step of determining the target problem method causing the ANR event to occur on the client from all target methods based on all comparison results includes: In the case where there is at least one first comparison result indicating that the execution time is greater than or equal to the first preset time in all comparison results, determining the target method corresponding to each of the at least one first comparison results as the target problem method causing the ANR event to occur on the client; When all the comparison results indicate that the execution time is less than the first preset time, the target method with the longest execution time is determined as the target method that causes the ANR event to occur on the client.

4. The ANR problem locating method according to claim 1, characterized in that: The determining, based on the time printing log data, the execution duration corresponding to each of the target methods in the current stack information includes: For each target method in the current stack information, based on the time printing log data, determine the time information corresponding to the target method; In the case where the time information includes an entry time and an exit time, determining the difference between the exit time and the entry time as the execution duration corresponding to the target method; When the time information includes the entry time, the time corresponding to when the ANR event occurs again on the client is determined as the end time corresponding to the target method; the difference between the end time and the entry time is determined as the execution duration corresponding to the target method.

5. The ANR problem locating method according to any one of claims 1 to 4, characterized in that: Before receiving the time printing log data sent by the client, the method further includes: Marking all the target methods in the current stack information, and updating the ANR method whitelist based on all the target methods; The updated ANR method whitelist is sent to the client, and the client is used to monitor all target methods in the ANR method whitelist.

6. The ANR problem location method according to claim 5, characterized in that: The method further comprises: Send the target problem method to the developer's corresponding terminal for display; After receiving the developer's confirmation information on the target problem method, the mark corresponding to the ANR event is updated, and other target methods except the target problem method in the ANR method whitelist are deleted.

7. A method for locating an ANR problem, characterized in that: Applied to a client, the method comprises: When an ANR event is detected for the first time, current stack information is sent to the server, where the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; Receive the ANR method whitelist sent by the server, and monitor all target methods in the ANR method whitelist; When the ANR event is detected again, time print log data is sent to the server, where the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

8. An ANR problem location device, characterized in that: Applied to the server side, the device comprises: The first receiving module is used to receive the current stack information and time print log data sent by the client; the current stack information is used to represent the states corresponding to all target methods when the ANR event occurs for the first time on the client; the time print log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client; A first determination module, configured to determine the execution time corresponding to each of the target methods in the current stack information based on the time printing log data; The second determination module is used to determine the target problem method that causes the ANR event to occur in the client from all the target methods based on all the execution times.

9. An ANR problem location device, characterized in that: Applied to a client, the device comprises: A first sending module is used to send current stack information to the server when an ANR event is detected for the first time, wherein the current stack information is used to represent the states corresponding to all target methods when an ANR event occurs for the first time on the client; A second receiving module is used to receive the ANR method whitelist sent by the server and monitor all target methods in the ANR method whitelist; The second sending module is used to send time printing log data to the server when the ANR event is detected again. The time printing log data is used to represent the time information corresponding to all target methods when the ANR event occurs again on the client.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, it implements the ANR problem locating method as described in any one of claims 1 to 6, or the ANR problem locating method as described in claim 7.

Citation Information

Patent Citations

  • Anomaly detection method of application program, terminal device and medium

    CN109491860A

  • Jamming positioning method and device

    CN111625456A

  • Application program lag event positioning method and device, storage medium and equipment

    CN113297052A

  • ANR abnormal data collection method, ANR abnormal data display method, ANR abnormal data collection device and ANR abnormal data display equipment

    CN113626244A

  • Log generation method and device

    CN115033223A

Cited By

  • Lag root cause analysis method, device and equipment

    CN122339938A