CN116860552A - Application program operation monitoring method and device, electronic equipment and storage medium - Google Patents
Application program operation monitoring method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN116860552A CN116860552A CN202310815147.5A CN202310815147A CN116860552A CN 116860552 A CN116860552 A CN 116860552A CN 202310815147 A CN202310815147 A CN 202310815147A CN 116860552 A CN116860552 A CN 116860552A
- Authority
- CN
- China
- Prior art keywords
- application program
- preset threshold
- blocking
- determining
- stuck
- 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.)
- Pending
Links
- 238000012544 monitoring process Methods 0.000 title claims abstract description 79
- 238000000034 method Methods 0.000 title claims abstract description 49
- 230000000903 blocking effect Effects 0.000 claims abstract description 94
- 238000012806 monitoring device Methods 0.000 claims abstract description 4
- 230000008859 change Effects 0.000 claims description 17
- 230000004044 response Effects 0.000 claims description 12
- 230000002159 abnormal effect Effects 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 9
- 238000004883 computer application Methods 0.000 abstract description 2
- 238000001514 detection method Methods 0.000 description 8
- 230000008439 repair process Effects 0.000 description 7
- 230000008901 benefit Effects 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 230000015556 catabolic process Effects 0.000 description 3
- 230000005856 abnormality Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 230000004083 survival effect Effects 0.000 description 2
- 239000008358 core component Substances 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000003745 diagnosis Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000036541 health Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000009545 invasion Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003825 pressing Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3089—Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
- G06F11/3093—Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Quality & Reliability (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application discloses an application program operation monitoring method, an application program operation monitoring device, electronic equipment and a storage medium, and relates to the field of computer application and the field of digital medical treatment, wherein the method comprises the following steps: responding to an operation request of an application program executing task, and acquiring the operation time length of the operation cycle of the main thread in the wake-up state; judging whether the operation time length is greater than or equal to a first preset threshold value; if the running time length is greater than or equal to a first preset threshold value, determining that the application program is blocked; determining the stuck type of the stuck of the application program according to the operation time length, the first preset threshold and the second preset threshold; if the running time length is smaller than a first preset threshold value, determining that the application program is not blocked. By setting the first preset threshold and the second preset threshold, the application program can be accurately distinguished when the application program is monitored for blocking, so that the application program can be comprehensively identified for blocking, and the application program can be repaired in a targeted manner.
Description
Technical Field
The present application relates to the field of computer applications and the field of digital medical treatment, and in particular, to a method and apparatus for monitoring application program operation, an electronic device, and a storage medium.
Background
In the medical field, it goes without saying that the medical application of the medical staff and the service application provided for the patient run smoothly, if these applications get stuck, they may affect the diagnosis of the doctor, the detection of the patient and the normal operation of the medical equipment, and may even impair the health and life safety of the patient. Therefore, it is important to collect the application program operation jamming information to analyze the jamming reason and repair the application jamming in time.
In the prior art, as the memory of the mobile terminal is too high, the CPU consumption is too large, the electric quantity consumption is also large, the breakdown is also large, the survival time of the App entering the background is too low, and the like, the unstable factors of the App can be caused. The unstable factors can be detected through detection tools (such as a timer and CADisplayLink) or third-party software, the problem of breakdown can be solved in a development stage, and the problem of breakdown can be solved in a positioning way through collecting and analyzing crash logs, however, the influencing factors of the survival time of the App are mainly killed by a system, and the system is killed by the system without any signal reminding, so that the factors are difficult to accurately monitor, therefore, when the App is monitored, only the jam of the App can be monitored, the jam type of the App cannot be accurately positioned, and further, the jam cause analysis cannot be rapidly and accurately performed.
Disclosure of Invention
In view of the above, the present application provides a method, a device, an electronic device and a storage medium for monitoring application program operation, and aims to solve the technical problems in the prior art that when an App is monitored, only the App is monitored to be stuck, the type of the stuck App cannot be accurately located, and further, the analysis of the cause of the stuck App cannot be rapidly and accurately performed.
According to a first aspect of the present application, there is provided an application operation monitoring method, the method comprising:
responding to an operation request of an application program executing task, and acquiring the operation time length of the operation cycle of the main thread in the wake-up state;
judging whether the operation time length is greater than or equal to a first preset threshold value;
if the running time length is greater than or equal to a first preset threshold value, determining that the application program is blocked;
determining the stuck type of the stuck of the application program according to the operation time length, the first preset threshold and the second preset threshold;
if the running time length is smaller than a first preset threshold value, determining that the application program is not blocked.
Optionally, the step of acquiring the running duration of the running cycle of the main thread in the wake state in response to the operation request of the application program to execute the task specifically includes:
Responding to an operation request of an application program for executing tasks, adding the execution tasks to a main thread, and enabling the running cycle of the main thread to enter an awake state to execute the tasks;
when the running cycle of the main thread enters the awakening state to start executing tasks, the monitoring sub-thread starts timing so as to acquire the running time of the awakening state.
Optionally, the step of determining the stuck type of the stuck of the application program according to the operation duration, the first preset threshold and the second preset threshold specifically includes:
comparing the operation time length with a second preset threshold value;
if the running time length is greater than or equal to a second preset threshold value, determining that the application program is a system strong killing katon;
if the running time is greater than or equal to the first preset threshold and is smaller than the second preset threshold, determining that the application program is ordinary cartoon.
Optionally, after determining that the application program is stuck, the method further includes:
obtaining a blocking time stamp of blocking of an application program;
acquiring the clamping and positioning information of a main thread;
generating a stuck abnormal prompt message according to the stuck time stamp, the stuck positioning information and the stuck type;
and sending the blocking abnormal prompt information to a server.
Optionally, the method further comprises:
Responding to the starting operation of the application program, adding an observer to the running cycle of the main thread to monitor the state change of the running cycle of the main thread;
and starting a pre-established monitoring sub-thread, and monitoring whether the application program is blocked or not by using the monitoring sub-thread.
Optionally, the method further comprises:
responding to the cold start operation of the application program, and acquiring a first time stamp corresponding to the cold start operation;
obtaining a blocking duration and a second time stamp of target blocking of the application program, wherein the target blocking is the last blocking of the application program before cold start operation;
and determining the jamming type of the target jamming according to the jamming duration, the first time stamp and the second time stamp.
Optionally, the step of determining the stuck type of the target stuck according to the stuck duration, the first timestamp and the second timestamp specifically includes:
judging whether the length of the blocking time of the target blocking is larger than or equal to a second preset threshold value;
if the blocking time length of the target blocking is greater than or equal to a second preset threshold value, determining that the target blocking is the system strong killing blocking;
if the blocking duration of the target blocking is smaller than a second preset threshold, calculating a time interval between the first time stamp and the second time stamp;
If the time interval is smaller than or equal to a third preset threshold value, determining that the target stuck is a system strong killing stuck;
if the time interval is greater than a third preset threshold, determining that the target jamming is common jamming.
According to a second aspect of the present application, there is provided an application operation monitoring apparatus comprising:
the acquisition module is used for responding to an operation request of executing a task by an application program and acquiring the operation time length of the operation cycle of the main thread in the wake-up state;
the judging module is used for judging whether the operation time length is greater than or equal to a first preset threshold value;
the first determining module is used for determining that the application program is blocked if the running time is greater than or equal to a first preset threshold value;
the second determining module is used for determining the blocking type of blocking of the application program according to the operation time length, the first preset threshold value and the second preset threshold value;
and the third determining module is used for determining that the application program is not blocked if the running time length is smaller than a first preset threshold value.
Optionally, the acquiring module is specifically configured to:
responding to an operation request of an application program for executing tasks, adding the execution tasks to a main thread, and enabling the running cycle of the main thread to enter an awake state to execute the tasks;
When the running cycle of the main thread enters the awakening state to start executing tasks, the monitoring sub-thread starts timing so as to acquire the running time of the awakening state.
Optionally, the second determining module is specifically configured to:
comparing the operation time length with a second preset threshold value;
if the running time length is greater than or equal to a second preset threshold value, determining that the application program is a system strong killing katon;
if the running time is greater than or equal to the first preset threshold and is smaller than the second preset threshold, determining that the application program is ordinary cartoon.
Optionally, the acquiring module is further configured to:
obtaining a blocking time stamp of blocking of an application program;
and acquiring the clamping and positioning information of the main thread.
Optionally, the apparatus further comprises:
the generation module is used for generating a jamming abnormal prompt message according to the jamming timestamp, the jamming positioning information and the jamming type;
and the sending module is used for sending the katon abnormity prompt information to the server.
Optionally, the apparatus further comprises:
the adding module is used for responding to the starting operation of the application program, adding the running cycle from the observer to the main thread and monitoring the state change of the running cycle of the main thread;
the starting module is used for starting the monitoring sub-thread which is created in advance, and monitoring whether the application program is blocked or not by using the monitoring sub-thread.
Optionally, the acquiring module is further configured to:
responding to the cold start operation of the application program, and acquiring a first time stamp corresponding to the cold start operation;
and acquiring the blocking duration and the second time stamp of the target blocking of the application program, wherein the target blocking is the last blocking of the application program before the cold start operation.
Optionally, the apparatus further comprises:
and the fourth determining module is used for determining the jamming type of the target jamming according to the jamming duration, the first time stamp and the second time stamp.
Optionally, the judging module is further configured to judge whether the duration of the target click is greater than or equal to a second preset threshold.
Optionally, the apparatus further comprises:
a fifth determining module, configured to determine that the target stuck is a system forced killing stuck if the stuck time length of the target stuck is greater than or equal to a second preset threshold;
the calculating module is used for calculating the time interval between the first time stamp and the second time stamp if the blocking duration of the target blocking is smaller than a second preset threshold value;
a sixth determining module, configured to determine that the target stuck is a system forced killing stuck if the time interval is less than or equal to a third preset threshold;
and a seventh determining module, configured to determine that the target jamming is common jamming if the time interval is greater than a third preset threshold.
According to a third aspect of the present application there is provided an electronic device comprising a memory storing a computer program and a processor implementing the steps of the method of any of the first aspects when the computer program is executed.
According to a fourth aspect of the present application there is provided a readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the method of any of the first aspects.
By means of the technical scheme, the application program operation monitoring method, the device, the electronic equipment and the storage medium provided by the application are used for monitoring the operation duration of the task by monitoring the operation cycle of the main thread in the wake-up state by presetting a first preset threshold value for monitoring the jamming and responding to the operation request of the application program, and determining whether the main thread is jammed or not based on the operation duration and the first preset threshold value. And comparing the operation time length with a second preset threshold value set in advance under the condition that the application program is blocked, so as to analyze that the application program is ordinary blocked or the system is forcedly blocked. Compared with the prior art, application detection is performed by using a detection tool (such as a timer and CADisplayLink) or third-party software, and the respective technical problems are existed, such as low accuracy of the monitoring result, dependence on screen refreshing or the need of a hook system API, which is not flexible. Meanwhile, the blocking monitoring method in the prior art can only monitor whether the application program is blocked or not, and can not rapidly and accurately distinguish the blocking types of the application program. By setting the first preset threshold and the second preset threshold, the application can accurately distinguish the type of the stuck application program when monitoring whether the application program is stuck or not, so as to realize the comprehensive identification of the stuck application program, facilitate the subsequent targeted repair of the application program and improve the stability of the application program.
The foregoing description is only an overview of the present application, and is intended to be implemented in accordance with the teachings of the present application in order that the same may be more clearly understood and to make the same and other objects, features and advantages of the present application more readily apparent.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
fig. 1 shows a flowchart of an application operation monitoring method according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating another method for monitoring operation of an application according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an application running monitoring device according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the application to those skilled in the art.
The embodiment of the application provides an application program operation monitoring method, as shown in fig. 1, which comprises the following steps:
s101, responding to an operation request of an application program executing task, and acquiring the operation time length of the operation cycle of the main thread in the wake-up state.
The execution main body of the application program operation monitoring method provided by the embodiment of the application can be electronic equipment, and is used for monitoring applications in the electronic equipment, in particular, iOS (mobile operating system of apple company) application programs such as iOS medical service systems aiming at different service scenes in electronic equipment such as mobile phones, computers and the like. When the application program is started each time, responding to the starting operation of the application program, and monitoring the running time of the running cycle of the main thread of the application in the wake-up state.
Specifically, the main thread has a run loop (Runloop). Runloop is a core component of threads in iOS for managing the processing of messages and events of threads. The Runloop of the main thread automatically processes the unprocessed event and notifies the relevant observer each time the Runloop is opened. There are several different states of Runloop, in which the main thread starts to perform tasks in the awake state (cfrunloop afterwaiting), and in which the main thread enters the sleep state (cfrunloop before waiting). In the awake state, each loop triggers a different type of callback in which tasks are performed, such as UI (user interface) rendering, network requests, database operations, etc. If the task is executed for too long, the main thread is blocked, and user interaction or other events cannot be responded in time, so that the application program is blocked.
When a user uses an application program, the application program starts to execute a task in response to an operation request for the task to be executed, monitors the operation time length of the operation cycle of the main thread in a wake-up state in real time, and judges whether the application program is blocked or not based on the operation time length.
S102, judging whether the operation duration is greater than or equal to a first preset threshold value, if so, entering step S103, and if not, entering step S105.
In this step, when the application program executes a task, the running cycle of the main thread enters an awake state to execute the task, and after the task is completed, the state of the running cycle of the main thread changes. If the running cycle is in the wake-up state for a long time, the time consumption of the task is long, the main thread Runloop stays in the wake-up state for too long, which means that the main thread is blocked, and at the moment, the application can be determined to be blocked. In order to monitor whether the application program is stuck or not, a first preset threshold value, namely a stuck threshold value, is preset, and in the process of executing a task, the operation duration of the wake-up state of the main thread operation cycle of the task is compared with the first preset threshold value, so that whether the application program is stuck or not is judged according to a comparison result.
Alternatively, the setting range of the first preset threshold may be set to 2s to 4s, for example, 2s, 3s, 4s, etc., according to the application content of the application program, the service scenario. Monitoring the state change of the running cycle of the main thread executing the task by presetting a first preset threshold value to monitor whether the main thread is blocked or not, and further rapidly judging whether the application program is blocked or not.
S103, determining that the application program is blocked.
In the step, after the operation cycle of the main thread enters the wake-up state, the operation duration of the wake-up state is monitored, if the operation duration is greater than or equal to a first preset threshold value, the operation cycle of the main thread does not change in state, which indicates that the duration of the operation cycle in the wake-up state exceeds a jam threshold value, and at the moment, the main thread is determined to be blocked, namely the application is determined to be jammed.
S104, determining the blocking type of the blocking of the application program according to the operation time length, the first preset threshold value and the second preset threshold value.
In practical applications, in iOS systems, there is a stuck (hard stall) that causes a main thread to be forcedly killed by the system without responding for a long period of time, in addition to a normal stuck (stall). hard stall is more serious than stall because it not only affects the user experience, but also can cause application data to be lost or corrupted. Moreover, after hard stall occurs, the system does not give any signal or hint to the application, nor does it generate a report file like crash (crash). In the prior art, only whether the application program is blocked or not is monitored, but the distinction between the stall and the hard stall is difficult. However, the reason for the jam is different from that of the hard stall, and the repairing scheme is also different, and the application cannot be repaired in a targeted manner by only monitoring the jam. In order to obtain the jamming information of the application program more comprehensively and repair the application program in a targeted manner, the application provides that a second preset threshold is set, and after the main line Cheng Kadu is monitored, the second preset threshold is compared with the running time length at the moment so as to analyze the jamming type of the application program.
Optionally, the second preset threshold is used to distinguish between the types of the blocking of the application program. The setting range of the second preset threshold may be set to 10s to 12s, such as 10s, 11s, 12s, etc., according to the application content of the application program, the service scene, and the like. By presetting a second preset threshold value and monitoring the blocking time of the main thread in the task execution process, the blocking type of the application program can be rapidly analyzed, and the monitoring result of the application program is more comprehensive.
By the method, after the application jamming is determined, the jamming type is distinguished to determine that the application program is common jamming or the system is forcedly killed jamming, so that the jamming anomaly analysis of the application program is more comprehensive, and further, a provider can conduct targeted optimization and upgrading on the application program according to the jamming condition, and the running stability of the application program is improved.
S105, determining that the application program is not blocked.
In the step, when the operation duration of the operation cycle in the wake-up state is monitored to be smaller than a first preset threshold value, the duration of the wake-up state is not longer than a jam threshold value, and at the moment, the main thread is determined to be not blocked, and the application is not jammed.
In practical application, when a user invokes data by using a medical service system in a terminal, the user logs in the medical service application at an iOS terminal, after the necessary resources of an application program are waited for being loaded, the main thread operation cycle enters a wake-up state to execute a task of invoking data of a database in response to an operation request of invoking the data input by the user, at the moment, the callback is observed, if the operation cycle invokes the data of the database in the wake-up state for a period of time reaching a first preset threshold value, but the data of the database is not returned, at the moment, the fact that the execution time of the main thread is too long is determined, and the application program is indicated to be blocked. And at the moment, continuously monitoring the operation time length of the wake-up state, and judging whether the application program is ordinary or system strong killing and blocking according to the operation time length and a second preset threshold value. Further, if the operation duration of the wake-up state is within the first preset threshold, it is indicated that the main thread is not blocked, the application program is normally operated, and no blocking occurs.
According to the application program operation monitoring method provided by the embodiment of the application, by presetting a first preset threshold value for monitoring the jamming, responding to an operation request of an application program, monitoring the operation time length of the main thread when the operation cycle of the main thread is in an awake state to execute a task, and determining whether the main thread is jammed or not based on the operation time length and the first preset threshold value. And comparing the operation time length with a second preset threshold value set in advance under the condition that the application program is blocked, so as to analyze that the application program is ordinary blocked or the system is forcedly blocked. Compared with the prior art, application detection is performed by using a detection tool (such as a timer and CADisplayLink) or third-party software, and the respective technical problems are existed, such as low accuracy of the monitoring result, dependence on screen refreshing or the need of a hook system API, which is not flexible. Meanwhile, the blocking monitoring method in the prior art can only monitor whether the application program is blocked or not, and can not rapidly and accurately distinguish the blocking types of the application program. By setting the first preset threshold and the second preset threshold, the application can accurately distinguish the type of the stuck application program when monitoring whether the application program is stuck or not, so as to realize the comprehensive identification of the stuck application program, facilitate the subsequent targeted repair of the application program and improve the stability of the application program.
Further, as a refinement and extension of the foregoing embodiment, in order to fully describe a specific implementation procedure of the embodiment, an embodiment of the present application provides another method for monitoring operation of an application program, where the method includes:
s201, responding to starting operation of an application program, adding an observer to a running cycle of a main thread to monitor state change of the running cycle of the main thread.
And S202, starting a pre-established monitoring sub-thread, and monitoring whether the application program is blocked or not by using the monitoring sub-thread.
In steps S201 and S202, in response to a start-up operation of the application program, an observer (observer) is added to a run cycle (Runloop) of the main thread. Wherein the observer registers as the monitor of the observed person, when the observed person generates some change, the monitor is triggered, and the monitor is informed to inform the observer of the running state change. Further, a pre-established monitoring sub-thread is started, timing is started when the running cycle of the main thread enters the awakening state, after the monitoring sub-thread receives a state change notification sent by an observer, timing is ended, the running time of the running cycle of the main thread in the awakening state is obtained, and whether the application program is blocked or not is judged based on the running time.
In practical application, a monitoring sub-thread is created in advance, whether the main thread is blocked or not is monitored through the monitoring sub-thread, after an application program is started, an observer is added to the main thread, and meanwhile, a monitoring sub-is started to claim. When the user uses the application program, after the execution task is added to the main thread, the running cycle of the main thread enters the wake-up state to execute the task. The observer monitors a state change event of an awake state in the main thread operating cycle, and issues a notification when the observer monitors the state change event. And after the monitoring sub-thread receives the state change notification, counting the operation time length of the wake-up state, and judging whether the application program is blocked or not based on the operation time length and a first preset threshold value.
By the method, a notification observer monitors a state change event in the main thread operation cycle, sends a notification message to the created monitoring sub-thread, and monitors whether the wake-up state of the main thread operation cycle is blocked or not by the monitoring sub-thread. Compared with the monitoring method adopting the third party tool in the prior art, the method and the device realize a lightweight monitoring mode based on the Runloop technology, avoid misjudgment, improve the accuracy of the cartoon monitoring, simultaneously avoid the hook of the third party tool to the system API, reduce the influence on the performance of the application program, simultaneously, do not need to be connected with a third party plug-in, improve the accuracy of the monitoring result of the application program, simultaneously avoid the problem of privacy leakage, reduce the invasion to a program module as much as possible, and improve the safety of the application program.
S203, in response to an operation request of executing the task by the application program, adding the execution task to the main thread, so that the running cycle of the main thread enters an awake state to execute the task.
In practical applications, the iOS platform needs to be executed by the main thread due to the characteristics of UIKit itself. Thus, a developer may place some logic with uncertain thread security into the main thread. The large amount of computation, IO, drawing, etc. work contained in the unsafe logic may cause the main thread to be stuck. For an application program in the medical field, if the application program is blocked, the application program can not respond to user operations such as pressing a certain button and opening a certain interface or can not respond to the user operations in time, if the user frequently encounters the application program blocking, the application program is not used by the user, so that the application program is not used by the user any more, the stability of the operation of the application program is improved, the viscosity of the user is improved, whether the application program is blocked is monitored, the blocking phenomenon of the application program is repaired, and the stability and fluency of the operation of the application program are improved.
In order to better monitor whether the application program is stuck or not, the application provides that when the user uses the application program, an execution task is added into a main thread to execute the task in response to an operation request for the task to be executed, and the operation cycle of the main thread enters an awake state to execute the task.
S204, when the running cycle of the main thread enters the wake-up state to start executing tasks, monitoring the start timing of the sub-threads to acquire the running time of the wake-up state.
In the step, when the main thread operation cycle enters the wake-up state to execute the task, the monitoring sub-thread is controlled to start timing, and when the monitoring sub-thread receives a state change notification sent by an observer, the timing is ended, so that the operation duration of the wake-up state is acquired, and whether the application program sends a card is judged based on the operation duration.
S205, judging whether the operation duration is greater than or equal to a first preset threshold value, if so, entering step S206, and if not, entering step S214.
In this step, when the application program executes a task, the running cycle of the main thread enters an awake state to execute the task, and after the task is completed, the state of the running cycle of the main thread changes. If the running cycle is in the wake-up state for a long time, the time consumption of the task is long, the main thread Runloop stays in the wake-up state for too long, which means that the main thread is blocked, and at the moment, the application can be determined to be blocked. In order to monitor whether the application program is stuck or not, a first preset threshold value, namely a stuck threshold value, is preset, and in the process of executing a task, the operation duration of the wake-up state of the main thread operation cycle of the task is compared with the first preset threshold value, so that whether the application program is stuck or not is judged according to a comparison result.
S206, determining that the application program is blocked.
In the step, after the operation cycle of the main thread enters the wake-up state, the operation duration of the wake-up state is monitored, if the operation duration is greater than or equal to a first preset threshold value, the operation cycle of the main thread does not change in state, which indicates that the duration of the operation cycle in the wake-up state exceeds a jam threshold value, and at the moment, the main thread is determined to be blocked, namely the application is determined to be jammed.
S207, comparing the operation time length with a second preset threshold value, judging whether the operation time length is greater than or equal to the second preset threshold value, if so, entering step S208, and if not, entering step S209.
In this step, in the iOS system, there is a stuck (hard stall) that causes the main thread to be forcedly killed by the system without responding for a long period of time, in addition to the normal stuck (stall). hard stall is more serious than stall because it not only affects the user experience, but also can cause application data to be lost or corrupted. Moreover, after hard stall occurs, the system does not give any signal or hint to the application, nor does it generate a report file like crash (crash). In the prior art, only whether the application program is blocked or not is monitored, but the distinction between the stall and the hard stall is difficult. However, the reason for the jam is different from that of the hard stall, and the repairing scheme is also different, and the application cannot be repaired in a targeted manner by only monitoring the jam. In order to obtain the jamming information of the application program more comprehensively and repair the application program in a targeted manner, the application provides that a second preset threshold is set, and after the main line Cheng Kadu is monitored, the second preset threshold is compared with the running time length at the moment so as to analyze the jamming type of the application program.
S208, determining that the application program is the system strong killing and blocking.
S209, determining that the application program is ordinary cartoon.
In steps S208 and S209, when it is determined that the operation duration of the wake-up state is greater than or equal to the second preset threshold, it is determined that the main thread is blocked for too long, and the main thread Cheng Kadu is relatively serious, and at this time, it is determined that the application program is a system strong killing katon. Further, when the operation duration of the wake-up state is determined to be less than the second preset threshold, it is indicated that the main thread operation cycle has a state change within the second preset threshold, that is, the main thread is blocked for a short time although a blocking phenomenon occurs during the task execution, and at this time, it is determined that the application program is a common blocking.
By the method, after the application jamming is determined, the jamming type is distinguished to determine that the application program is common jamming or the system is forcedly killed jamming, so that the jamming anomaly analysis of the application program is more comprehensive, and further, a provider can conduct targeted optimization and upgrading on the application program according to the jamming condition, and the running stability of the application program is improved.
S210, acquiring a blocking time stamp of the blocking of the application program.
S211, acquiring the clamping and positioning information of the main thread.
S212, generating the jamming abnormal prompt information according to the jamming timestamp, the jamming positioning information and the jamming type.
S213, the katon abnormity prompt information is sent to the server.
In steps S210 to S213, the stuck positioning information refers to task information executed by the main thread when a stuck occurs. After determining that the application program is blocked, in the main thread call stack, stack information corresponding to the blocked application program is found, and if the information of 'inquiry record of the last month' is searched, the event is determined to be the main cause of the blocked main thread. Further, when the application program is determined to be blocked, a blocking time stamp, blocking positioning information and a blocking type of the blocking are obtained, and blocking abnormal prompt information of the application program is generated. And uploading the blocking abnormality prompt information to a server, so that a developer analyzes the cause of blocking of the application program through the content of the blocking abnormality prompt information received by the server, and a blocking repair scheme of the application program is formulated.
Optionally, when the running cycle of the main thread enters the wake-up state, acquiring a call stack of the main thread is started, when the application program is determined to be blocked, acquiring the call stack of the main thread is stopped, and the call stack is stored in a local database to obtain the call stack in the blocking time period, wherein the call stack contains blocking positioning information. According to the call stack as the monitoring data of the blocking, the blocking caused by the blocking of the main thread is monitored, and meanwhile, excessive resources occupied by the monitoring are avoided, and the influence of the monitoring on the application performance is reduced.
By the method, the application program cartoon anomaly information is collected, the cartoon anomaly information is uploaded to the server, the server receives comprehensive and accurate anomaly information, and then a provider can pertinently optimize the application program according to the received anomaly information, so that the running stability and safety of the application program are effectively improved, and the user experience is further improved.
In the embodiment of the application, in order to more accurately analyze that an application program is a common card or a system strong card, the application provides that the analysis of the cold start operation of the application program specifically comprises: responding to the cold start operation of the application program, and acquiring a first time stamp corresponding to the cold start operation; obtaining a blocking duration and a second time stamp of target blocking of the application program, wherein the target blocking is the last blocking of the application program before cold start operation; and determining the jamming type of the target jamming according to the jamming duration, the first time stamp and the second time stamp.
In practical application, cold start is a restarting mode of an application program, when the application program takes longer to execute tasks, the main thread is blocked seriously, and if the main thread exceeds a fixed duration, for example, if the main thread exceeds 10s, the main thread is killed by the system, and at the moment, the application program executes cold start operation. However, cold start of an application may also include a variety of other reasons, such as an upgrade of the application, insufficient background memory, insufficient foreground memory, and so on. In addition, when the application program is blocked, part of users do not wait for the application program to automatically perform system forced killing, but manually kill the application program in advance, namely manually restart the application. Such a jam, which causes the user to interrupt the current task, may also be considered a system-intensive jam. Therefore, the application analyzes the cold start operation of the application program to realize the accurate determination of the stuck type of the application program.
Specifically, a first timestamp of the cold start operation is obtained in response to the cold start operation of the application program, wherein the first timestamp is the start time of the cold start operation. Thereafter, a click duration and a second timestamp of the target click of the application program are obtained. It should be noted that, the target jamming is the last jamming of the application program recorded in the local database before the cold start operation. And (3) calling the blocking duration of the target blocking in the local database, namely the operation duration of the wake-up state corresponding to the target blocking, and the second time stamp of the target blocking. And further determining the jamming type of the target jamming based on the jamming duration, the first timestamp and the second timestamp, and further determining whether the cold start of the application program is caused by the strong jamming of the system.
In the embodiment of the present application, optionally, the step of determining the stuck type of the target stuck according to the stuck duration, the first timestamp and the second timestamp specifically includes: judging whether the length of the blocking time of the target blocking is larger than or equal to a second preset threshold value; if yes, determining that the target stuck is a system strong killing stuck; if not, calculating the time interval between the first time stamp and the second time stamp; if the time interval is smaller than or equal to a third preset threshold value, determining that the target stuck is a system strong killing stuck; if the time interval is greater than a third preset threshold, determining that the target jamming is common jamming.
In this embodiment, the stuck duration of the target stuck is compared with a second preset threshold to determine whether the target stuck is a system-forced stuck. Specifically, if the stuck time length of the target stuck is greater than or equal to a second preset threshold, determining that the target stuck is a system strong killing stuck. Further, if the stuck duration of the target stuck is smaller than the second preset threshold, it is determined that the target stuck does not reach the system forced killing threshold, and the application program performs cold start operation. It should be noted that, the application cold start may be performed manually in advance for the user, and the type of the click cannot be determined according to the duration of the click. Therefore, if the duration of the target stuck is less than the second preset threshold, calculating a time interval between the second time stamp of the target stuck and the first time stamp of the cold start at this time, and comparing the time interval with a third preset threshold, if the time interval is less than or equal to the third preset threshold, determining that the interval between the target stuck and the cold start is shorter, and determining that the cold start is caused by the target stuck at this time, then determining that the target stuck is the system forced killing stuck. Further, if the time interval is greater than the third preset threshold, the interval between the target jamming and the application cold start is determined to be longer, at this time, it can be determined that the cold start is caused by other reasons, and the target jamming is determined to be the common jamming.
Alternatively, the range of the third preset threshold may be set to 25 seconds to 30 seconds.
By the method, the cold start reason of the application program is analyzed based on the jamming duration, the first time stamp and the second time stamp of the target jamming, and then the jamming type of the target jamming is determined. So as to realize the accurate determination of the application program stuck type. And the provider can pertinently optimize the application program according to the received abnormal information, so that the running stability and safety of the application program are effectively improved, and the use experience of a user is further improved.
S214, determining that the application program is not blocked.
In the step, when the operation duration of the operation cycle in the wake-up state is monitored to be smaller than a first preset threshold value, the duration of the wake-up state is not longer than a jam threshold value, and at the moment, the main thread is determined to be not blocked, and the application is not jammed.
Further, as a specific implementation of the method shown in fig. 1, an embodiment of the present application provides an application running monitoring apparatus 300, as shown in fig. 3, including:
an obtaining module 301, configured to obtain an operation duration of an operation cycle of a main thread in a wake state in response to an operation request of an application program to execute a task;
A judging module 302, configured to judge whether the operation duration is greater than or equal to a first preset threshold;
a first determining module 303, configured to determine that the application program is stuck if the running time is greater than or equal to a first preset threshold;
a second determining module 304, configured to determine a stuck type of the stuck of the application according to the operation duration, the first preset threshold, and the second preset threshold;
a third determining module 305 is configured to determine that the application program does not get stuck if the running duration is less than the first preset threshold.
Optionally, the acquiring module 301 is specifically configured to:
responding to an operation request of an application program for executing tasks, adding the execution tasks to a main thread, and enabling the running cycle of the main thread to enter an awake state to execute the tasks;
when the running cycle of the main thread enters the awakening state to start executing tasks, the monitoring sub-thread starts timing so as to acquire the running time of the awakening state.
Optionally, the second determining module 304 is specifically configured to:
comparing the operation time length with a second preset threshold value;
if the running time length is greater than or equal to a second preset threshold value, determining that the application program is a system strong killing katon;
if the running time is greater than or equal to the first preset threshold and is smaller than the second preset threshold, determining that the application program is ordinary cartoon.
Optionally, the obtaining module 301 is further configured to:
obtaining a blocking time stamp of blocking of an application program;
and acquiring the clamping and positioning information of the main thread.
Optionally, the apparatus further comprises:
the generating module 306 is configured to generate a stuck abnormal prompt message according to the stuck time stamp, the stuck positioning information and the stuck type;
and the sending module 307 is configured to send the katon anomaly prompt message to the server.
Optionally, the apparatus further comprises:
an adding module 308, configured to add an operation cycle from an observer to the main thread in response to a start operation of the application program, so as to monitor a state change of the operation cycle of the main thread;
the starting module 309 is configured to start a pre-created monitoring sub-thread, and monitor whether the application program is stuck by using the monitoring sub-thread.
Optionally, the obtaining module 301 is further configured to:
responding to the cold start operation of the application program, and acquiring a first time stamp corresponding to the cold start operation;
and acquiring the blocking duration and the second time stamp of the target blocking of the application program, wherein the target blocking is the last blocking of the application program before the cold start operation.
Optionally, the apparatus further comprises:
a fourth determining module 310, configured to determine a stuck type of the target stuck according to the stuck duration, the first timestamp and the second timestamp.
Optionally, the determining module 302 is further configured to determine whether the duration of the pause of the target pause is greater than or equal to a second preset threshold.
Optionally, the apparatus further comprises:
a fifth determining module 311, configured to determine that the target stuck is a system strong killing stuck if the stuck time length of the target stuck is greater than or equal to a second preset threshold;
a calculating module 312, configured to calculate a time interval between the first timestamp and the second timestamp if the stuck duration of the target stuck is less than a second preset threshold;
a sixth determining module 313, configured to determine that the target stuck is a system forced killing stuck if the time interval is less than or equal to a third preset threshold;
a seventh determining module 314 is configured to determine that the target click is a normal click if the time interval is greater than the third preset threshold.
According to the application program operation monitoring device 300 provided by the embodiment of the application, by presetting a first preset threshold value for monitoring the jamming, responding to an operation request of an application program, monitoring the operation time length of the main thread in a wake-up state to execute a task, and determining whether the main thread is jammed or not based on the operation time length and the first preset threshold value. And comparing the operation time length with a second preset threshold value set in advance under the condition that the application program is blocked, so as to analyze that the application program is ordinary blocked or the system is forcedly blocked. Compared with the prior art, application detection is performed by using a detection tool (such as a timer and CADisplayLink) or third-party software, and the respective technical problems are existed, such as low accuracy of the monitoring result, dependence on screen refreshing or the need of a hook system API, which is not flexible. Meanwhile, the blocking monitoring method in the prior art can only monitor whether the application program is blocked or not, and can not rapidly and accurately distinguish the blocking types of the application program. By setting the first preset threshold and the second preset threshold, the application can accurately distinguish the type of the stuck application program when monitoring whether the application program is stuck or not, so as to realize the comprehensive identification of the stuck application program, facilitate the subsequent targeted repair of the application program and improve the stability of the application program.
In an exemplary embodiment, the application also provides an electronic device including a memory and a processor. The memory stores a computer program and a processor for executing the program stored in the memory, and executing the application program operation monitoring method in the above embodiment.
In an exemplary embodiment, the application also provides a readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the application operation monitoring method.
From the above description of the embodiments, it will be clear to those skilled in the art that the present application may be implemented in hardware, or may be implemented by means of software plus necessary general hardware platforms. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.), and includes several instructions for causing an electronic device (may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective implementation scenario of the present application.
Those skilled in the art will appreciate that the drawing is merely a schematic illustration of a preferred implementation scenario and that the modules or flows in the drawing are not necessarily required to practice the application.
Those skilled in the art will appreciate that modules in an apparatus in an implementation scenario may be distributed in an apparatus in an implementation scenario according to an implementation scenario description, or that corresponding changes may be located in one or more apparatuses different from the implementation scenario. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The above-mentioned inventive sequence numbers are merely for description and do not represent advantages or disadvantages of the implementation scenario.
The foregoing disclosure is merely illustrative of some embodiments of the application, and the application is not limited thereto, as modifications may be made by those skilled in the art without departing from the scope of the application.
Claims (10)
1. An application operation monitoring method, comprising:
responding to an operation request of an application program executing task, and acquiring the operation time length of the operation cycle of the main thread in the wake-up state;
judging whether the operation time length is greater than or equal to a first preset threshold value;
if the running time is greater than or equal to the first preset threshold, determining that the application program is blocked;
determining a blocking type of blocking of the application program according to the operation time length, the first preset threshold and the second preset threshold;
And if the operation duration is smaller than the first preset threshold value, determining that the application program is not blocked.
2. The method according to claim 1, wherein the step of obtaining the operation duration of the operation cycle of the main thread in the wake state in response to the operation request of the application program to execute the task specifically comprises:
in response to the operation request of the application program to execute a task, adding the execution task to the main thread, so that the running cycle of the main thread enters an awake state to execute a task;
when the running cycle of the main thread enters the awakening state to start executing tasks, monitoring the starting timing of the sub-threads to acquire the running time length of the awakening state.
3. The method according to claim 1, wherein the step of determining the stuck type of the stuck of the application according to the operation duration, the first preset threshold and the second preset threshold specifically includes:
comparing the operation time length with the second preset threshold value;
if the running time is greater than or equal to the second preset threshold, determining that the application program is a system strong killing katon;
And if the running time is greater than or equal to the first preset threshold and is smaller than the second preset threshold, determining that the application program is ordinary cartoon.
4. The method of claim 1, wherein the determining that the application program is stuck further comprises:
obtaining a blocking time stamp of the blocking of the application program;
acquiring the clamping and positioning information of the main thread;
generating a jamming abnormal prompt message according to the jamming time stamp, the jamming positioning information and the jamming type;
and sending the blocking abnormal prompt information to a server.
5. The method as recited in claim 1, further comprising:
in response to a start-up operation of an application, adding an observer to a run cycle of a main thread to monitor a state change of the run cycle of the main thread;
and starting a pre-established monitoring sub-thread, and monitoring whether the application program is blocked or not by using the monitoring sub-thread.
6. The method according to any one of claims 1 to 5, further comprising:
responding to a cold start operation of an application program, and acquiring a first time stamp corresponding to the cold start operation;
Obtaining a blocking duration and a second time stamp of target blocking of the application program, wherein the target blocking is the last blocking of the application program before cold start operation;
and determining the jamming type of the target jamming according to the jamming duration, the first time stamp and the second time stamp.
7. The method according to claim 6, wherein the step of determining the type of the target click according to the click duration, the first timestamp and the second timestamp specifically comprises:
judging whether the length of the blocking time of the target blocking is larger than or equal to a second preset threshold value;
if the length of the blocking time of the target blocking is greater than or equal to the second preset threshold, determining that the target blocking is a system forced killing blocking;
if the stuck time length of the target stuck is smaller than the second preset threshold value, calculating a time interval between the first time stamp and the second time stamp;
if the time interval is smaller than or equal to a third preset threshold value, determining that the target stuck is a system forced killing stuck;
and if the time interval is larger than the third preset threshold value, determining that the target jamming is common jamming.
8. An application operation monitoring device, comprising:
the acquisition module is used for responding to an operation request of executing a task by an application program and acquiring the operation time length of the operation cycle of the main thread in the wake-up state;
the judging module is used for judging whether the running time is greater than or equal to a first preset threshold value;
the first determining module is used for determining that the application program is blocked if the running time is greater than or equal to the first preset threshold value;
the second determining module is used for determining the blocking type of blocking of the application program according to the running time length, the first preset threshold value and the second preset threshold value;
and the third determining module is used for determining that the application program is not blocked if the running time length is smaller than the first preset threshold value.
9. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310815147.5A CN116860552A (en) | 2023-07-04 | 2023-07-04 | Application program operation monitoring method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310815147.5A CN116860552A (en) | 2023-07-04 | 2023-07-04 | Application program operation monitoring method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116860552A true CN116860552A (en) | 2023-10-10 |
Family
ID=88235304
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310815147.5A Pending CN116860552A (en) | 2023-07-04 | 2023-07-04 | Application program operation monitoring method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116860552A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118093348A (en) * | 2024-04-07 | 2024-05-28 | 荣耀终端有限公司 | Critical thread identification method and thread optimization method during application starting |
-
2023
- 2023-07-04 CN CN202310815147.5A patent/CN116860552A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118093348A (en) * | 2024-04-07 | 2024-05-28 | 荣耀终端有限公司 | Critical thread identification method and thread optimization method during application starting |
CN118093348B (en) * | 2024-04-07 | 2024-09-13 | 荣耀终端有限公司 | Critical thread identification method and thread optimization method during application starting |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10838838B2 (en) | Method and apparatus for dealing with abnormality of application program and storage medium | |
CN106681811B (en) | Multithreading scheduling method and device based on thread pool | |
US8516499B2 (en) | Assistance in performing action responsive to detected event | |
CN113835985B (en) | Method, device and equipment for monitoring and analyzing jamming reason | |
CN111949368A (en) | Application program control method and device | |
US8341637B2 (en) | Utilization management | |
CN116860552A (en) | Application program operation monitoring method and device, electronic equipment and storage medium | |
CN110908864B (en) | Equipment jamming processing method, device, equipment and medium | |
WO2019140739A1 (en) | Method for determining return visits to client, and electronic apparatus and computer-readable storage medium | |
CN111625425A (en) | Data monitoring method, device and system | |
CN106326065B (en) | Terminal use duration management method and device | |
CN110597694A (en) | Method and terminal for monitoring front-end page | |
CN108509322B (en) | Method for avoiding excessive return visit, electronic device and computer readable storage medium | |
CN114996103A (en) | Page abnormity detection method and device, electronic equipment and storage medium | |
CN111124761B (en) | Equipment restarting method, device, equipment and medium | |
CN110674149B (en) | Service data processing method and device, computer equipment and storage medium | |
CN111783081A (en) | Malicious process processing method, terminal device and storage medium | |
CN116991559A (en) | Method and device for exiting uninterrupted sleep state process | |
CN110225113B (en) | Service monitoring method and system | |
CN109491771B (en) | Task processing method based on system performance optimization and related equipment | |
CN108121582B (en) | Message processing method, mobile terminal and device with storage function | |
CN110532160B (en) | Method for BMC to record server system hot restart event | |
CN113220379B (en) | Task processing method and device, electronic equipment and readable storage medium | |
CN115509781A (en) | Method and device for processing page rendering control abnormity in android system | |
CN114385457A (en) | Application program data acquisition method, device, 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 |