CN109960659B - Method and device for detecting application program - Google Patents

Method and device for detecting application program Download PDF

Info

Publication number
CN109960659B
CN109960659B CN201910248655.3A CN201910248655A CN109960659B CN 109960659 B CN109960659 B CN 109960659B CN 201910248655 A CN201910248655 A CN 201910248655A CN 109960659 B CN109960659 B CN 109960659B
Authority
CN
China
Prior art keywords
value
preset
main thread
message
name
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.)
Active
Application number
CN201910248655.3A
Other languages
Chinese (zh)
Other versions
CN109960659A (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.)
Apollo Zhilian Beijing Technology Co Ltd
Original Assignee
Apollo Zhilian Beijing 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 Apollo Zhilian Beijing Technology Co Ltd filed Critical Apollo Zhilian Beijing Technology Co Ltd
Priority to CN201910248655.3A priority Critical patent/CN109960659B/en
Publication of CN109960659A publication Critical patent/CN109960659A/en
Application granted granted Critical
Publication of CN109960659B publication Critical patent/CN109960659B/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/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a method and a device for detecting an application program. One embodiment of the method comprises: performing a blockage detection step: recording the name and the value of a preset identifier, and sending a message with the name of the preset identifier to the main thread, wherein the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes after a preset time interval; if not, determining that the main thread is blocked. The embodiment can detect the ANR and is beneficial to positioning and analyzing the ANR problem.

Description

Method and device for detecting application program
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for detecting an application program.
Background
ANR, application Not Responding, is also referred to as Application unresponsiveness.
For example, in the Android system, some events need to be completed within a certain time period, and if a predetermined time period is exceeded and a valid response is not obtained or the response time is too long, ANR may be caused. If the main thread is blocked for more than a preset time period due to some time-consuming operations, the system displays an ANR dialog box to prompt the user that the corresponding application is in a non-response state.
When ANR occurs, the system stores the process stack information of the application in a local file (e.g., "/data/ANR/" a trace. Txt file under the directory). In general, developers cannot acquire process stack information in which ANR appears in real time, so that some ANRs cannot be restored and repaired.
Disclosure of Invention
The embodiment of the application provides a method and a device for detecting an application program.
In a first aspect, an embodiment of the present application provides a method for detecting an application, where the method includes: performing a blockage detection step: recording the name and the value of a preset identifier, and sending a message with the name of the preset identifier to the main thread, wherein the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes after a preset time interval; if not, determining that the main thread is blocked.
In some embodiments, the method further comprises: and if the value of the preset identifier is not changed, acquiring stack information of the main thread, and uploading the stack information to the server.
In some embodiments, the method further comprises: if the value of the preset identifier has changed, the blocking detection step is executed again.
In some embodiments, sending a message with a name of a preset identification to the main thread comprises: and calling a message passing object created in the main thread to send the message with the name of the preset identification, wherein the message passing object is used for pushing the sent message into a message queue of the main thread.
In some embodiments, the main thread is configured to: changing the value of the preset identifier in response to a message having the name of the preset identifier being taken out of the message queue of the main thread.
In some embodiments, the determining whether the value of the preset flag changes after a preset time interval includes: sleeping for a preset time; it is determined whether the value of the preset flag is changed.
In a second aspect, an embodiment of the present application provides an apparatus for detecting an application, where the apparatus includes a congestion detection unit. Wherein the congestion detection unit is configured to perform the congestion detection step: recording the name and the value of a preset identifier, and sending a message with the name of the preset identifier to the main thread, wherein the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes after a preset time interval; if not, determining that the main thread is blocked.
In some embodiments, the apparatus further comprises: and the reporting unit is configured to acquire the stack information of the main thread and upload the stack information to the server if the value of the preset identifier is not changed.
In some embodiments, the apparatus further comprises: and a re-execution unit configured to re-execute the blocking detection step if the value of the preset identifier has changed.
In some embodiments, sending a message with a name of a preset identification to the main thread comprises: and calling a message passing object created in the main thread to send the message with the name of the preset identification, wherein the message passing object is used for pushing the sent message into a message queue of the main thread.
In some embodiments, the main thread is configured to: changing the value of the preset identifier in response to a message having the name of the preset identifier being taken out of the message queue of the main thread.
In some embodiments, the determining whether the value of the preset flag changes after a preset time interval includes: sleeping for a preset time; it is determined whether a value of the preset flag is changed.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when executed by one or more processors, cause the one or more processors to implement a method as described in any implementation of the first aspect.
In a fourth aspect, the present application provides a computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the method and the device for detecting the application program, provided by the embodiment of the application program, the name and the value of the preset identifier are recorded, a message with the name of the preset identifier is sent to the main thread, whether the value of the preset identifier changes or not is determined at intervals of the preset duration, and the main thread is determined to be blocked when the value of the preset identifier changes, so that the ANR can be detected, and the positioning and analysis of the ANR problem are facilitated.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram to which one embodiment of the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for detecting an application according to the present application;
FIG. 3 is a timing diagram of one application scenario of a method for detecting an application program according to the present application;
FIG. 4 is a schematic block diagram illustrating one embodiment of an apparatus for detecting an application in accordance with the present application;
fig. 5 is a schematic structural diagram of an electronic device suitable for implementing embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which embodiments of the method for detecting an application or the apparatus for detecting an application of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 101, 102, 103 to interact with a server 105 over a network 104 to receive or send messages or the like. Various communication client Applications (APP) such as a web browser Application, a shopping Application, a search Application, an instant messaging tool, a mailbox client, social platform software, and the like may be installed on the terminal devices 101, 102, and 103.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices capable of running applications, including but not limited to smart phones, tablet computers, personal Digital Assistants (PDAs), and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for applications running on the terminal devices 101, 102, 103. The background server may receive the thread stack information reported by the terminal devices 101, 102, and 103, so that developers may locate and analyze ANR problems.
It should be noted that the method for detecting the application provided in the embodiment of the present application is generally executed by the terminal devices 101, 102, 103, and accordingly, the apparatus for detecting the application is generally disposed in the terminal devices 101, 102, 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for detecting an application in accordance with the present application is shown. The method for detecting an application may include the steps of:
step 201, recording the name and value of the preset identifier, and sending a message with the name of the preset identifier to the main thread.
In this embodiment, an execution subject on which the method for detecting an application runs (e.g., a child thread started in a main thread of an application running in the terminal device 101, 102, 103 of fig. 1) may first record a name and a value of a preset identification and then send a message with the name of the preset identification to the main thread. For example, the sub-thread acquires/creates a message, then sets some attribute of the message to the name of the preset identifier, and then sends the message to the main thread. Wherein the value of the preset identifier can be modified by the main thread. Here, the preset identifier may be an object created by a main thread or a sub-thread, and a value of the preset identifier may be a default value or a value set by a user. The execution agent (e.g., child thread) may be created and opened by the primary thread while the application is running.
In some optional implementation manners of this embodiment, step 201 may specifically include: calling a message passing object created in the main thread to send a message with a name of a preset identification. Wherein the messaging object may be used to push messages into the message queue of the main thread. Taking the android system as an example, the messaging object may be a Handler instance (i.e., a Handler instance). Here, each Handler instance may be associated with a thread (the thread that created the Handler instance, e.g., the main thread) and the message queue of that thread, and other threads (e.g., child threads) may send/process messages through the Handler instance.
In some optional implementations of this embodiment, the main thread may be configured to: and in response to the message with the name of the preset identifier being taken out of the message queue of the main thread, changing the value of the preset identifier, namely changing the value of the preset identifier to a value different from the value recorded by the sub-thread. For example, when a message with the name of the preset identifier is taken out from the message queue of the main thread, the main thread modifies the value of the preset identifier from 0 to 1.
Although it is described in the above implementation that the execution subject (i.e., the child thread) calls the message passing object created in the main thread to send a message, the present application is not limited thereto. Those skilled in the art will appreciate that other suitable means for sending messages between the child thread and the main thread may also be employed.
Step 202, obtaining a value of a preset identifier after a preset time interval.
In this embodiment, the execution subject may obtain the value of the preset flag after a preset time interval. Here, the preset duration may refer to a time interval from the transmission of the message to the acquisition of the value of the preset flag. The preset time period may be a value preset according to the system-defined ANR timeout time, for example, 6s, 8s, and the like.
In some optional implementations of this embodiment, step 202 may specifically include: the execution main body firstly sleeps for a preset duration after step 201, and acquires the value of the preset identifier after the sleep. In the android system, the child thread may sleep for 8s after step 201, and then obtain the value of the preset identifier.
Step 203, determining whether the value of the preset flag changes.
In this embodiment, the executing entity may compare the value obtained in step 202 with the value recorded in step 201 to determine whether the value of the preset flag has changed.
And step 204, if the value of the preset identifier is not changed, determining that the main thread is blocked.
In this embodiment, if step 203 determines that the value of the preset flag is not changed, that is, the value obtained in step 202 is the same as the value recorded in step 201 (that is, the message sent in step 201 is not processed), the execution main body may determine that the main thread is blocked (that is, the application does not respond).
In some optional implementation manners of this embodiment, if it is determined in step 203 that the value of the preset identifier has changed, that is, the value obtained in step 202 is different from the value recorded in step 201 (that is, the message sent in step 201 has been processed), the execution main body may determine that the main thread is not blocked, and thus may return to step 201 to execute again.
In some optional implementations of this embodiment, the method for detecting an application may further include: after determining that the main thread is blocked, the execution body may acquire stack information of the main thread, and then upload the acquired stack information to a server, so that a developer may locate and analyze the ANR. Taking the android system as an example, the StackTrace (also called a stack trace) stores call information of a main thread in a form of a stack, and therefore, the stack information of the main thread can be obtained by obtaining a StackTraceElement of the main thread (the StackTraceElement is a method object representing the StackTrace, and call procedure information in the call stack, including a class name, a method name, a file name, a line number of a call, and the like, can be obtained through the object).
In the implementation manner, a developer can obtain the main thread blockage detected by the application end in real time, so that ANR can be positioned and analyzed.
With continued reference to fig. 3, fig. 3 is a timing sequence 300 of one application scenario of the method for detecting an application program according to the present embodiment. In the application scenario of fig. 3, when the application program runs, the main thread first starts a monitoring thread for monitoring ANR (see step 301). Thereafter, the monitoring thread records the name and value of the preset identification (see step 302), and sends a message with the name of the preset identification to the main thread (see step 303), and then sleeps for 8s (see step 304). Wherein the message is pushed into the message queue of the main thread. The main thread takes the message from the message queue and modifies the value of the preset identification to a value different from the value recorded by the monitoring thread (see step 305). Subsequently, after the monitoring thread finishes sleeping, it determines that the value of the preset identifier is different from the value recorded by the monitoring thread (see step 306), it may determine that the main thread is not currently blocked, record the value of the preset identifier again and send a message with the name of the preset identifier to the main thread (see steps 307 and 308), and sleep again for 8s (see step 309). During this time, no message is fetched and the value of the preset identification is modified, since the main thread is always processing the last call. Therefore, the monitoring thread determines that the value of the preset flag is the same as the recorded value after the sleep is finished (see step 310), and at this time, it may be determined that the main thread has been blocked, and simultaneously stack information of the main thread is acquired (see step 311). Finally, the monitoring thread reports the acquired stack information to the server (see step 312).
In the method for detecting an application program according to the embodiment of the present application, by recording the name and the value of the preset identifier, and sending a message with the name of the preset identifier to the main thread, determining whether the value of the preset identifier changes at a preset time interval, and determining that the main thread is blocked when the value of the preset identifier changes, the ANR can be detected, which is beneficial to positioning and analyzing an ANR problem.
With further reference to fig. 4, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an apparatus for detecting an application, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied in a terminal device.
As shown in fig. 4, the apparatus 400 for detecting an application of the present embodiment may include a congestion detection unit 401. Wherein the congestion detection unit 401 may be configured to perform the congestion detection step: recording the name and the value of a preset identifier, and sending a message with the name of the preset identifier to the main thread, wherein the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes after a preset time interval; if not, determining that the main thread is blocked.
In this embodiment, the step of detecting congestion may specifically include the following steps:
the first step, recording the name and value of the preset identification, and sending a message with the name of the preset identification to the main thread. For example, the sub-thread acquires/creates a message, then sets some attribute of the message to the name of the preset identifier, and then sends the message to the main thread. Wherein the value of the preset identifier can be modified by the main thread. Here, the preset flag may be an object created by the main thread or the sub-thread, and a value of the preset flag may be a default value or a value set by a user. The child thread may be created and opened by the main thread while the application is running.
Optionally, the first step may specifically include: and calling a message passing object created in the main thread to send the message with the name of the preset identification, wherein the message passing object is used for pushing the sent message into a message queue of the main thread.
Optionally, the main thread may be configured to: changing the value of the preset identifier in response to a message having the name of the preset identifier being taken out of the message queue of the main thread.
And secondly, acquiring a value of a preset identifier after a preset time interval. Here, the preset duration may refer to a time interval from the transmission of the message to the acquisition of the value of the preset flag. The preset time period may be a value preset according to the system-defined ANR timeout time, for example, 6s, 8s, and the like.
Optionally, the second step may specifically include: sleeping for a preset time; and acquiring the value of the preset identifier.
And thirdly, comparing the obtained value with the recorded value to determine whether the value of the preset identifier is changed.
Fourth, if the value of the preset flag is not changed, that is, the obtained value is the same as the recorded value (that is, the sent message is not processed), it may be determined that the main thread is blocked (that is, the application is not responding).
In some optional implementations of this embodiment, the apparatus 400 for detecting an application may further include a reporting unit. Wherein the reporting unit may be configured to: and if the value of the preset identifier is not changed, acquiring stack information of the main thread, and uploading the stack information to the server.
In some optional implementations of this embodiment, the apparatus 400 for detecting an application program may further include a re-execution unit 402. Wherein the re-execution unit 402 may be configured to: if the value of the preset identifier has changed, the blocking detection step is executed again.
The apparatus for detecting an application program according to the foregoing embodiment of the present application, by recording a name and a value of a preset identifier, and sending a message with the name of the preset identifier to a main thread, and then determining whether the value of the preset identifier changes at a preset interval, and determining that the main thread is blocked when the value of the preset identifier changes, the apparatus can detect ANR, and is helpful for positioning and analyzing ANR problems.
Referring now to FIG. 5, a schematic diagram of an electronic device (e.g., electronic devices 101, 102, 103 of FIG. 1) 500 suitable for use in implementing embodiments of the present application is shown. The electronic device 500 shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 5, electronic device 500 may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the computer system 500 are also stored. The processing device 501, the ROM 502, and the RAM503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following devices may be connected to the I/O interface 505 in general: input devices 506 including, for example, a touch screen, keys, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, etc.; and a communication device 508. The communication means 508 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device 500 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be alternatively implemented or provided. Each block shown in fig. 5 may represent one device or may represent multiple devices as desired.
In particular, the processes described above with reference to the flow diagrams may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 508, or installed from the ROM 502. The computer program, when executed by the processing device 501, performs the above-described functions defined in the methods of embodiments of the present disclosure. It should be noted that the computer readable medium in the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the apparatus; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: performing a blockage detection step: recording the name and the value of a preset identifier, and sending a message with the name of the preset identifier to the main thread, wherein the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes after a preset time interval; if not, determining that the main thread is blocked.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a congestion detection unit. Where the names of these units do not in some cases constitute a limitation of the unit itself, for example, the congestion detection unit may also be described as a "unit performing a congestion detection step".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept as defined above. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.

Claims (8)

1. A method for detecting an application, the method comprising:
performing a blockage detection step: acquiring or creating a message by a sub-thread, setting a preset attribute of the message as a name of a preset identifier, recording the name and the value of the preset identifier, and sending the message with the name of the preset identifier to a main thread, wherein the sub-thread is created and started by the main thread when an application program runs, and the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes or not after a preset time interval; if not, determining that the main thread is blocked;
the main thread is configured to: in response to determining that a message having the name of the preset identification is pulled from the message queue of the main thread, changing the value of the preset identification to a value different from the value of the sub-thread record;
wherein the method further comprises:
and if the value of the preset identifier is changed, determining that the main thread is not blocked, and executing the blocking detection step again.
2. The method of claim 1, wherein the method further comprises:
and if the value of the preset identifier is not changed, acquiring stack information of the main thread, and uploading the stack information to a server.
3. The method of claim 1, wherein the sending a message with the name of the preset identification to a main thread comprises:
and calling a message passing object created in the main thread to send the message with the name of the preset identification, wherein the message passing object is used for pushing the sent message into a message queue of the main thread.
4. The method according to one of claims 1 to 3, wherein the determining whether the value of the preset flag changes after the interval of a preset duration comprises:
sleeping for a preset time;
determining whether a value of the preset flag changes.
5. An apparatus for detecting an application, the apparatus comprising:
a congestion detection unit configured to perform a congestion detection step: acquiring or creating a message by a sub-thread, setting a preset attribute of the message as a name of a preset identifier, recording the name and the value of the preset identifier, and sending the message with the name of the preset identifier to a main thread, wherein the sub-thread is created and started by the main thread when an application program runs, and the value of the preset identifier can be modified by the main thread; determining whether the value of the preset identifier changes or not after a preset time interval; if not, determining that the main thread is blocked;
the main thread is configured to: in response to determining that a message having the name of the preset identification is pulled from the message queue of the main thread, changing the value of the preset identification to a value different from the value of the sub-thread record;
wherein the apparatus further comprises:
a re-execution unit configured to re-execute the block detection step if the value of the preset identifier has changed and the main thread is determined not to be blocked.
6. The apparatus of claim 5, wherein the apparatus further comprises:
and the reporting unit is configured to acquire the stack information of the main thread and upload the stack information to a server if the value of the preset identifier is not changed.
7. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
8. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201910248655.3A 2019-03-29 2019-03-29 Method and device for detecting application program Active CN109960659B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910248655.3A CN109960659B (en) 2019-03-29 2019-03-29 Method and device for detecting application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910248655.3A CN109960659B (en) 2019-03-29 2019-03-29 Method and device for detecting application program

Publications (2)

Publication Number Publication Date
CN109960659A CN109960659A (en) 2019-07-02
CN109960659B true CN109960659B (en) 2022-11-01

Family

ID=67025214

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910248655.3A Active CN109960659B (en) 2019-03-29 2019-03-29 Method and device for detecting application program

Country Status (1)

Country Link
CN (1) CN109960659B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113742177A (en) * 2021-09-10 2021-12-03 掌阅科技股份有限公司 Application performance monitoring method, electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
CN109445957A (en) * 2018-09-26 2019-03-08 迪瑞医疗科技股份有限公司 A kind of synchronization and asynchronous communication control method, system and device

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8504520B2 (en) * 2010-06-11 2013-08-06 Microsoft Corporation Background synchronization of data objects
CN106610881B (en) * 2015-10-22 2019-05-07 阿里巴巴集团控股有限公司 The extracting method and device of function stack when extraction procedure occurs without response
US20170153962A1 (en) * 2015-11-30 2017-06-01 International Business Machines Corporation Monitoring the performance of threaded applications
CN106371809B (en) * 2016-08-31 2019-03-01 北京奇虎科技有限公司 Thread processor and thread processing method
CN108021496B (en) * 2016-10-28 2020-09-04 腾讯科技(深圳)有限公司 Thread data processing method and device
CN106776253B (en) * 2016-12-08 2020-08-04 武汉斗鱼网络科技有限公司 Interface card pause monitoring method and device
CN107590015A (en) * 2017-09-11 2018-01-16 北京京东尚科信息技术有限公司 The method and apparatus for monitoring the obstruction of main thread
CN108512695B (en) * 2018-03-12 2021-06-01 腾讯音乐娱乐科技(深圳)有限公司 Method and device for monitoring application blockage
CN109446094B (en) * 2018-11-05 2022-05-17 网易(杭州)网络有限公司 Stuck detection method and device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
CN109445957A (en) * 2018-09-26 2019-03-08 迪瑞医疗科技股份有限公司 A kind of synchronization and asynchronous communication control method, system and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"Dynamic thread mapping of shared memory applications by exploiting cache coherence protocols";Eduardo H.M.Cruz等;《Journal of Parallel and Distributed Computing》;20131206;第74卷(第03期);第2215-2228页 *
Matthew Curland等." 用VB创建高效的多线程应用程序".《程序员》.2003,(第03期),第99-101页. *

Also Published As

Publication number Publication date
CN109960659A (en) 2019-07-02

Similar Documents

Publication Publication Date Title
KR20200022329A (en) Method and device for determining response time
CN109684188B (en) Test method and device
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN110619096B (en) Method and apparatus for synchronizing data
CN112817831A (en) Application performance monitoring method, device, computer system and readable storage medium
CN112954056B (en) Method and device for processing monitoring data, electronic equipment and storage medium
CN108959102B (en) Method and device for generating test data and testing application to be tested
CN111813685B (en) Automatic test method and device
CN109960659B (en) Method and device for detecting application program
CN109218338B (en) Information processing system, method and device
CN110443034B (en) Risk program file identification method and device, computing equipment and medium
CN111367783B (en) Application program testing method and device and electronic equipment
CN112306826A (en) Method and apparatus for processing information for terminal
CN111324470A (en) Method and device for generating information
WO2022188576A1 (en) Performance issue locating method and apparatus, and electronic device and storage medium
CN111382058A (en) Service testing method and device, server and storage medium
CN110084298B (en) Method and device for detecting image similarity
CN111290873B (en) Fault processing method and device
CN110750424B (en) Resource inspection method and device
CN113568695A (en) Corner mark processing method and device for boarder application
CN111538577A (en) Program execution control device and method, terminal and storage medium
CN112084114A (en) Method and apparatus for testing an interface
CN111767486A (en) Method, device, electronic equipment and computer readable medium for displaying page
CN113704079A (en) Interface testing method and device based on Protobuf
CN111382057A (en) Test case generation method, test method and device, server 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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20211012

Address after: 100176 101, floor 1, building 1, yard 7, Ruihe West 2nd Road, Beijing Economic and Technological Development Zone, Daxing District, Beijing

Applicant after: Apollo Zhilian (Beijing) Technology Co.,Ltd.

Address before: Unit D, Unit 3, 301, Productivity Building No. 5, High-tech Secondary Road, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: BAIDU INTERNATIONAL TECHNOLOGY (SHENZHEN) Co.,Ltd.

GR01 Patent grant
GR01 Patent grant