Method for client to detect page rendering lag
Through aspect-oriented programming, AOP interception processing and timestamp comparison methods, the existing technology problems of incomplete detection of page rendering freezes and high development costs are solved, and the location of page rendering freezes can be quickly located and optimized, thereby improving user experience. experience.
Patent Information
- Application Number
- CN202410706590.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology has problems such as incompleteness, excessive logs, and high development costs when detecting page rendering freezes. It cannot effectively and uniformly monitor the rendering timing of the page, resulting in a decline in user experience.
The system's unified rendering method onDraw is intercepted through aspect-oriented programming AOP, timestamps are recorded before and after page rendering, timestamp differences are compared to determine lags, and stack information is used to locate lag locations for analysis and modification.
It enables the timely discovery and quick location of the specific location of page rendering freezes during the development and debugging process, optimizes rendering efficiency, and reduces development costs.
Smart Images

Figure CN118606584A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a method for detecting page rendering freeze on a client. Background Art
[0002] When the client is being developed, due to complex business or tight project cycles, it is easy to write complex control hierarchies during the development process, or write in an irregular manner, resulting in low rendering efficiency, causing the system to freeze when rendering the interface, resulting in an unsmooth program page and a reduced user experience.
[0003] At present, the methods used in the development process are mostly for users to record too many logs in specific pages to monitor whether the current page has timed out, so as to determine whether the page has been stuck, without unified monitoring of the rendering timing of the page.
[0004] This approach has obvious drawbacks:
[0005] 1). Incomplete. The page that records logs in the application can determine whether a freeze has occurred, but other pages that do not record logs cannot detect freeze problems.
[0006] 2). Too many logs: As business functions accumulate, the number of pages will increase day by day, which will cause the logs to become larger and larger, and the code will be bloated and unclear.
[0007] 3). High development cost: Every newly developed page needs to be tested, which will lead to a waste of development time due to logs.
[0008] Based on the above situation, the present invention proposes a method for a client to detect page rendering freeze. Summary of the invention
[0009] In order to overcome the defects of the prior art, the present invention provides a simple and efficient method for detecting page rendering freeze on a client.
[0010] The present invention is achieved through the following technical solutions:
[0011] A method for detecting page rendering jams on a client, characterized in that it comprises the following steps:
[0012] Step S1, the client intercepts the system's unified rendering method onDraw;
[0013] Step S2: Write logs before and after page rendering and record timestamps; compare the timestamp difference before and after page rendering to determine whether a freeze occurs during page rendering;
[0014] Step S3, process the jamming situation, input the stack information, analyze the location where the program jams, and make modifications.
[0015] In the step S1, the client uses aspect-oriented programming AOP to intercept the unified rendering method onDraw of the system.
[0016] In the step S2, a switch flag is configured to record a current time T1 before the intercepted unified renderer onDraw() is executed, and then record a current time T2 after the execution. If the difference between time T2 and T1 is greater than 1s, it is considered that a freeze has occurred.
[0017] In step S3, when a page freeze is detected, the Looper.getMainLooper().getThread().getStackTrace() method is used to obtain the current stack information, and the stack information of the client process at this time is output, and then the program code position where the freeze occurs is accurately located according to the information in the stack for analysis and modification.
[0018] A system for detecting page rendering jams on a client, characterized by comprising a unified interception module, a jam detection module and a jam processing module;
[0019] The unified interception module is used to intercept the unified rendering method onDraw of the system on the client;
[0020] The jam detection module is responsible for writing logs before and after page rendering, recording timestamps, and determining whether jams occur during page rendering by comparing the timestamp difference before and after page rendering;
[0021] The jam processing module is responsible for processing jam situations, inputting stack information, analyzing the location where the program sends the jam, and making modifications.
[0022] The unified interception module uses aspect-oriented programming AOP to intercept the unified rendering method onDraw of the system.
[0023] The jam detection module is configured with a switch flag, which records a current time T1 before the intercepted unified renderer onDraw() is executed, and then records a current time T2 after the execution. If the difference between time T2 and T1 is greater than 1s, it is considered that a jam has occurred.
[0024] When a page freeze is detected, the freeze processing module uses the Looper.getMainLooper().getThread().getStackTrace() method to obtain the current stack information, output the stack information of the client process at this time, and then accurately locate the program code position where the freeze occurs based on the information in the stack, and perform analysis and modification.
[0025] A device for detecting page rendering jams on a client, characterized in that it includes a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the above-mentioned method steps when executing the computer program.
[0026] A readable storage medium, characterized in that: a computer program is stored on the readable storage medium, and the computer program implements the above method steps when executed by a processor.
[0027] The beneficial effect of the present invention is that the method for detecting page rendering freezes by the client can not only timely discover freezes during the development and debugging process, but also quickly locate the specific page and program location where the freeze occurs for optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0029] Attached Figure 1 A schematic diagram of a method for detecting page rendering freeze on a client side of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] When the page is displayed on the mobile phone, the program resources are rendered to the mobile phone screen. During this process, the system program will send a signal every 16.6ms (that is, 60 frames are refreshed per second, the limit of human eye resolution). If this signal is not received for a period of time, it is considered that a freeze has occurred in the rendering process.
[0032] When rendering a page, the Android system will uniformly go to the rendering and drawing method encapsulated at the bottom layer of the system. This method is implemented at the bottom layer of the system, and the client has no right to modify its specific implementation. The client can monitor the rendering process by intercepting this method in its own program.
[0033] The method for detecting page rendering jams on a client includes the following steps:
[0034] Step S1, the client intercepts the system's unified rendering method onDraw;
[0035] Step S2: Write logs before and after page rendering and record timestamps; compare the timestamp difference before and after page rendering to determine whether a freeze occurs during page rendering;
[0036] Step S3, process the jamming situation, input the stack information, analyze the location where the program jams, and make modifications.
[0037] In the step S1, the client uses aspect-oriented programming AOP to intercept the unified rendering method onDraw of the system.
[0038] The unified rendering method of the Android system for pages is the onDraw() method of View. All pages are drawn through this method. Using AOP (aspect-oriented programming) technology, this method is uniformly intercepted and processed to ensure that all pages can be executed.
[0039] In step S2, a switch flag is configured to record a current time T1 before the intercepted unified rendering method onDraw() is executed, and another current time T2 is recorded after the execution. From the two time values recorded above, the time of starting rendering is subtracted from the time of rendering completion. If the interpolation value is too large, it means that the time between the two renderings is too long, which further indicates that the system has a freeze when rendering the page.
[0040] If the difference between time T2 and T1 is greater than 1s, it is considered that a freeze has occurred.
[0041] In step S3, when a page freeze is detected, the Looper.getMainLooper().getThread().getStackTrace() method is used to obtain the current stack information, output the stack information of the client process at this time, and then accurately locate the program code location where the freeze occurs based on the information in the stack, and perform analysis and modification. Since it is a global interception, it is recommended to enable it in the development and debugging mode, and disable this function in the official online version.
[0042] The client-side system for detecting page rendering jams includes a unified interception module, a jam detection module, and a jam processing module;
[0043] The unified interception module is used to intercept the unified rendering method onDraw of the system on the client;
[0044] The jam detection module is responsible for writing logs before and after page rendering, recording timestamps, and determining whether jams occur during page rendering by comparing the timestamp difference before and after page rendering;
[0045] The jam processing module is responsible for processing jam situations, inputting stack information, analyzing the location where the program sends the jam, and making modifications.
[0046] The unified interception module uses aspect-oriented programming AOP to intercept the unified rendering method onDraw of the system.
[0047] The jam detection module is configured with a switch flag, which records a current time T1 before the intercepted unified renderer onDraw() is executed, and then records a current time T2 after the execution. If the difference between time T2 and T1 is greater than 1s, it is considered that a jam has occurred.
[0048] When a page freeze is detected, the freeze processing module uses the Looper.getMainLooper().getThread().getStackTrace() method to obtain the current stack information, output the stack information of the client process at this time, and then accurately locate the program code position where the freeze occurs based on the information in the stack, and perform analysis and modification.
[0049] The device for detecting page rendering jams on the client side includes a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the above method steps when executing the computer program.
[0050] The readable storage medium stores a computer program, and when the computer program is executed by a processor, the above method steps are implemented.
[0051] The embodiment described above is only one specific implementation of the present invention. Common changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting page rendering freeze on a client, characterized in that: The following steps are involved: Step S1, the client intercepts the system's unified rendering method onDraw; Step S2: Write logs before and after page rendering and record timestamps; compare the timestamp difference before and after page rendering to determine whether a freeze occurs during page rendering; Step S3, process the jamming situation, input the stack information, analyze the location where the program jams, and make modifications.
2. The method for detecting page rendering jams on a client according to claim 1, characterized in that: In the step S1, the client uses aspect-oriented programming AOP to intercept the unified rendering method onDraw of the system.
3. The method for detecting page rendering jams on a client according to claim 2, characterized in that: In the step S2, a switch flag is configured to record a current time T1 before the intercepted unified renderer onDraw() is executed, and then record a current time T2 after the execution. If the difference between time T2 and T1 is greater than 1s, it is considered that a freeze has occurred.
4. The method for detecting page rendering jams on a client according to claim 1, characterized in that: In step S3, when a page freeze is detected, the Looper.getMainLooper().getThread().getStackTrace() method is used to obtain the current stack information, and the stack information of the client process at this time is output, and then the program code position where the freeze occurs is accurately located according to the information in the stack for analysis and modification.
5. A system for detecting page rendering freeze on a client, characterized in that: Including unified interception module, jam detection module and jam processing module; The unified interception module is used to intercept the unified rendering method onDraw of the system on the client; The jam detection module is responsible for writing logs before and after page rendering, recording timestamps, and determining whether jams occur during page rendering by comparing the timestamp difference before and after page rendering; The jam processing module is responsible for processing jam situations, inputting stack information, analyzing the location where the program sends the jam, and making modifications.
6. The method for detecting page rendering jams by a client according to claim 5, characterized in that: The unified interception module uses aspect-oriented programming AOP to intercept the unified rendering method onDraw of the system.
7. The method for detecting page rendering jams by a client according to claim 6, characterized in that: The jam detection module is configured with a switch flag, which records a current time T1 before the intercepted unified renderer onDraw() is executed, and then records a current time T2 after the execution. If the difference between time T2 and T1 is greater than 1s, it is considered that a jam has occurred.
8. The method for detecting page rendering jams by a client according to claim 5, characterized in that: When a page freeze is detected, the freeze processing module uses the Looper.getMainLooper().getThread().getStackTrace() method to obtain the current stack information, output the stack information of the client process at this time, and then accurately locate the program code position where the freeze occurs based on the information in the stack, and perform analysis and modification.
9. A device for detecting page rendering freeze on a client, characterized in that: The method comprises a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the method steps as claimed in any one of claims 1 to 4 when executing the computer program.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Application not responding positioning system and method
CN106681913A
Method and device for acquiring webpage lagging data, terminal and storage medium
CN113067752A
