Method and device for detecting jamming

The method and device address the issue of main thread locking jams by recording access and release times to detect freezes and gather relevant information, facilitating developer analysis and optimization.

CN111752719BActive Publication Date: 2024-12-20TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010598543.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-28
Publication Date
2024-12-20
Estimated Expiration
2040-06-28

AI Technical Summary

Technical Problem

Existing systems fail to timely detect and analyze jamming caused by main thread locking in applications, leading to user experience issues and application freezes.

Method used

A method and device that record the access and release times of data containers by sub-threads to determine the waiting time of main threads, identifying freezes based on a threshold, and gather jamming information including call stacks and application details for analysis.

Benefits of technology

Enables timely detection and analysis of main thread locking jams, reducing performance loss and improving user experience by providing developers with necessary information to optimize applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111752719B_ABST
    Figure CN111752719B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for detecting jamming, which belongs to the field of computer technology. The method includes: when the main thread accesses a locked data container, recording the access time, wherein the data container is locked by a first child thread. When the first child thread releases the lock of the data container, recording the lock release time. The first child thread determines the waiting time of the main thread based on the access time and the lock release time. If the waiting time is greater than the jamming time threshold, it is determined that there is jamming, and jamming information is obtained, and the jamming information includes the call stack of the first child thread, the call stack of the main thread, and the waiting time. By using the present application, jamming caused by locking can be discovered, and information related to jamming can be obtained for developers to analyze, so as to solve the jamming problem in a timely manner.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method and device for detecting freeze. Background Art

[0002] A thread is the smallest unit in an operating system that can perform computational scheduling. An operating system can execute multiple threads simultaneously. During the life cycle of an application, multiple threads will be executed simultaneously. Among them, threads can be divided into main threads and sub-threads. The main thread is the thread that handles user interaction events in the application. If the main thread has events such as waiting and execution time is too long, it will directly cause the application to freeze, affecting the user experience. Sub-threads refer to threads other than the main thread.

[0003] During application operation, in order to ensure the security and consistency of data reading and writing in multi-threaded scenarios, the data container will be locked. When a thread locks a data container, before the thread releases the lock, other threads accessing this data container will pause execution and wait for the lock to be released. If the thread waiting for the lock to be released is the main thread, it will cause application lag and affect the user experience.

[0004] Therefore, how to detect the jamming caused by locking the main thread in a timely manner and obtain information related to the jamming for developers to analyze in order to solve the jamming problem in a timely manner is a problem worth studying. Summary of the invention

[0005] The embodiment of the present application provides a method and device for detecting jamming, which can solve the technical problems existing in the related art. The technical solution of the method and device for detecting jamming is as follows:

[0006] In a first aspect, a method for detecting jamming is provided, the method comprising:

[0007] When the main thread accesses a locked data container, recording the access time, wherein the data container is locked by the first child thread;

[0008] When the first sub-thread releases the lock of the data container, recording the lock release time;

[0009] Determining, by the first sub-thread based on the access time and the lock release time, the waiting time of the main thread;

[0010] If the waiting time is greater than the freeze time threshold, it is determined that freeze exists, and freeze information is obtained, where the freeze information includes a call stack of the first sub-thread, a call stack of the main thread, and the waiting time.

[0011] In a possible implementation, obtaining the jam information includes:

[0012] Obtaining a call stack of the first sub-thread through the first sub-thread;

[0013] Return to the main thread, and obtain the call stack of the main thread through the main thread.

[0014] In a possible implementation, obtaining the jam information includes:

[0015] Start the second sub-thread;

[0016] The call stack of the first sub-thread and the call stack of the main thread are obtained through the second sub-thread.

[0017] In a possible implementation, the jam information further includes data container information, and obtaining the jam information further includes:

[0018] Based on the call stack of the first sub-thread and the call stack of the main thread, data container information is determined, wherein the data container information includes an identifier of the data container and logic information for the first sub-thread to read and write the data container.

[0019] In a possible implementation, the freeze information also includes the access time and / or application related information, and the application related information includes at least the name information and version information of the application where the freeze occurs.

[0020] In a possible implementation, the application-related information also includes a user account logged in by the application that is experiencing freeze.

[0021] In a possible implementation, after acquiring the jam information, the method further includes:

[0022] The jam information is output to an integrated development environment (IDE).

[0023] In a possible implementation, after acquiring the jam information, the method further includes:

[0024] The jam information is reported to the jam detection background corresponding to the application where the jam occurs.

[0025] In a second aspect, a device for detecting freeze is provided, the device comprising:

[0026] A recording module, configured to record an access time when the main thread accesses a locked data container, wherein the data container is locked by the first child thread;

[0027] The recording module is further configured to record a lock release time when the first sub-thread releases the lock of the data container;

[0028] A determination module, configured to determine the waiting time of the main thread based on the access time and the lock release time by the first sub-thread;

[0029] An acquisition module is used to determine that a freeze exists if the waiting time is greater than a freeze time threshold, and to obtain freeze information, wherein the freeze information includes a call stack of the first sub-thread, a call stack of the main thread, and the waiting time.

[0030] In a possible implementation, the acquisition module is used to:

[0031] Obtaining a call stack of the first sub-thread through the first sub-thread;

[0032] Return to the main thread, and obtain the call stack of the main thread through the main thread.

[0033] In a possible implementation, the acquisition module is used to:

[0034] Start the second sub-thread;

[0035] The call stack of the first sub-thread and the call stack of the main thread are obtained through the second sub-thread.

[0036] In a possible implementation manner, the jam information also includes the data container, and the acquisition module is further used to:

[0037] Based on the call stack of the first sub-thread and the call stack of the main thread, data container information is determined, wherein the data container information includes an identifier of the data container and logic information for the first sub-thread to read and write the data container.

[0038] In a possible implementation, the freeze information also includes the access time and / or application related information, and the application related information includes at least the name information and version information of the application where the freeze occurs.

[0039] In a possible implementation, the application-related information also includes a user account logged in by the application that is experiencing freeze.

[0040] In a possible implementation, the device further includes an output module, which is used to:

[0041] The jam information is output to the IDE.

[0042] In a possible implementation manner, the device further includes a reporting module, configured to:

[0043] The jam information is reported to the jam detection background corresponding to the application where the jam occurs.

[0044] In a third aspect, a terminal is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for detecting jamming as described in the first aspect.

[0045] In a fourth aspect, a computer-readable storage medium is provided, wherein at least one instruction is stored in the computer-readable storage medium, and the at least one instruction is loaded and executed by a processor to implement the method for detecting jamming as described in the first aspect.

[0046] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:

[0047] An embodiment of the present application provides a method for detecting jamming, by recording the access time when the main thread accesses a locked data container. When the first child thread releases the data container, the lock release time is recorded. The first child thread determines the waiting time based on the lock release time and the access time. The waiting time is compared with the jamming time threshold to determine whether there is a jam. When it is determined that there is a jam, jam information including the call stack of the main thread, the call stack of the first child thread, and the waiting time is obtained. Thus, the jamming caused by the locking of the main thread can be detected in time, and the jamming information can be obtained for developers to analyze, so as to solve the jamming problem in time. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0049] Figure 1 is a flow chart of a method for detecting jamming provided by an embodiment of the present application;

[0050] Figure 2 It is a structural schematic diagram of a device for detecting jamming provided in an embodiment of the present application;

[0051] Figure 3 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application;

[0052] Figure 4 is a schematic diagram of displaying jamming information provided by an embodiment of the present application;

[0053] Figure 5This is a flowchart for detecting jamming provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0055] The embodiment of the present application provides a method for detecting freeze, which can be implemented by a terminal. The terminal can be a mobile terminal such as a mobile phone, a tablet computer, a notebook, or a fixed terminal such as a desktop computer.

[0056] The method for detecting jamming provided by the embodiment of the present application can be used to detect jamming caused by locking of the application on the terminal, and when jamming is detected, jamming information including the call stack of the first sub-thread, the call stack of the main thread and the waiting time is obtained in time. Thus, the developer can analyze the cause of jamming through the jamming information, so as to optimize the application in time, thereby reducing the probability of application jamming and improving the user experience. The method for detecting jamming provided by the embodiment of the present application can be applied in a development environment (i.e., the application runs on the test terminal). In this case, after the test terminal obtains the jamming information, the jamming information can be output to the integrated development environment (IDE), wherein the IDE is an application for providing an application development environment, generally including tools such as a code editor, a compiler, a debugger and a graphical user interface. The method for detecting jamming provided by the embodiment of the present application can also be applied in an external network environment (i.e., the user uses the application normally). In this case, after the terminal obtains the jamming information, the jamming information can be reported to the jamming detection background corresponding to the application that has jammed, so that the developer can obtain the jamming information through the jamming detection platform.

[0057] In addition, the method for detecting freeze provided in the embodiment of the present application can be applied in the iOS (iPhone Operation System) system, and can also be applied in the Android system or other systems, and the present application does not limit this.

[0058] like Figure 1 As shown, the processing flow of the method for detecting jamming provided in the embodiment of the present application may include the following steps:

[0059] In step 101, when the main thread accesses the locked data container, the access time is recorded.

[0060] The data container is locked by the first child thread.

[0061] In implementation, during the life cycle of an application (or application program), multiple threads will execute simultaneously. For the main thread, various data containers will be accessed during the execution of the main thread. If the data container accessed by the main thread is not locked, the main thread locks the data container and executes the corresponding logic normally. If the main thread accesses a locked data container, the main thread needs to wait for the lock of the data container to be released before it can execute normally. During this waiting process, if the waiting time is too long, the user may perceive that the application is stuck.

[0062] The method provided in the embodiment of the present application can determine whether a freeze occurs by the waiting time of the main thread. Therefore, in order to facilitate the determination of the waiting time of the main thread, the access time can be recorded when the main thread accesses the locked data container. In one possible implementation, when recording the access time, it can be the main thread that records the access time. Thus, for the application, there is no need to start a new child thread to record the access time, which can reduce performance loss. In another possible implementation, a new child thread can also be started to record the access time, which is not limited in this application.

[0063] In step 102, when the first child thread releases the lock of the data container, the lock release time is recorded.

[0064] In implementation, after the first sub-thread locks the data container, it executes the corresponding logic normally. When the first sub-thread completes execution, it releases the lock of the data container, and the main thread immediately acquires the lock of the data container and executes. It can be seen that the waiting time of the main thread is the time between the access time of the main thread accessing the data container and the release time of the first sub-thread releasing the lock of the data container.

[0065] Therefore, in order to facilitate the determination of the waiting time of the main thread, the release time of the lock of the data container can be recorded. In a possible implementation, when recording the lock release time, the first child thread can record the lock release time, so that the application does not need to start a new child thread to record the lock release time, which can reduce performance loss. In another possible implementation, a new child thread can also be started to record the lock release time, and the child thread can be the same child thread as the child thread that records the access time.

[0066] In step 103, the waiting time of the main thread is determined by the first sub-thread based on the access time and the lock release time.

[0067] In implementation, the waiting time of the main thread can be obtained by subtracting the access time from the lock release time. Then, whether there is a jam can be determined based on the waiting time.

[0068] For example, the waiting time can be compared with the jamming time threshold. If the waiting time is greater than the jamming time threshold, it means that the waiting time is too long and the user will feel the jamming, and it is determined that the application is jamming. At this time, the waiting time can be called the jamming time. If the waiting time is less than the jamming time threshold, it means that the waiting time is short and the user may not perceive the waiting time, so it can be determined that the application is not jamming. In addition, for the case where the waiting time is equal to the jamming time threshold, it can be considered that there is jamming or there is no jamming, and this application does not limit this.

[0069] It should be noted that the freeze duration threshold can be set by the developer based on experience. For example, the freeze duration threshold can be set to 16ms. In addition, different freeze duration thresholds can be set for different categories of applications.

[0070] By determining whether there is a jam through the existing first sub-thread, the application does not need to start a new sub-thread, which can reduce the performance loss of the application. Of course, in another possible implementation, a new sub-thread can also be started to determine whether there is a jam, and the new sub-thread can be the same sub-thread as the sub-thread for recording the access time and the lock release time.

[0071] In step 104, if the waiting time is greater than the freeze time threshold, it is determined that freeze exists, and freeze information is obtained, where the freeze information includes the call stack of the first sub-thread, the call stack of the main thread, and the waiting time.

[0072] The call stack refers to the record information of the execution method and logic of a thread. Through the call stack of a thread, the logic executed by the thread and the corresponding code can be analyzed. The call stack can also be called a stack.

[0073] In addition, the freeze information may also include data container information, access time and application related information. The application related information may include the name information and version information of the application where the freeze occurs and the user account logged in by the application where the freeze occurs.

[0074] In implementation, after determining that there is a jam, jam information may be obtained, which includes a call stack of the first sub-thread, a call stack of the main thread, and a waiting time.

[0075] The main thread's call stack can be used to analyze which data container the main thread is waiting for a lock on, and which child thread it is waiting for. The first child thread's call stack can be used to analyze the logic of reading and writing data containers executed by the corresponding child thread during the lock period. Therefore, developers can determine the cause of the freeze based on the main thread's call stack and the first child thread's call stack, and solve the freeze problem of the application.

[0076] It should be noted that there are at least two ways to obtain the call stack of the first child thread and the call stack of the main thread. The two ways are described below respectively:

[0077] In a possible implementation, in order to reduce the performance loss of the application, the corresponding processing process of step 104 can be as follows: obtain the call stack of the first sub-thread through the first sub-thread. Return to the main thread, and obtain the call stack of the main thread through the main thread.

[0078] In implementation, after the first sub-thread determines that there is a lag, the call stack of the first sub-thread can be obtained immediately. After the acquisition is completed, the application returns to execute the main thread, and the main thread obtains the call stack of the main thread. The application obtains its own call stack through the existing first sub-thread and main thread, and there is no additional performance loss.

[0079] In another possible implementation, in order to more accurately obtain the call stack, the corresponding processing process of step 104 can be described as follows: start the second sub-thread, and obtain the call stack of the first sub-thread and the call stack of the main thread through the second sub-thread.

[0080] In implementation, the acquired call stack is more accurate by starting the second sub-thread to acquire the call stack of the main thread and the call stack of the first sub-thread. The second sub-thread may be the sub-thread for recording access time, lock release time and determining whether there is a jam.

[0081] In addition, by including the jamming duration in the jamming information, developers can clearly understand the jamming duration of the main thread caused by locking, so that they can handle it accordingly.

[0082] In a possible implementation, the jam information may also include data container information, and the corresponding processing process of step 104 may be as follows: based on the call stack of the first sub-thread and the call stack of the main thread, the data container information is determined.

[0083] The data container information includes a data container identifier and logic information for the first sub-thread to read and write the data container.

[0084] In implementation, the identifier of the data container can be analyzed through the main thread call stack, and the logic information of the first sub-thread reading and writing the data container can be analyzed through the first sub-thread call stack. By determining the data container information, the cause of the application freeze is clearer.

[0085] It should be noted that the jam information may not include the data container information, but is obtained by the developer himself based on the call stack of the main thread and the call stack of the first sub-thread. This application does not limit this.

[0086] In addition, after obtaining the jam information, it is also necessary to send the jam information to the developer so that the developer can solve the jam problem based on the jam information.

[0087] In a possible implementation, during the testing phase, the application may be run on a test terminal, and the terminal running the application may output freeze information to an IDE.

[0088] Among them, in the IDE environment, the jamming information may also include the access time and application related information, and the application related information may at least include the name information and version information of the application where the jamming occurs. Optionally, the application related information may also include the user account logged in by the application where the jamming occurs. The access time may also be referred to as the jamming occurrence time, that is, the time when the jamming begins to occur.

[0089] In another possible implementation, after the application is launched, if the user terminal obtains the jamming information, the user terminal can report the jamming information to the jamming detection background corresponding to the application where the jamming occurs, and the developer can obtain the jamming information through the jamming detection platform. This situation can also be called an external network environment.

[0090] Among them, in the extranet environment, the freeze information can also include the access time and application related information, and the application related information can include the name information and version information of the application where the freeze occurs, and the user account logged in by the application where the freeze occurs. The access time can also be called the freeze occurrence time.

[0091] In implementation, Figure 4 As shown, it is a schematic diagram of a jam information reported to the jam detection platform provided by an embodiment of the present application. The jam information includes the main thread call stack, the first sub-thread call stack, the jam duration and the data container information. In addition, it also includes the reporting date, the user account (that is, the user account logged in by the application where the jam occurs) and the version (the version may include the name and version number of the application) and other information. Among them, in one possible implementation, the reporting date can be determined by the terminal according to the access time obtained, or the reporting date can also be determined by the jam detection background based on the access time in the received jam information. Exemplarily, the access time is 10:01:17.195820 seconds on October 21, 2019, and the reporting date can be October 21, 2019. In another possible implementation, the reporting date can also be determined by the jam detection background according to the reception time of the jam information.

[0092] An embodiment of the present application provides a method for detecting jamming, by recording the access time when the main thread accesses a locked data container. When the first child thread releases the data container, the lock release time is recorded. The first child thread determines the waiting time based on the lock release time and the access time. The waiting time is compared with the jamming time threshold to determine whether there is a jam. When it is determined that there is a jam, jam information including the call stack of the main thread, the call stack of the first child thread, and the waiting time is obtained. Thus, the jamming caused by the locking of the main thread can be detected in time, and the jamming information can be obtained for developers to analyze, so as to solve the jamming problem in time.

[0093] like Figure 5 As shown, it is a flow chart of a method for detecting jamming provided by an embodiment of the present application:

[0094] In step 501, during the application process, in order to ensure the read and write security and consistency of the data container, the first sub-thread locks the data container when reading and writing the data container.

[0095] In step 502, the main thread accesses the locked data container. At this time, the main thread waits for the lock to be released and records the access time t1.

[0096] In step 503, after the first sub-thread logic is executed, the lock is released, and the lock release time t2 is recorded, and the interval between t2 and t1 is determined.

[0097] In step 504, it is determined whether t2-t1 is greater than a freeze duration threshold (for example, the freeze duration threshold is 16 ms).

[0098] In step 505, if the time is greater than the freeze duration threshold, it is determined that freeze occurs. The call stack and freeze duration of the first sub-thread are recorded by the first sub-thread, and then the main thread is called back.

[0099] In step 506, after returning to the main thread, the call stack of the main thread is recorded.

[0100] In step 507, in a development environment, the jam information is output to the IDE; in an external network environment, it is reported to the jam detection platform.

[0101] It should be noted that if t2-t1 is less than the freeze duration threshold, it is determined that no freeze exists, and the subsequent process of obtaining freeze information is not performed.

[0102] By adopting this solution, developers can discover certain main thread locking and jamming scenarios during the development stage, and analyze and optimize them. At the same time, in an external network environment, main thread locking and jamming scenarios that are usually difficult to find can also be captured and reported for analysis. By obtaining the call stack of the first sub-thread through the first sub-thread, and obtaining the call stack of the main thread through the main thread, this application has no additional performance loss and will not affect normal development work and user experience. Through this solution, developers can eventually locate the cause of the main thread locking and jamming, thereby reducing the probability of application jamming, improving user experience, and improving product reputation.

[0103] Based on the same technical concept, the embodiment of the present application also provides a device for detecting freeze, which may be a terminal, such as Figure 2 As shown, the device comprises:

[0104] A recording module 201, configured to record the access time when the main thread accesses the locked data container, wherein the data container is locked by the first child thread;

[0105] The recording module 201 is further configured to record the lock release time when the first sub-thread releases the lock of the data container;

[0106] A determination module 202, configured to determine the waiting time of the main thread based on the access time and the lock release time by the first sub-thread;

[0107] The acquisition module 203 is used to determine that there is a freeze if the waiting time is greater than the freeze time threshold, and to obtain freeze information, where the freeze information includes the call stack of the first sub-thread, the call stack of the main thread, and the waiting time.

[0108] In a possible implementation, the acquisition module 203 is used to:

[0109] Obtain a call stack of the first child thread through the first child thread;

[0110] Return to the main thread and obtain the call stack of the main thread through the main thread.

[0111] In a possible implementation, the acquisition module 203 is used to:

[0112] Start the second sub-thread;

[0113] The call stack of the first sub-thread and the call stack of the main thread are obtained through the second sub-thread.

[0114] In a possible implementation, the jam information also includes a data container, and the acquisition module 203 is further used to:

[0115] Based on the call stack of the first sub-thread and the call stack of the main thread, data container information is determined, wherein the data container information includes an identifier of the data container and logic information for the first sub-thread to read and write the data container.

[0116] In a possible implementation, the freeze information also includes access time and / or application related information, and the application related information includes at least the name information and version information of the application where the freeze occurs.

[0117] In a possible implementation, the freeze information also includes a user account, where the user account is a user account logged in by the application where the freeze occurs.

[0118] In a possible implementation, the device further includes an output module, which is used to:

[0119] Output the jamming information to the integrated development environment IDE.

[0120] In a possible implementation, the device further includes a reporting module, configured to:

[0121] Report the jamming information to the jamming detection background corresponding to the application where the jamming occurs.

[0122] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0123] It should be noted that: the device for detecting jamming provided in the above embodiment only uses the division of the above functional modules as an example when detecting jamming. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device for detecting jamming provided in the above embodiment and the method embodiment for detecting jamming belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0124] Figure 3 300 is a block diagram of a terminal provided in an embodiment of the present application. The terminal 300 may be a portable mobile terminal, such as a smart phone or a tablet computer. The terminal 300 may also be called a user equipment, a portable terminal, or other names.

[0125] Typically, the terminal 300 includes a processor 301 and a memory 302 .

[0126] The processor 301 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 301 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 301 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 301 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 301 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0127] The memory 302 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 302 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 302 is used to store at least one instruction, which is used to be executed by the processor 301 to implement the method for detecting jamming provided in the present application.

[0128] In some embodiments, the terminal 300 may further include: a peripheral device interface 303 and at least one peripheral device. Specifically, the peripheral device includes: at least one of a radio frequency circuit 304 , a display screen 305 , a camera component 306 , an audio circuit 307 , a positioning component 308 and a power supply 309 .

[0129] The peripheral device interface 303 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 301 and the memory 302. In some embodiments, the processor 301, the memory 302, and the peripheral device interface 303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 301, the memory 302, and the peripheral device interface 303 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.

[0130] The radio frequency circuit 304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 304 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 304 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 304 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 304 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 304 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.

[0131] The display screen 305 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. The display screen 305 also has the ability to collect touch signals on the surface or above the surface of the display screen 305. The touch signal may be input to the processor 301 as a control signal for processing. The display screen 305 is used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 305 may be one, and the front panel of the terminal 300 is set; in other embodiments, the display screen 305 may be at least two, which are respectively set on different surfaces of the terminal 300 or are folded; in still other embodiments, the display screen 305 may be a flexible display screen, which is set on the curved surface or folded surface of the terminal 300. Even, the display screen 305 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 305 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).

[0132] The camera assembly 306 is used to capture images or videos. Optionally, the camera assembly 306 includes a front camera and a rear camera. Typically, the front camera is used to realize video calls or selfies, and the rear camera is used to realize the shooting of photos or videos. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, and a wide-angle camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, and the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting functions. In some embodiments, the camera assembly 306 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0133] The audio circuit 307 is used to provide an audio interface between the user and the terminal 300. The audio circuit 307 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 301 for processing, or input them into the radio frequency circuit 304 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 300. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 301 or the radio frequency circuit 304 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 307 may also include a headphone jack.

[0134] The positioning component 308 is used to locate the current geographical location of the terminal 300 to implement navigation or LBS (Location Based Service). The positioning component 308 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system or Russia's Galileo system.

[0135] The power supply 309 is used to power various components in the terminal 300. The power supply 309 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 309 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0136] In some embodiments, the terminal 300 further includes one or more sensors 310 , including but not limited to: an acceleration sensor 311 , a gyroscope sensor 312 , a pressure sensor 313 , a fingerprint sensor 314 , an optical sensor 315 , and a proximity sensor 316 .

[0137] The acceleration sensor 311 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 300. For example, the acceleration sensor 311 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 301 can control the display screen 305 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 311. The acceleration sensor 311 can also be used to collect game or user motion data.

[0138] The gyro sensor 312 can detect the body direction and rotation angle of the terminal 300, and the gyro sensor 312 can cooperate with the acceleration sensor 311 to collect the user's 3D actions on the terminal 300. The processor 301 can implement the following functions based on the data collected by the gyro sensor 312: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0139] The pressure sensor 313 can be set in the side frame of the terminal 300 and / or the lower layer of the display screen 305. When the pressure sensor 313 is set in the side frame of the terminal 300, it can detect the user's holding signal of the terminal 300, and perform left and right hand recognition or shortcut operation according to the holding signal. When the pressure sensor 313 is set in the lower layer of the display screen 305, it can control the operability control on the UI interface according to the user's pressure operation on the display screen 305. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0140] The fingerprint sensor 314 is used to collect the user's fingerprint to identify the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 301 authorizes the user to perform relevant sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 314 can be set on the front, back, or side of the terminal 300. When a physical button or a manufacturer logo is set on the terminal 300, the fingerprint sensor 314 can be integrated with the physical button or the manufacturer logo.

[0141] The optical sensor 315 is used to collect the ambient light intensity. In one embodiment, the processor 301 can control the display brightness of the display screen 305 according to the ambient light intensity collected by the optical sensor 315. Specifically, when the ambient light intensity is high, the display brightness of the display screen 305 is increased; when the ambient light intensity is low, the display brightness of the display screen 305 is reduced. In another embodiment, the processor 301 can also dynamically adjust the shooting parameters of the camera assembly 306 according to the ambient light intensity collected by the optical sensor 315.

[0142] The proximity sensor 316, also called a distance sensor, is usually arranged on the front of the terminal 300. The proximity sensor 316 is used to collect the distance between the user and the front of the terminal 300. In one embodiment, when the proximity sensor 316 detects that the distance between the user and the front of the terminal 300 is gradually decreasing, the processor 301 controls the display screen 305 to switch from the screen-on state to the screen-off state; when the proximity sensor 316 detects that the distance between the user and the front of the terminal 300 is gradually increasing, the processor 301 controls the display screen 305 to switch from the screen-off state to the screen-on state.

[0143] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation on the terminal 300, and the terminal 300 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0144] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement the method for detecting jamming in the above embodiment. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0145] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0146] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for detecting jamming, characterized in that: The method comprises: When the main thread accesses a locked data container, the access time is recorded, wherein the data container is locked by the first sub-thread, the access time is obtained by the second sub-thread, the main thread refers to a thread that processes user interaction events in the application, and the first sub-thread and the second sub-thread are threads other than the main thread; When the first sub-thread releases the lock of the data container, recording the lock release time, wherein the lock release time is obtained by the second sub-thread; Determining, by the first sub-thread based on the access time and the lock release time, the waiting time of the main thread; If the waiting time is greater than the freeze time threshold, it is determined that there is a freeze, and the freeze information is obtained, the freeze information including the call stack of the first sub-thread, the call stack of the main thread and the waiting time, wherein the call stack refers to the record information of the thread execution method and logic, the call stack of the first sub-thread and the call stack of the main thread are obtained through the second sub-thread, different types of applications are set with different freeze time thresholds, the call stack of the main thread is used to analyze and determine the locked data container, and the call stack of the first sub-thread is used to analyze the logic of reading and writing data containers executed by the first sub-thread during the locking period.

2. The method according to claim 1, characterized in that The jam information also includes data container information, and obtaining the jam information also includes: Based on the call stack of the first sub-thread and the call stack of the main thread, data container information is determined, wherein the data container information includes an identifier of the data container and logic information for the first sub-thread to read and write the data container.

3. The method according to claim 2, characterized in that The freeze information also includes the access time and / or application related information, and the application related information at least includes the name information and version information of the application where the freeze occurs.

4. The method according to claim 3, characterized in that: The application-related information also includes the user account logged in by the application that has been stuck.

5. The method according to any one of claims 1 to 4, characterized in that: After obtaining the jam information, the method further includes: The jam information is output to an integrated development environment IDE.

6. The method according to any one of claims 1 to 4, characterized in that: After obtaining the jam information, the method further includes: The jam information is reported to the jam detection background corresponding to the application where the jam occurs.

7. A device for detecting jamming, characterized in that: The device comprises: a recording module, configured to record an access time when a main thread accesses a locked data container, wherein the data container is locked by a first sub-thread, the access time is obtained by a second sub-thread, the main thread refers to a thread for processing user interaction events in an application, and the first sub-thread and the second sub-thread are threads other than the main thread; The recording module is further configured to record a lock release time when the first sub-thread releases the lock of the data container, wherein the lock release time is obtained by the second sub-thread; A determination module, configured to determine the waiting time of the main thread based on the access time and the lock release time by the first sub-thread; An acquisition module is used to determine that a freeze exists if the waiting time is greater than a freeze time threshold, and to obtain freeze information, wherein the freeze information includes a call stack of the first sub-thread, a call stack of the main thread, and the waiting time, wherein the call stack refers to record information of thread execution methods and logics, the call stack of the first sub-thread and the call stack of the main thread are obtained through the second sub-thread, different types of applications are set with different freeze time thresholds, the call stack of the main thread is used to analyze and determine the locked data container, and the call stack of the first sub-thread is used to analyze the logic of reading and writing data containers executed by the first sub-thread during the locking period.

8. A terminal, characterized in that: The terminal includes a memory and a processor, the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for detecting jamming as described in any one of claims 1-6.