CN113626244A - ANR abnormal data collection method, ANR abnormal data display method, ANR abnormal data collection device, ANR abnormal data display device and ANR abnormal data display equipment - Google Patents

ANR abnormal data collection method, ANR abnormal data display method, ANR abnormal data collection device, ANR abnormal data display device and ANR abnormal data display equipment Download PDF

Info

Publication number
CN113626244A
CN113626244A CN202110990795.5A CN202110990795A CN113626244A CN 113626244 A CN113626244 A CN 113626244A CN 202110990795 A CN202110990795 A CN 202110990795A CN 113626244 A CN113626244 A CN 113626244A
Authority
CN
China
Prior art keywords
data
execution
time
target
main thread
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110990795.5A
Other languages
Chinese (zh)
Other versions
CN113626244B (en
Inventor
张文彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Baiguoyuan Network Technology Co Ltd
Original Assignee
Guangzhou Baiguoyuan Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Baiguoyuan Network Technology Co Ltd filed Critical Guangzhou Baiguoyuan Network Technology Co Ltd
Priority to CN202110990795.5A priority Critical patent/CN113626244B/en
Publication of CN113626244A publication Critical patent/CN113626244A/en
Application granted granted Critical
Publication of CN113626244B publication Critical patent/CN113626244B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application discloses a method, a device and equipment for collecting and displaying ANR abnormal data, and belongs to the technical field of computers. The method comprises the following steps: acquiring running data of a target application program, wherein the running data comprises main thread call stack data, main thread task data and function execution data; recording operation data; when the target application program generates the ANR, reporting ANR abnormal data to a server, wherein the ANR abnormal data comprises the generation time of the ANR and operation data corresponding to the ANR. The method and the device have the advantages that the data for analyzing the ANR abnormity are collected in a targeted manner, effective data can be provided for ANR abnormity analysis, and the analysis difficulty of the ANR abnormity is reduced.

Description

ANR abnormal data collection method, ANR abnormal data display method, ANR abnormal data collection device, ANR abnormal data display device and ANR abnormal data display equipment
Technical Field
The embodiment of the Application relates to the technical field of computers, in particular to a method, a device and equipment for collecting and displaying ANR (Application Not responding) abnormal data.
Background
ANR is a problem that users may experience when using running applications. In the Android system, a specific event needs to be completed within a specified time range, and if an application fails to respond within the specified time range or the response time is too long, an ANR exception is caused.
In the related art, when an ANR exception occurs in an application, a technician analyzes a cause of the ANR exception by calling a trace document (trace. txt) generated by an operating system. The tracking document describes information such as a time point at which the ANR abnormality occurs and a thread in a corresponding time period, an application program in which the ANR abnormality occurs, a process number, and a load condition of a CPU (Central Processing Unit), and a technician searches for data for analyzing a cause of the ANR abnormality from the tracking document by means of a keyword search or the like.
However, because the data that can be collected in a trace document is limited and contains much of the underlying data, this data does not help the ANR anomaly analysis process. In the related art, the trace document cannot clearly and definitely display the cause of the ANR abnormality.
Disclosure of Invention
The embodiment of the application provides a method, a device and equipment for collecting and displaying ANR abnormal data, and can be used for solving the problem of weak directivity of reference information for analyzing ANR abnormal in the related art. The technical scheme is as follows:
according to an aspect of the embodiments of the present application, there is provided a method for collecting ANR anomaly data, the method being performed by a target application, the method including:
collecting operation data of the target application program, wherein the operation data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
recording the operation data;
reporting ANR abnormal data to a server when the target application program generates ANR, wherein the ANR abnormal data comprises the generation time of the ANR and the running data corresponding to the ANR.
According to an aspect of the embodiments of the present application, there is provided a method for collecting ANR anomaly data, the method being performed by an analysis device, the method including:
obtaining ANR exception data of a target application program from a server, wherein the ANR exception data comprises occurrence time of ANR of the target application program and running data corresponding to the ANR, and the running data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
and visually displaying the operation data.
According to an aspect of an embodiment of the present application, there is provided an ANR anomaly data collection apparatus, including:
the acquisition module is used for acquiring the running data of the target application program, wherein the running data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
the recording module is used for recording the operation data;
and a reporting module, configured to report, to a server, ANR exception data when the target application generates ANR, where the ANR exception data includes an ANR occurrence time and the operation data corresponding to the ANR.
According to an aspect of an embodiment of the present application, there is provided a display apparatus for ANR anomaly data, the apparatus including:
an obtaining module, configured to obtain, from a server, ANR exception data of a target application, where the ANR exception data includes an occurrence time of ANR of the target application and operation data corresponding to the ANR, and the operation data includes main-thread call stack data, main-thread task data, and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
and the display module is used for visually displaying the operating data.
According to an aspect of the embodiments of the present application, there is provided a computer device including a processor and a memory, where a computer program is stored, and the processor executes the computer program to implement the ANR abnormality data collection method or the ANR abnormality data display method.
According to an aspect of the embodiments of the present application, there is provided a computer-readable storage medium having a computer program stored therein, where the computer program is used to be executed by a processor to implement the ANR anomaly data collection method or the ANR anomaly data display method.
According to an aspect of the present application, there is provided a computer program product which, when run on a computer device, causes the computer device to execute the method of collecting ANR abnormality data as described above, or the method of displaying ANR abnormality data as described above.
The technical scheme provided by the embodiment of the application can bring the following beneficial effects:
the application provides a method for collecting ANR abnormal data, which collects and records running data through an application program, wherein the running data comprises the following steps: the method has the advantages that effective data can be provided for ANR abnormity analysis, and the ANR abnormity analysis difficulty is reduced.
The method for displaying the ANR abnormal data obtains the ANR abnormal data of the target application program from the server through the analysis equipment, and the running data is displayed in a visual mode, so that the running scene of the target application program in a period of time before the ANR abnormal occurs in the target application program can be displayed clearly according to the time line, and the method is beneficial to analyzing the generation reason of the ANR abnormal.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a network architecture provided by one embodiment of the present application;
FIG. 2 illustrates a diagram of a message access main thread method for a child thread;
FIG. 3 illustrates a diagram of a call stack structure;
FIG. 4 is a flowchart of a method for collecting ANR anomaly data according to an embodiment of the present application;
FIG. 5 is a flowchart of a method for displaying ANR anomaly data according to an embodiment of the present application;
FIG. 6 is a schematic illustration of a visual display of operational data provided by an embodiment of the present application;
FIG. 7 is a diagram illustrating visualization of main thread call stack data provided by another embodiment of the present application;
FIG. 8 is a schematic diagram of a visualization of main thread task data provided by another embodiment of the present application;
FIG. 9 is a schematic diagram illustrating the data for a visualization display function provided in another embodiment of the present application;
FIG. 10 is a block diagram of an ANR anomaly data collection apparatus provided by an embodiment of the present application;
fig. 11 is a block diagram of a display device for ANR anomaly data according to another embodiment of the present application;
FIG. 12 is a schematic diagram of a computer device provided by one embodiment of the present application.
Detailed Description
Before the technical solutions of the present application are introduced, some background knowledge related to the present application will be described. The following related arts as alternatives can be arbitrarily combined with the technical solutions of the embodiments of the present application, and all of them belong to the scope of the embodiments of the present application. The embodiment of the present application includes at least part of the following contents.
The system architecture and the service scenario described in the embodiment of the present application are for more clearly illustrating the technical solution of the embodiment of the present application, and do not constitute a limitation to the technical solution provided in the embodiment of the present application, and it can be known by a person skilled in the art that the technical solution provided in the embodiment of the present application is also applicable to similar technical problems along with the evolution of the system architecture and the appearance of a new service scenario.
Referring to fig. 1, a schematic diagram of a system architecture according to an embodiment of the present application is shown. The system architecture may include: electronic device 10, server 20 and analysis device 30.
The electronic device 10 may be an electronic device having a process and a thread with an interaction function, such as a smart phone, a tablet computer, a desktop computer, a portable computer, a smart television, and a VR device.
The server 20 is a device having a function of receiving, storing, and transmitting data, and is configured to receive and store operation data transmitted when ANR occurs in a target application, and transmit the stored operation data of the target application in a period of time before an ANR abnormality occurs to the analysis device 30 when the analysis device 30 requests the server 20 for the operation data of the target application. The server 20 may be an independent server device, or may be a server cluster or a distributed system formed by a plurality of physical servers. The server 20 may be a server, a server cluster composed of a plurality of servers, or a cloud computing service center.
The analysis device 30 has functions of sending, storing and receiving, and has a capability of displaying data visually, and the analysis device 30 may be a smart phone, a tablet computer, a desktop computer, a portable computer, a smart television, or the like, which has a certain computing capability and is capable of displaying graphical data.
Next, the Android system is taken as an example to introduce the relevant contents of the main thread and the sub-thread.
The main thread is also called a UI (User Interface) thread or an Interface thread, and the main thread is used for updating a thread of a UI Interface. In the process of creating the application program, the main thread of the application program is generated by default of the system and cannot be created by a user, and each application program only has one main thread. The main thread is responsible for processing events such as key events, touch events, screen drawing and the like generated by interaction of a user on an application program, the events are completed through UI components controlled by the main thread, and the common UI components comprise: folding panels, operation tables, number corner marks, buttons and dialog boxes. The system controls the UI components through a main thread, which is responsible for distributing time (including drawing events) to the UI components.
Child threads are also known as Worker threads: a worker thread is any other thread than the main thread.
The main thread is responsible for interacting with a user, generally speaking, an ANR exception is caused only when a task of the main thread in a process is overtime in response, the ANR exception causes a system crash, and an application cannot be used, and the ANR exception cannot be caused by the blocking or slow response of the sub-thread. Therefore, to reduce the generation of ANR exceptions and ensure the safety of the main thread, a sub-thread is generally used to process complex and time-consuming work, and the sub-thread cannot directly access the UI component, but accesses the UI component by accessing the main thread.
Referring to fig. 2, taking the Andriod system as an example, it shows a schematic diagram of a method for a child thread to access a main thread by a message.
In the process of creating the main thread, the Andriod system assigns a message queue and a message loop for the main thread, and messages generated by the sub-thread access the message queue of the main thread through Looper and Handler tools and are executed in the main thread. In the process of constructing the Handler, the system can assign the Handler to the Looper corresponding to the main thread, and then the Handler can add the message into a message queue managed by the Looper of the main thread. The Looper is used for circularly accessing the message queue, the sub-thread adds the message into the message queue of the main thread through the Handler, and the main thread obtains the message from the message queue of the main thread through the Looper, so that message circulation is realized.
The cause of ANR abnormality will be described below.
In the Android system, a Message Queue (Message Queue) is initialized in a main thread to process a UI Message. Generally, a message queue is stored in a linked list, and tasks in the message queue are sequentially stored in the message queue according to a time sequence to be executed, wherein UI messages include call back messages of ASM (Automatic Storage Management) and messages generated inside an application. The specific task message in the UI message queue corresponds to a specific time range, and an ANR exception may be triggered when the task message is not completed within the specified time range, and the cause of the ANR exception may include but is not limited to:
1. calculating for a long time in the main thread;
2. time-consuming I/O operations are performed in the main thread;
3. the main thread is in a blocking state and waits for acquiring a lock;
4. deadlock occurs between the main thread and other threads;
5. the main thread makes synchronized Binder calls with other threads.
The following describes the relevant contents of the callback function.
The callback function is a function which is transmitted to a function to be called by a calling party by taking a function to be called as a parameter, and after the called function is executed, the function is returned to be called by the parameter, and the function transmitted as the parameter is called as the callback function.
The relevant contents of the thread call stack will be described below with reference to fig. 3.
Referring to FIG. 3, a diagram illustrating the structure of a call stack is shown.
Taking the Android system as an example, the call stack, also called an execution stack, a control stack, a runtime stack, and a machine stack, is a data structure for storing data generated by an application program in operation. The call stack mainly stores a return address, a local variable, a parameter and an operating environment, wherein the return address refers to an address of a next execution instruction after the current function is executed. The call stack is used to track the point at which each active subroutine should return control after completion of execution.
The call stack is composed of a plurality of stack frames, each stack frame corresponds to a function, and the stack frames comprise: function parameters, return addresses, and local variables within frames. The operation direction of the call stack is from top to bottom, the stack pointer points to the top of the stack, the frame pointer points to the previous stack frame, and the whole call stack can be traversed through the frame pointer. The calling relation of the whole function is obtained by traversing the call stack, the real storage address of the function is obtained, and then the name of the function and the relevant information of the running process are obtained.
In the related art, analysis of online anomalies relies on a logging system. Currently, a common ANR anomaly analysis method mainly depends on kernel log data of an Android system, some simple custom memory data, process occupation and other data. However, with these data, it is very difficult to find the cause of the ANR exception occurring in the application, and the related art has difficulty finding the cause of the ANR exception, which mainly includes the following points:
1. in the related art, log data collected by a monitoring means is very limited, and a lot of key data are lacked in the collected log data;
2. the collected application program running data in the related technology is obscure and unintelligible, and often there are many system-level log data, such as CPU data, thread occupation and other data, which are usually difficult to correspond to the service of the application program, so that it is difficult to locate a specific service problem;
3. due to the fact that application data collected in the related technology is obscure and unintelligible in operation data, analysis of ANR abnormity has a high technical threshold, and developers cannot find the reason for ANR abnormity through the application data and the operation data intuitively;
4. the reasons for generating an ANR exception are various, and the ANR exception caused by an application program may be not only a task which is currently executed and takes too long time, but also one or more time-consuming tasks before the ANR exception is generated. In some cases, log data collected when an ANR anomaly occurs cannot reflect the operation content of an application program when the ANR anomaly occurs, so that it is difficult to find a cause of the ANR anomaly.
Therefore, a more complete ANR anomaly data collection method is needed, which can more accurately restore the application program execution site before, when, and after the ANR anomaly occurs, and by providing sufficient site data, developers can more intuitively and quickly investigate the cause of the ANR anomaly.
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Referring to fig. 4, a flowchart of a method for collecting ANR anomaly data according to an embodiment of the present application is shown, where an execution subject of each step of the method may be a target application in an electronic device, and the method may include at least one of the following steps (410-430):
step 410, collecting operation data of the target application program, wherein the operation data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of a target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program.
The target application is a type of computer program capable of generating ANR exceptions that is at least interactive with a user. The running data refers to data which is generated in the running process of the target application program and can reflect the execution condition of the application program at a certain moment or a certain period of time. The main thread refers to a thread responsible for interaction with a user, and please refer to the above for detailed description of the main thread. The main thread task data is data capable of reflecting task execution information and execution conditions in the main thread message queue.
In some embodiments, the time interval for the target application to fetch the main thread call stack data is fixed, also referred to as periodic fetching; in some embodiments, the time interval for the target application to fetch the main thread call stack data is not fixed. In some embodiments, the main thread task data and function execution data of the target application are obtained in real-time.
In some embodiments, the runtime data further includes an interface call stack, which refers to an interface in which one language calls another language in the application. In some embodiments, the type of interface call stack is a native interface, which is an interface used by Java to call C + + programs.
In some embodiments, a monitoring function is inserted into a target packet of a target application program, and the monitoring function is used for collecting, recording and reporting operation data; and an opening command is inserted into a position, which needs ANR abnormity monitoring, in the target packet, and the opening command is used for triggering execution of a monitoring function.
The target package is a set of related classes or interfaces to be monitored, and the monitoring function is inserted into the target package in the target application program, so that the target application program can obtain the running data through the monitoring function. In some embodiments, the snoop function is inserted into the target application by way of instrumentation. In some embodiments, a monitoring function is inserted into a target package by using an instrumentation method of an ASM in a target application, the monitoring function collects and records main thread call stack data, main thread task data and function execution data during an application running process, and sends the recorded running data to a server at a time when an ANR exception occurs.
Step 420, recording the operation data.
In some embodiments, logging operational data comprises: the application program stores the main thread call stack data, the main thread task data and the function execution data into corresponding storage queues respectively; the storage queue is used for recording the operation data of the latest period of time in a first-in first-out mode.
In some embodiments, the capacity of the storage queue corresponding to the main-thread call stack data is determined according to the duration of monitoring and the time interval of monitoring, where the capacity of the storage queue refers to the number of running data that can be stored in the storage queue, for example, a target application needs to monitor running data within 30s before ANR occurs, and collect a cycle 1s of the main-thread call stack data, and thus the capacity of the storage queue corresponding to the main-thread call stack data needs to be greater than or equal to 30. In general, the size of the compressed storage queue of the main thread task data and the function execution data should be kept within several megabytes, and the capacity of the storage queue of the main thread task data and the function execution data is obtained through a plurality of experiments, which is not specifically limited herein. In some embodiments, the main thread task data and the function execution data generated by the target application program can be found in the corresponding storage queue within the time range of listening for the main thread call stack data, and the storage queue corresponding to the main thread task data and the function execution data may further include the main thread task data and the function execution data generated by the target application program outside the listening time range. In some embodiments, the storage queue is configured to use a first-in first-out manner, and recording the operation data in the last period of time means that the storage queue discards the operation data written first and writes new operation data when the operation data stored in the storage queue reaches the capacity of the storage queue. In some embodiments, the last period of time refers to a time frame in which the application listens to the operating data. In some embodiments, the store queue uses a poll method to move old operation data out of the store queue and a push method to write new operation data into the store queue.
And step 430, reporting ANR exception data to a server when the target application program generates ANR, where the ANR exception data includes the ANR occurrence time and operation data corresponding to the ANR.
The operation data corresponding to the ANR refers to the main-thread call stack data, the main-thread task data, and the function execution data recorded in the storage queue when the ANR is generated. In some embodiments, in the case of ANR, the application program creates a document, where the name of the document is the occurrence time of ANR, the content of the document is operation data corresponding to ANR, and the application program uploads the document to the server.
In some embodiments, the application program collects and records main thread call stack data, main thread task data and function execution data in the running process, and when the application program has an ANR exception, the application program sends the main thread call stack data, the main thread task data and the function execution data recorded in the storage queue to the server.
In summary, the main thread call stack data, the main thread task data and the function execution data are collected and recorded by the application program, and the recorded main thread call stack data, main thread task data and function execution data are sent to the server when the application program generates the ANR, so that the purpose of collecting the operation data causing the ANR abnormality in a targeted manner is achieved, a complete application program operation scene is provided for ANR abnormality analysis, and the ANR abnormality analysis difficulty is reduced.
Next, a method of acquiring operation data of the target application will be described.
In some embodiments, the main thread call stack data includes a correspondence between at least one set of main thread stack information and call time information;
collecting operating data of a target application program, comprising:
acquiring main thread stack information, wherein the main thread stack information is used for indicating the calling relationship among various methods in a main thread;
and acquiring calling time information corresponding to the main thread stack information, wherein the calling time information is used for indicating the acquiring time of the main thread stack information.
In some embodiments, an application program periodically collects main thread call stack information, and in each sampling period, the application program determines whether to collect the main thread call stack information or not by monitoring a state, and in the case of determining to collect the main thread call stack information, the application program uses a run stack information acquisition tool to acquire the main thread stack information, and uses a time acquisition tool to acquire call time information corresponding to the main thread stack information; and the application program does not collect the call stack information of the main thread under the condition of determining not to collect the call stack information of the main thread. In some embodiments, the call time information corresponding to the thread stack information is obtained by subtracting the time to start monitoring the target application from the current time. In some embodiments, in a certain sampling period, after acquiring the main thread call stack information and the call time information corresponding to the main thread stack information, the application program constructs an object of the main thread call stack, and records the acquired main thread stack information and the call time information corresponding to the main thread stack information in the constructed object of the main thread call stack.
In some embodiments, when the application determines to acquire the main thread stack information, the start monitoring time is T, the application acquires the main thread stack information by thread.
The calling condition in the main thread call stack can be mastered by acquiring the main thread call stack information, and analysis of the cause of ANR abnormity is facilitated.
In some embodiments, the main thread task data includes: the starting execution time, the execution duration and the CPU occupation duration of at least one target task, wherein the target task is a task in a message queue of a main thread;
collecting operating data of a target application program, comprising: under the condition that the target task starts to execute, acquiring the starting execution time of the target task and the first thread running time, wherein the first thread running time refers to the running time of a main thread when the target task starts to execute; under the condition that the execution of the target task is finished, the finishing execution time of the target task and the second thread running time are obtained, wherein the second thread running time refers to the running time of the main thread when the execution of the target task is finished; determining the execution duration of the target task according to the starting execution time of the target task and the ending execution time of the target task; and determining the CPU occupation time of the target task according to the first thread running time and the second thread running time.
The execution time length of the target task refers to the time interval from the beginning of the target task to the end of the target task. The CPU occupancy time of the target task refers to the time consumed by the main thread to execute the target task. Because an asynchronous execution mechanism exists in the application program, task switching may occur after a target task is executed for a period of time, the target task is not in a suspended state during execution, and the system switches other tasks to be executed, so that in some embodiments, the execution duration of the target task is longer than the CPU occupation duration; in other embodiments, the target task has an execution duration equal to the CPU occupancy duration.
In some embodiments, the main thread task data further includes an application running time corresponding to the start of execution of the target task, and the application obtains the running time of the application through a system time obtaining tool. In some embodiments, in the case that the target task starts to execute, the application program obtains the running time length of the application program corresponding to the start of executing the target task by the method of systemlock.
In some embodiments, in the case that the target task starts to execute, the application program obtains, through the time obtaining tool, a start execution time of the target task and a first thread runtime, where the first thread runtime refers to a runtime length of the main thread when the target task starts to execute. In some embodiments, the start execution time of the target task is obtained through system.
In some embodiments, when the target task starts to be executed, the application program obtains data when the task is finished through the callback information, and for details of the callback, reference is made to the above, which is not described herein again. In some embodiments, in the case that the execution of the target task is finished, the application program obtains, by the time obtaining tool, a finished execution time of the target task and a second thread run time, where the second thread run time refers to a run time of the main thread when the execution of the target task is finished. In some embodiments, the end execution time of the target task is obtained through system.
In some embodiments, the application program obtains the execution duration of the target task by subtracting the target task end execution time and the target task start execution time.
In some embodiments, the application obtains the CPU occupancy duration for the target task by subtracting the first thread runtime from the second thread runtime.
In some embodiments, the main thread task data further includes execution information of the target task, the execution information indicating an execution environment and an execution result of the target task; after the execution duration of the target task is determined according to the starting execution time of the target task and the ending execution time of the target task, the method further comprises the following steps: acquiring execution information of a target task under the condition that the execution duration is greater than or equal to a threshold value; the execution information comprises field information and parameter information, the field information is used for indicating a field where the target task is located, and the parameter information is used for indicating the field condition of the target task during execution.
In some embodiments, the threshold value of the target task is determined by self-definition, and in some embodiments, the application program determines the threshold value of the execution time of the target task through a variable named config.
In some embodiments, the target application program judges the execution condition of the target task by comparing whether the execution duration of the target task exceeds a threshold value, and records the execution information of the target task when the execution duration of the target task is greater than or equal to the threshold value. And under the condition that the execution time of the target task is less than the threshold value, the target application program records and/or does not record the execution information of the target task.
In some embodiments, when the execution duration of the target task is greater than or equal to a threshold value, the target application program obtains execution information of the target task, where the execution information includes field information and parameter information, the field information is used to indicate a field where the target task is located, and the parameter information is used to indicate a field situation when the target task is executed. In some embodiments, the field information is used to store class-level variables and instance-level variables for Java. In some embodiments, the obtaining, by the target application, the parameter information of the target program includes: callback information, target (target node) information, information of calling parameters in the target task execution process and execution state information, wherein the execution state information is used for indicating whether the target task is executed or not. In some embodiments, the target application creates a variable named period to indicate the execution status of the target task, and uses-1 to indicate that the target task is completed, 0 to indicate that the target task is executing, and 1 to indicate that the target task is not executing.
Under the condition that the execution time of the target task is greater than or equal to the threshold value, the execution condition of the target task comprises the following steps: the target task is executed completely or the target task is not executed completely but the execution time is too long, so that the target task is executed and finished. In some embodiments, when the target application starts executing the target task, the target application creates an object corresponding to the target task, where the object is used to record parameter information of the target task during the execution of the target application, for example, create an object named as a message when a certain target task starts executing.
In some embodiments, when the execution duration of the target task is greater than or equal to a threshold value, the target application program first determines whether execution information exists in an object corresponding to the target task, and when the execution information exists in the object corresponding to the target task, the target application program records the execution information of the target task; and under the condition that execution information does not exist in the object corresponding to the target task, the target application program further judges whether the target task has callback information, and under the condition that the callback information does not exist in the target task, the parameter information record corresponding to the target task is used for indicating the parameter with unsuccessful callback of the target application program.
The execution process of the target task can be fully known by collecting the main thread task data through the target application program, the execution site of the target task is restored, and analysis of the reason of ANR abnormity is facilitated.
In some embodiments, the function execution data comprises: the function name, the starting execution time, the ending execution time, the execution duration and the CPU occupation duration of at least one target function; collecting operating data of a target application program, comprising: under the condition that the target function starts to execute, acquiring a function name, a starting execution time and a third thread running time of the target function, wherein the third thread running time refers to the running time of a thread in which the target function is located when the target function starts to execute; under the condition that the execution of the target function is finished, the finished execution time of the target function and the fourth thread running time are obtained, wherein the fourth thread running time refers to the running time of the thread where the target function is located when the execution of the target function is finished; determining the execution duration of the target function according to the starting execution time of the target function and the ending execution time of the target function; and determining the CPU occupation time of the target function according to the third thread running time and the fourth thread running time.
In some embodiments, the application program collects the execution data of the function in the thread by means of instrumentation in the target packet, inserts the monitoring function in the head and tail of the target function by means of instrumentation, and collects and records the execution data of the target function. In some embodiments, the application program collects the function name of the objective function by the method of visitMethodInsn when the objective function starts and/or finishes executing. In some embodiments, in the case that at least one function has the same name as the target function, the application program further includes a parameter list in the function name of the target function, and the parameter list is used for distinguishing the target function from other functions having the same name.
In some embodiments, in the case that the target function starts to execute, the target application program obtains, by the time obtaining tool, a start execution time of the target function and a third thread run time, where the third thread run time refers to a run time of a thread in which the target function is located when the target function starts to execute. In some embodiments, the start execution time of the objective function is obtained through system.
In some embodiments, in the case that the execution of the target function is finished, the target application program obtains, by the time obtaining tool, a finished execution time of the target function and a fourth thread run time, where the fourth thread run time refers to a run time of a thread in which the target function is located when the execution of the target function is finished. In some embodiments, the end execution time of the objective function is obtained through system.
In some embodiments, the target application obtains the execution duration of the target function by subtracting the end execution time of the target function from the start execution time of the target function.
In some embodiments, the target application obtains the CPU footprint of the target function by subtracting the fourth thread run time from the third thread run time.
The execution condition of the target function can be selectively and pertinently tracked by acquiring the function execution data of the thread in the target application program, and analysis of the reason causing the ANR abnormity is facilitated.
Referring to fig. 5, which shows a flowchart of a method for displaying ANR abnormal data according to an embodiment of the present application, an execution subject of each step of the method may be an analysis device, and the method may include at least one of the following steps (510-:
step 510, obtaining ANR exception data of the target application program from the server, where the ANR exception data includes ANR occurrence time of the target application program and operation data corresponding to the ANR, and the operation data includes main thread call stack data, main thread task data, and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of a target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program.
In some embodiments, the main thread call stack data comprises: the method comprises the steps that main thread stack information and calling time corresponding to the main thread stack information are obtained, the main thread stack information refers to the calling relation among various methods in a main thread, and the calling time information refers to the time interval between the current main thread stack information and the start of obtaining operation data; the main thread task data comprises: the method comprises the steps that the starting execution time, the CPU occupation time and execution information of at least one target task are obtained, the target task is a task in a main thread message queue, and the execution information is used for indicating the execution environment and the execution result of the target task; the function execution data includes: the function name, the starting execution time, the ending execution time, the execution duration and the CPU occupation duration of at least one objective function.
In some embodiments, the main thread task data further includes a running time of the target application program corresponding to the start of execution of the target task.
In some embodiments, the parameter information of the target task is used to indicate a field condition when the target task is executed. The execution information of the target task comprises field information and parameter information.
For details of the execution information and other operation information, please refer to the above, which is not described herein.
In some embodiments, the analysis device obtains, by the server, ANR exception data of the target application, the ANR exception data including an occurrence time of ANR of the target application and execution data corresponding to the ANR.
And step 520, visually displaying the operation data.
And the analysis equipment visually displays the operation data obtained by the server.
Please refer to fig. 6, which illustrates a schematic diagram of a method for displaying ANR abnormal data according to an embodiment of the present application.
In some embodiments, the visualization displays operational data, including: respectively displaying a time shaft 610, main thread call stack data 620, main thread task data 630, function execution data 640 and an information window 650 according to the arrangement sequence, wherein the information window 650 is used for displaying detailed information of the running data; the main thread call stack data, the main thread task data and the function execution data are respectively represented by a timeline with a width.
In some embodiments, timeline 610 is a line segment with a time scale. In some embodiments, the timeline 610, main-thread call stack data 620, main-thread task data 630, function execution data 640, and information window 650 are displayed in an order from top to bottom or from left to right, respectively; alternatively, main-thread call stack data 620, a time axis 610, main-thread task data 630, function execution data 640, and an information window 650 are displayed from top to bottom or from left to right, respectively; alternatively, main-thread call stack data 620, main-thread task data 630, function execution data 640, timeline 610, and information window 650 are displayed from top to bottom or from left to right, respectively; alternatively, main thread call stack data 620, main thread task data 630, function execution data 640, information window 650, and timeline 610 are shown from top to bottom or from left to right, respectively.
In some embodiments, the analysis device obtains ANR exception data of the target application from the server, the ANR exception data including an occurrence time of ANR of the target application and execution data corresponding to the ANR, the execution data including main-thread call stack data 620, main-thread task data 630, and function execution data 640. The analysis device completes the visualization of the running data in a manner of sequentially displaying a time axis 610, main thread call stack data 620, main thread task data 630, function execution data 640, and an information window 650 from top to bottom.
In summary, the analysis device acquires the ANR exception data of the target application from the server, and the operation data is visually displayed, so that the operation site of the application before the ANR exception occurs in the application is clearly displayed according to the timeline, and analysis of the cause of the ANR exception is facilitated.
Next, a method for visually displaying the operation data will be described with reference to fig. 7, 8, and 9.
Please refer to fig. 7, which illustrates a schematic diagram of a method for displaying ANR anomaly data according to another embodiment.
In some embodiments, call time information corresponding to main thread stack information 622 is identified using a distinguishing mark 621 on a timeline 623 corresponding to the main thread call stack data, and main thread stack information 622 associated with the call time information is displayed in an information window 651 corresponding to the distinguishing mark 621, the distinguishing mark 621 being an identification that can be distinguished from the timeline 623.
In some embodiments, the analyzing device selects a circle as the distinguishing mark 621, locates the position of the call time information corresponding to the main thread stack information 622 on the timeline 623 corresponding to the main thread call stack data through the time axis 610, and identifies the position of the call time information by using the circle-shaped distinguishing mark 621, and the analyzing device displays the main thread stack information 622 of the main thread call stack data 620 in the information window 651 corresponding to the circle-shaped distinguishing mark 621.
The main thread stack information and the corresponding calling time information of the main thread stack information in a period of time before the ANR occurs can be clearly displayed through visualizing the main thread calling stack data through the analysis equipment, and the ANR abnormity analysis is facilitated.
Referring to fig. 8, a visual display effect diagram of another embodiment is shown.
In some embodiments, the main-thread task data is arranged in chronological order, with different colors identifying different target tasks 632; the function execution data 640 is arranged in time series, with different colors identifying different ones of the objective functions.
In some embodiments, the display position of the target task 632 on the timeline 631 corresponding to the main thread task data 630 is determined by the start execution time and the end execution time of the target task 632; or, the display position of the target task on the timeline 631 corresponding to the main thread task data 630 is determined according to the starting execution time and the execution duration of the target task 632; the execution time starting execution time duration, the CPU occupation time duration, and the execution information of the target task are displayed in the information window 651 corresponding to the display position.
In some embodiments, the display position of the target task on the timeline corresponding to the main thread task data is a segment of the timeline on timeline 631.
In some embodiments, the analysis device locates, through the time axis 610, a display position of a start execution time and an end execution time of the target task on a timeline corresponding to the main thread task data; in some embodiments, the analytics device locates, via the time axis 610, the location of the start execution time of the target task 632 on the timeline 631 to which the main-thread task data 630 corresponds and determines, via the execution time of the target task 632, the display location of the target task on the timeline 631 to which the main-thread task data corresponds.
In some embodiments, the analysis device displays the start execution time 633, the CPU footprint 634, the execution time 635 of the target task, and the execution information of the target application in the information window 651 corresponding to the display position of the target task 632. In some embodiments, the execution information includes the parameter information 636 and the field information 637, and the detailed information about the field information and the parameter information is described above and is not described herein again.
In some embodiments, the information displayed in the information window 651 corresponding to the display position of the target task 632 by the analysis device further includes the corresponding running time of the application program when the target task starts to execute. Displaying the corresponding application program running time length when the target task starts to execute in the information window is helpful for analyzing the generation reason of the ANR abnormity.
The busyness degree of the main thread can be visually displayed by visually displaying the task data of the main thread, information such as the action and execution parameters of each target task can be clearly displayed through an information window corresponding to the target task, and the time consumption situation of the technical task for detecting the target task is facilitated.
Referring to fig. 9, a visual display effect diagram of another embodiment is shown.
In some embodiments, arranging the function execution data 640 in chronological order includes: determining the display position of the target function on the timeline 641 corresponding to the function execution data 640 according to the start execution time and the end execution time of the target function; or, the display position of the objective function on the timeline 641 corresponding to the function execution data is determined according to the start execution time and the execution duration of the objective function; the function name 642, the execution time 643, and the CPU occupation time 644 of the objective function are displayed in the information window 651 corresponding to the display position.
In some embodiments, the analysis device locates, through the time axis 610, a display position of the start execution time and the end execution time of the objective function on the timeline 641 corresponding to the function execution data; in some embodiments, the analysis apparatus locates the position of the start execution time of the objective function on the timeline 641 corresponding to the function execution data 640 through the time axis 610, and determines the display position of the objective function on the timeline 641 corresponding to the function execution data 640 by the position of the start execution time on the timeline 641 corresponding to the function execution data 640 and the execution time length 643 of the objective function.
In some embodiments, the analysis apparatus displays the function name 642, the execution duration 643, and the CPU occupation duration 644 of the objective function in the information window 651 corresponding to the display position of the objective function.
In some embodiments, in the function execution data, a parameter list 645 is further included in the function name of the objective function, and the parameter list 645 is used to distinguish the objective function from other functions of the same name.
In some embodiments, in the case that a call relationship exists between target functions, determining the call relationship between the target functions according to the starting execution time and the ending execution time of the target functions; and displaying the called target function below the called target function.
The function with the calling relation has a certain relation between the starting execution time and the ending execution time, the starting execution time of the calling target function is smaller than or equal to the starting execution time of the called target function, and the ending execution time of the calling target function is larger than or equal to the ending execution time of the called target function. In some embodiments, the analysis device determines a calling relationship between the target functions by the start execution time and the end execution time of the target functions, and displays the called target functions above the calling target functions.
In some embodiments, the analysis device obtains, by the server, operation data when the ANR occurs, where the operation data includes function execution data. The target execution data comprises a target function 1, a target function 2 and a target function 3, wherein the function name of the target function 1 is 1, the execution time is 300ms, the CPU occupation time is 275ms, the starting execution time is 1000ms, and the ending execution time is 1300 ms; the function name of the target function 2 is 2, the execution time is 1000ms, the CPU occupation time is 700ms, the starting execution time is 500ms, and the ending execution time is 1500 ms; the function name of the target function 3 is 3, the execution time is 100ms, the CPU occupation time is 75ms, the start execution time is 1700ms, and the end execution time is 1800 ms. The analysis device determines that a calling-called relation exists between a target function 2 and the target function 1 through the starting execution time and the ending execution time of the target task (the starting execution time 1000ms of the target function 1 is greater than the starting execution time 700ms of the target function 2, the ending execution time 1300ms of the target function 1 is less than the ending execution time 1500ms of the target function 2), a calling relation does not exist between the target function 3 and the target function 1, a calling relation does not exist between the target function 3 and the target function 2, the analysis device determines the display positions of the target function 2 and the target function 3 on a time axis corresponding to the function execution data through the starting execution time and the ending execution time of the target functions 2 and 3, and respectively displaying the function name, the execution time length and the CPU occupation time length corresponding to the target functions 2 and 3 in the information window of the corresponding display position. The analysis device determines the display position of the objective function 1 by the starting execution time and the ending execution time of the objective function 1 below the objective function 2, and displays the function name, the execution time length and the CPU occupation time length of the objective function 1 on the display position of the objective function 1.
The calling relation among the target functions can be cleared through visually displaying the function execution data, and the execution condition of the target functions can be clearly shown.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 10, a block diagram of an ANR anomaly data collection apparatus according to an embodiment of the present application is shown. The device has the function of implementing the method for collecting the ANR abnormal data, and the function can be implemented by hardware or by hardware executing corresponding software. The apparatus may be the electronic device described above, or may be provided in an electronic device. The apparatus 1000 may include: the device comprises an acquisition module 1010, a recording module 1020 and a reporting module 1030.
An acquisition module 1010, configured to acquire operation data of the target application program, where the operation data includes main thread call stack data, main thread task data, and function execution data; the main thread call stack data is used for indicating the call condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program.
A recording module 1020 for recording the operation data.
A reporting module 1030, configured to report, to a server, ANR exception data when the target application generates ANR, where the ANR exception data includes occurrence time of the ANR and the operation data corresponding to the ANR.
In some embodiments, the main thread call stack data comprises a correspondence between at least one set of main thread stack information and call time information; the acquisition module 1010 includes a first acquisition unit configured to: acquiring the main thread stack information, wherein the main thread stack information is used for indicating the calling relationship among various devices in the main thread; and acquiring calling time information corresponding to the main thread stack information, wherein the calling time information is used for indicating the acquiring time of the main thread stack information.
In some embodiments, the main thread task data comprises: the starting execution time, the execution duration and the CPU occupation duration of at least one target task, wherein the target task is a task in a message queue of the main thread; the acquisition module 1010 further includes a second acquisition unit configured to:
under the condition that the target task starts to execute, acquiring the starting execution time of the target task and the first thread running time, wherein the first thread running time refers to the running time of the main thread when the target task starts to execute; under the condition that the execution of the target task is finished, acquiring the finish execution time of the target task and the second thread running time, wherein the second thread running time refers to the running time of the main thread when the execution of the target task is finished; determining the execution duration of the target task according to the starting execution time of the target task and the ending execution time of the target task; and determining the CPU occupation time of the target task according to the first thread running time and the second thread running time.
In some embodiments, the main thread task data further includes execution information of the target task, the execution information indicating an execution environment and an execution result of the target task; the second obtaining unit is further configured to obtain the execution information of the target task when the execution duration is greater than or equal to a threshold value; the execution information comprises field information and parameter information, the field information is used for indicating a field where the target task is located, and the parameter information is used for indicating the field condition of the target task during execution.
In some embodiments, the function execution data comprises: the function name, the starting execution time, the ending execution time, the execution duration and the CPU occupation duration of at least one target function; the acquisition module 1010 further includes a third acquisition unit configured to: under the condition that the target function starts to execute, acquiring a function name, a starting execution time and a third thread running time of the target function, wherein the third thread running time refers to the running time of a thread where the target function is located when the target function starts to execute; under the condition that the execution of the target function is finished, acquiring the finish execution time of the target function and a fourth thread running time, wherein the fourth thread running time refers to the running time of a thread in which the target function is located when the execution of the target function is finished; determining the execution duration of the target function according to the starting execution time of the target function and the ending execution time of the target function; and determining the CPU occupation time of the target function according to the third thread running time and the fourth thread running time.
In some embodiments, the recording module 1020 is configured to:
storing the main thread call stack data, the main thread task data and the function execution data into corresponding storage queues respectively; the storage queue is used for recording the operation data of a latest period of time in a first-in first-out mode. In some embodiments, a monitoring function is inserted into a target packet of the target application, and the monitoring function is used for collecting, recording and reporting the running data; and inserting an opening command into a position, which needs to perform ANR abnormity monitoring, in the target packet, wherein the opening command is used for triggering execution of the monitoring function.
Please refer to fig. 11, which illustrates a block diagram of a display device for ANR abnormal data according to an embodiment of the present application. The device has the function of implementing the display method of the ANR abnormal data, and the function can be implemented by hardware or by hardware executing corresponding software. The apparatus may be an analysis device as described above, or may be provided in an analysis device. The apparatus 1100 may include: an acquisition module 1110 and a display module 1120.
An obtaining module 1110, configured to obtain, from a server, ANR exception data of a target application, where the ANR exception data includes an occurrence time of ANR of the target application and operation data corresponding to the ANR, and the operation data includes main-thread call stack data, main-thread task data, and function execution data; the main thread call stack data is used for indicating the call condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program.
A display module 1120, configured to visually display the operation data.
In some embodiments, the main thread call stack data comprises: the method comprises the steps that main thread stack information and calling time corresponding to the main thread stack information are obtained, the main thread stack information refers to the calling relation among various devices in a main thread, and the calling time information refers to the time interval between the current main thread stack information and the time when the running data begins to be obtained; the main thread task data comprises: the method comprises the steps that the starting execution time, the CPU occupation time and the execution information of at least one target task are obtained, the target task is a task in a main thread message queue, and the execution information is used for indicating the execution environment and the execution result of the target task; the function execution data includes: the function name, the starting execution time, the ending execution time, the execution duration and the CPU occupation duration of at least one objective function.
In some embodiments, the display module 1120 is configured to: respectively displaying a time axis, the main thread call stack data, the main thread task data, the function execution data and an information window according to an arrangement sequence, wherein the information window is used for displaying detailed information of the operation data; and respectively representing the main thread call stack data, the main thread task data and the function execution data by using a time line with width.
In some embodiments, the display module 1120 is configured to: respectively displaying a time axis, the main thread call stack data, the main thread task data, the function execution data and an information window according to an arrangement sequence, wherein the information window is used for displaying detailed information of the operation data; and respectively representing the main thread call stack data, the main thread task data and the function execution data by using a time line with width.
In some embodiments, the display module 1120 is configured to: and identifying calling time information corresponding to the main thread stack information by using a distinguishing mark on a time line corresponding to the main thread calling stack data, and displaying the main thread stack information associated with the calling time information in an information window corresponding to the distinguishing mark, wherein the distinguishing mark is an identifier which can be distinguished from the time line.
In some embodiments, the display module 1120 is configured to: arranging the main thread task data according to a time sequence, and identifying different target tasks by using different colors; the function execution data is arranged in time order, and different target functions are identified using different colors.
In some embodiments, the display module 1120 is configured to: determining the display position of the target task on a timeline corresponding to the main thread task data according to the starting execution time and the ending execution time of the target task; or determining the display position of the target task on a timeline corresponding to the main thread task data according to the starting execution time and the execution duration of the target task; and displaying the starting execution time, the ending execution time, the execution duration, the CPU occupation duration and the execution information of the target task in an information window corresponding to the display position.
In some embodiments, the display module 1120 is configured to: determining the display position of the target function on a timeline corresponding to the function execution data according to the starting execution time and the ending execution time of the target function; or determining the display position of the objective function on a timeline corresponding to the function execution data according to the starting execution time and the execution duration of the objective function; and displaying the function name, the execution duration and the CPU occupation duration of the target function in an information window corresponding to the display position.
In some embodiments, the display module 1120 is configured to: determining the calling relation among the target functions according to the starting execution time and the ending execution time of the target functions under the condition that the calling relation exists among the target functions; and displaying the called target function below the called target function.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the content structure of the device may be divided into different functional modules to implement all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Referring to fig. 12, a block diagram of a computer device 1200 according to an embodiment of the present application is shown. The computer device 1200 may be the electronic device described above, and is configured to implement the ANR anomaly data collection method described above; the ANR anomaly data display device may be the analysis device described above, and is configured to implement the ANR anomaly data display method described above.
Generally, computer device 1200 includes: a processor 1201 and a memory 1202.
The processor 1201 may include one or more processing cores, such as a 4-core processor, an 8-core processor, or the like. The processor 1201 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 1201 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 1201 may be integrated with a GPU (Graphics Processing Unit) that is responsible for rendering and drawing content that the display screen needs to display. In some embodiments, the processor 1201 may further include an AI (Artificial Intelligence) processor for processing a computing operation related to machine learning.
Memory 1202 may include one or more computer-readable storage media, which may be non-transitory. Memory 1202 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices.
Those skilled in the art will appreciate that the configuration shown in FIG. 12 is not intended to be limiting of the computer device 1200 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
In an example embodiment, there is also provided a computer device comprising a processor and a memory, the memory having stored therein a computer program. The computer program is configured to be executed by one or more processors to implement the ANR abnormality data collection method or the ANR abnormality data display method.
In an exemplary embodiment, a computer-readable storage medium is also provided, in which a computer program is stored, which when executed by a processor of a computer device implements the ANR abnormality data collection method described above, or implements the ANR abnormality data display method described above.
Alternatively, the computer-readable storage medium may be a ROM (Read-Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, there is also provided a computer program product, which when run on a computer device, causes the computer device to execute the method of collecting ANR abnormality data as described above, or the method of displaying ANR abnormality data as described above.
It should be understood that reference to "a plurality" herein means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. In addition, the step numbers described herein only exemplarily show one possible execution sequence among the steps, and in some other embodiments, the steps may also be executed out of the numbering sequence, for example, two steps with different numbers are executed simultaneously, or two steps with different numbers are executed in a reverse order to the order shown in the figure, which is not limited by the embodiment of the present application.
The above description is only exemplary of the present application and should not be taken as limiting the present application, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (15)

1. A method for collecting application unresponsive ANR exception data, the method performed by a target application, the method comprising:
collecting operation data of the target application program, wherein the operation data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
recording the operation data;
reporting ANR abnormal data to a server when the target application program generates ANR, wherein the ANR abnormal data comprises the generation time of the ANR and the running data corresponding to the ANR.
2. The method of claim 1, wherein the main thread call stack data comprises a correspondence between at least one set of main thread stack information and call time information;
the acquiring the operation data of the target application program comprises the following steps:
acquiring the main thread stack information, wherein the main thread stack information is used for indicating the calling relationship among various methods in the main thread;
and acquiring calling time information corresponding to the main thread stack information, wherein the calling time information is used for indicating the acquiring time of the main thread stack information.
3. The method of claim 1, wherein the main thread task data comprises: the starting execution time, the execution duration and the CPU occupation duration of at least one target task, wherein the target task is a task in a message queue of the main thread;
the acquiring the operation data of the target application program comprises the following steps:
under the condition that the target task starts to execute, acquiring the starting execution time of the target task and the first thread running time, wherein the first thread running time refers to the running time of the main thread when the target task starts to execute;
under the condition that the execution of the target task is finished, acquiring the finish execution time of the target task and the second thread running time, wherein the second thread running time refers to the running time of the main thread when the execution of the target task is finished;
determining the execution duration of the target task according to the starting execution time of the target task and the ending execution time of the target task;
and determining the CPU occupation time of the target task according to the first thread running time and the second thread running time.
4. The method of claim 1, wherein the function execution data comprises: the function name, the starting execution time, the ending execution time, the execution duration and the CPU occupation duration of at least one target function;
the acquiring the operation data of the target application program comprises the following steps:
under the condition that the target function starts to execute, acquiring a function name, a starting execution time and a third thread running time of the target function, wherein the third thread running time refers to the running time of a thread where the target function is located when the target function starts to execute;
under the condition that the execution of the target function is finished, acquiring the finish execution time of the target function and a fourth thread running time, wherein the fourth thread running time refers to the running time of a thread in which the target function is located when the execution of the target function is finished;
determining the execution duration of the target function according to the starting execution time of the target function and the ending execution time of the target function;
and determining the CPU occupation time of the target function according to the third thread running time and the fourth thread running time.
5. The method according to any one of claims 1 to 4,
a monitoring function is inserted into a target packet of the target application program, and the monitoring function is used for collecting, recording and reporting the running data;
and inserting an opening command into a position, which needs to perform ANR abnormity monitoring, in the target packet, wherein the opening command is used for triggering execution of the monitoring function.
6. A method for displaying unresponsive ANR exception data of an application, the method comprising:
obtaining ANR exception data of a target application program from a server, wherein the ANR exception data comprises occurrence time of ANR of the target application program and running data corresponding to the ANR, and the running data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
and visually displaying the operation data.
7. The method of claim 6,
the main thread call stack data comprises: the method comprises the steps that main thread stack information and calling time corresponding to the main thread stack information are obtained, the main thread stack information refers to the calling relation among various methods in a main thread, and the calling time information refers to the time interval between the current main thread stack information and the start of obtaining the running data;
the main thread task data comprises: the method comprises the steps that the starting execution time, the CPU occupation time and the execution information of at least one target task are obtained, the target task is a task in a main thread message queue, and the execution information is used for indicating the execution environment and the execution result of the target task;
the function execution data includes: the function name, the starting execution time, the ending execution time, the execution duration and the CPU occupation duration of at least one objective function.
8. The method of claim 6, wherein the visually displaying the operational data comprises:
respectively displaying a time axis, the main thread call stack data, the main thread task data, the function execution data and an information window according to an arrangement sequence, wherein the information window is used for displaying detailed information of the operation data;
and respectively representing the main thread call stack data, the main thread task data and the function execution data by using a time line with width.
9. The method of claim 6, wherein the visually displaying the operational data comprises:
and identifying calling time information corresponding to the main thread stack information by using a distinguishing mark on a time line corresponding to the main thread calling stack data, and displaying the main thread stack information associated with the calling time information in an information window corresponding to the distinguishing mark, wherein the distinguishing mark is an identifier which can be distinguished from the time line.
10. The method of claim 6, wherein the visually displaying the operational data comprises:
arranging the main thread task data according to a time sequence, and identifying different target tasks by using different colors;
the function execution data is arranged in time order, and different target functions are identified using different colors.
11. The method of claim 10, wherein said arranging said main-thread task data in chronological order comprises:
determining the display position of the target task on a timeline corresponding to the main thread task data according to the starting execution time and the ending execution time of the target task; or determining the display position of the target task on a timeline corresponding to the main thread task data according to the starting execution time and the execution duration of the target task;
and displaying the starting execution time, the ending execution time, the execution duration, the CPU occupation duration and the execution information of the target task in an information window corresponding to the display position.
12. An apparatus for collecting application unresponsive ANR anomaly data, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring running data of a target application program, and the running data comprises main thread call stack data, main thread task data and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
the recording module is used for recording the operation data;
and a reporting module, configured to report, to a server, ANR exception data when the target application generates ANR, where the ANR exception data includes an ANR occurrence time and the operation data corresponding to the ANR.
13. A display device for application unresponsive ANR exception data, the device comprising:
an obtaining module, configured to obtain, from a server, ANR exception data of a target application, where the ANR exception data includes an occurrence time of ANR of the target application and operation data corresponding to the ANR, and the operation data includes main-thread call stack data, main-thread task data, and function execution data; the main thread call stack data is used for indicating the calling condition of a main thread of the target application program, the main thread task data is used for indicating the task execution condition of the main thread at different time, and the function execution data is used for indicating the function execution condition in the thread of the target application program;
and the display module is used for visually displaying the operating data.
14. A computer device, characterized in that the computer device comprises a processor and a memory, in which a computer program is stored, which computer program is loaded and executed by the processor to implement the method according to any of claims 1 to 5, or to implement the method according to any of claims 6 to 11.
15. A computer readable storage medium, having stored thereon a computer program, the at least one instruction, the at least one program, the set of codes or the set of instructions being loaded and executed by a processor to implement the method according to any of claims 1 to 5 or to implement the method according to any of claims 6 to 11.
CN202110990795.5A 2021-08-26 2021-08-26 ANR abnormal data collection method, display method, device and equipment Active CN113626244B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110990795.5A CN113626244B (en) 2021-08-26 2021-08-26 ANR abnormal data collection method, display method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110990795.5A CN113626244B (en) 2021-08-26 2021-08-26 ANR abnormal data collection method, display method, device and equipment

Publications (2)

Publication Number Publication Date
CN113626244A true CN113626244A (en) 2021-11-09
CN113626244B CN113626244B (en) 2024-05-28

Family

ID=78387934

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110990795.5A Active CN113626244B (en) 2021-08-26 2021-08-26 ANR abnormal data collection method, display method, device and equipment

Country Status (1)

Country Link
CN (1) CN113626244B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002318712A (en) * 2001-04-20 2002-10-31 Matsushita Electric Ind Co Ltd Program running history analyzing method
CN101211309A (en) * 2006-12-29 2008-07-02 中兴通讯股份有限公司 Embedded system progress abnormal tracking position-finding method
CN106681811A (en) * 2016-12-08 2017-05-17 腾讯科技(深圳)有限公司 Multi-thread scheduling method and device based on thread pool
CN108052354A (en) * 2017-11-06 2018-05-18 北京趣拿软件科技有限公司 Definite method, apparatus, processor and terminal of the application program without response
CN108572906A (en) * 2018-04-24 2018-09-25 广州优视网络科技有限公司 ANR method for real-time monitoring, device, terminal and storage medium
CN109284269A (en) * 2018-10-17 2019-01-29 Oppo广东移动通信有限公司 Abnormal log analysis method, device, storage medium and server
CN111338713A (en) * 2020-02-10 2020-06-26 广州虎牙科技有限公司 Application blocking processing method, device, equipment and storage medium
CN112015612A (en) * 2019-05-28 2020-12-01 杭州萤石软件有限公司 Method and device for acquiring stuck information

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002318712A (en) * 2001-04-20 2002-10-31 Matsushita Electric Ind Co Ltd Program running history analyzing method
CN101211309A (en) * 2006-12-29 2008-07-02 中兴通讯股份有限公司 Embedded system progress abnormal tracking position-finding method
CN106681811A (en) * 2016-12-08 2017-05-17 腾讯科技(深圳)有限公司 Multi-thread scheduling method and device based on thread pool
CN108052354A (en) * 2017-11-06 2018-05-18 北京趣拿软件科技有限公司 Definite method, apparatus, processor and terminal of the application program without response
CN108572906A (en) * 2018-04-24 2018-09-25 广州优视网络科技有限公司 ANR method for real-time monitoring, device, terminal and storage medium
CN109284269A (en) * 2018-10-17 2019-01-29 Oppo广东移动通信有限公司 Abnormal log analysis method, device, storage medium and server
CN112015612A (en) * 2019-05-28 2020-12-01 杭州萤石软件有限公司 Method and device for acquiring stuck information
CN111338713A (en) * 2020-02-10 2020-06-26 广州虎牙科技有限公司 Application blocking processing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN113626244B (en) 2024-05-28

Similar Documents

Publication Publication Date Title
US8949671B2 (en) Fault detection, diagnosis, and prevention for complex computing systems
US5898873A (en) System and method for visualizing system operation trace chronologies
US8464221B2 (en) Visualization tool for system tracing infrastructure events
US5214780A (en) Synchronized journaling system
US8051409B1 (en) Monitoring memory accesses for multiple computer processes
US9355003B2 (en) Capturing trace information using annotated trace output
CN106294176B (en) The method and system that application failure positions in Mac OS systems
JP2009516239A (en) General purpose multi-instance method and GUI detection system for tracking and monitoring computer applications
US8667472B1 (en) System and method of instrumenting code for in-production monitoring
US20100180245A1 (en) Methods and products for determining and visualizin ic behavior
US10528456B2 (en) Determining idle testing periods
CN107357731A (en) Process produces monitoring, analysis and the processing method of core dump problems
CN111339118A (en) Kubernetes-based resource change history recording method and device
CN112306833A (en) Application program crash statistical method and device, computer equipment and storage medium
CN109800124B (en) CPU utilization monitoring method and device, electronic equipment and storage medium
CN113190427A (en) Caton monitoring method and device, electronic equipment and storage medium
CN113760491A (en) Task scheduling system, method, equipment and storage medium
Mathur et al. Idea: an immersive debugger for actors
CN113626244B (en) ANR abnormal data collection method, display method, device and equipment
CN115237728B (en) Visual monitoring method for real-time operating system running state
CN115061837A (en) Method and device for scheduling, tracking and acquiring user space call stack
CN115481025A (en) Script recording method and device for automatic test, computer equipment and medium
CN114706581A (en) Image analysis method, image analysis device, computer equipment and storage medium
CN114610386A (en) Interaction method, device, equipment and storage medium of H5 and application program
CN112463626A (en) Memory leak positioning method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant