A method, apparatus, electronic device, and computer storage medium for monitoring lag / stuttering.
By collecting user behavior event stacks and monitoring long tasks with PerformanceObserver, combined with XPath parsing, the problem of inaccurate page lag in traditional methods was solved, enabling rapid location and repair, and improving development efficiency and user experience.
Patent Information
- Application Number
- CN202210316771.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-28
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2042-03-28
AI Technical Summary
Traditional methods are difficult to accurately determine the location of page lag, and are time-consuming and labor-intensive, making it impossible to quickly locate the cause of lag and affecting the troubleshooting efficiency of front-end developers.
By collecting the event stack of user behavior events from sub-threads, using PerformanceObserver to monitor long-running tasks, and combining XPath parsing methods, stuttering location information is generated and uploaded to the server.
It enables real-time monitoring and precise location of page lag, helping developers quickly troubleshoot and fix performance issues, improve user experience, and reduce online bug rates.
Smart Images

Figure CN116860542B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more particularly to a method, apparatus, electronic device, and computer storage medium for monitoring lag / stuttering. Background Technology
[0002] In traditional solutions, it is possible to determine whether the main thread is lagging by monitoring the FPS. For example, a timer CADisplayLink can be added to the main thread's RunLoop so that the CADisplayLink method is executed every time the screen refreshes. This allows the number of screen refreshes within a fixed time period to be counted, which is the FPS. When the FPS drops significantly, it is determined that the main thread is lagging.
[0003] However, this traditional method has the following problems: when a lag occurs, the FPS will drop significantly, and the judgment results obtained by the traditional solution may not be accurate. In addition, the traditional solution can only determine whether a lag has occurred, but it is difficult to pinpoint exactly where on the page the lag problem is caused, which is inconvenient for front-end developers to troubleshoot.
[0004] Because front-end developers have varying skill levels, the performance of the pages developed and deployed varies greatly. Some large systems may involve thousands of pages in production, and manually testing each one would be extremely time-consuming and inefficient. Summary of the Invention
[0005] To address the aforementioned technical issues, a lag monitoring method is needed. This method collects information and reports it via embedded data points, enabling real-time monitoring of page lag and pinpointing lag points for easier troubleshooting and optimization of page performance. This invention provides a lag monitoring method, apparatus, electronic device, and computer storage medium. This method allows real-time monitoring of page lag issues in the user's browser. Through the reporting and collection of large amounts of data, page performance can be quickly assessed, and relevant performance-affecting points can be located. Developers can then quickly identify and fix the root causes, improving the user experience.
[0006] In one aspect, embodiments of the present invention provide a method for monitoring lag, characterized in that the method includes: collecting the event stack of a user behavior event sub-thread; adding the user behavior event of the current page to the event stack; detecting whether the main thread of the page is in a lag state according to a preset detection rule; if the main thread is detected to be in a lag state, finding the latest user behavior event at the top of the event stack, and generating lag location information based on the latest user behavior event at the top of the stack.
[0007] Furthermore, the step of detecting whether the main thread is in a lag state according to preset detection rules includes: detecting the PerformanceObserver, a long-task observer used to monitor performance measurement events in the main thread, and monitoring the existence of long-tasks through the PerformanceObserver object. If long-tasks are monitored, it is determined that the user behavior event triggered the page lag.
[0008] Furthermore, the PerformanceObserver used to monitor performance measurement events in the main thread includes: the PerformanceObserver will be notified when a new performance entry is recorded on the page's performance timeline. When a new performance entry is recorded, the observer will receive a notification.
[0009] Furthermore, finding the latest user behavior event at the top of the event stack includes: retrieving the top of the event stack using the getLastAction method to obtain the Event object of the user's most recent operation.
[0010] Furthermore, by using the Extensible Markup Language (XPath) parsing method, the XPath is queried in the user behavior event, and a unique value is calculated using the XPath of the Event object to locate the location causing the page lag.
[0011] Furthermore, the lag location information is uploaded to the server, wherein the location information includes data related to the location causing the page lag. The user behavior events include at least: mouse events, keyboard events, and pointer events; the data related to the location causing the page lag includes at least the start time of the lag, the duration of the lag, and the page URL path.
[0012] In another aspect, embodiments of the present invention provide a device for monitoring online page lag, characterized in that the device includes: a collection module, used to collect the event stack of user behavior event sub-threads; add the user behavior events of the current page to the event stack; a state detection module, used to detect whether the main thread of the page is in a lag state according to preset detection rules; and a lag location module, used to find the latest user behavior event at the top of the event stack if the main thread is detected to be in a lag state, and generate lag location information based on the latest user behavior event at the top of the stack.
[0013] Furthermore, the step of detecting whether the main thread is in a lag state according to the preset detection rules includes: detecting the long task observer PerformanceObserver in the main thread used to monitor performance measurement events, and monitoring the existence of long tasks LongTasks through the PerformanceObserver object; if long tasks LongTasks are monitored, it is determined that the user behavior event triggered the page lag.
[0014] Furthermore, the PerformanceObserver used to monitor performance measurement events in the main thread includes: the PerformanceObserver records a new performance information, performanceentries, on the page's performance timeline, and the observer will receive a notification when a new performance information is recorded.
[0015] Furthermore, finding the latest user behavior event at the top of the event stack includes: retrieving the top of the event stack using the getLastAction method to obtain the Event object of the user's most recent operation.
[0016] Furthermore, by using the Extensible Markup Language (XPath) parsing method, the XPath is queried in the user behavior event, and a unique value is calculated using the XPath of the Event object to locate the location causing the page lag.
[0017] Furthermore, the lag location information is uploaded to the server, wherein the location information includes data related to the location causing the page lag. The user behavior events include at least: mouse events, keyboard events, and pointer events; the data related to the location causing the page lag includes at least the start time of the lag, the duration of the lag, and the page URL path.
[0018] In another aspect, embodiments of the present invention provide an electronic device, characterized in that the electronic device includes: a processor; a memory for storing processor-executable instructions; wherein the processor is used to execute the instructions to implement the various steps in the above method.
[0019] In another aspect, embodiments of the present invention provide a computer medium, characterized in that, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is able to execute to implement the various steps in the above-described method.
[0020] This invention provides a method for monitoring online page performance lag. It collects the event stack of user behavior events from sub-threads and determines whether the main page thread is lagging. When the main thread lags, the corresponding lag event stack is extracted to generate lag location information. This allows for rapid assessment of page performance, pinpointing relevant points affecting page performance, and helping developers quickly identify and fix the causes, thus improving user experience. This method also enables monitoring of development quality, reduces the online execution of inefficient code, and lowers the online bug rate. Attached Figure Description
[0021] Specific embodiments of the present invention will now be described with reference to the accompanying drawings, wherein:
[0022] Figure 1 This invention provides a method for monitoring lag in a given embodiment.
[0023] Figure 2 This invention provides a method for monitoring lag / stuttering according to Embodiment 2.
[0024] Figure 3 This diagram illustrates the structure of an embodiment of the device provided in this invention.
[0025] Figure 4 A schematic diagram of the structure of an electronic device provided according to an embodiment of the present invention is shown. Detailed Implementation
[0026] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.
[0027] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0028] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0029] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0030] It should be understood that although the terms first, second, third, etc., may be used in this invention to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of this invention, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0031] Figure 1 This is a flowchart illustrating an embodiment of a method for monitoring lag provided by this invention. Figure 1 As shown, the method includes the following steps:
[0032] Step 101: Start the main page thread and the user behavior event sub-thread;
[0033] The current startup time point is obtained. When the current startup time point is reached, it is determined that the startup condition of the detection sub-thread is met. The current startup time point is determined by the sluggish state of the main thread detected when the detection sub-thread was last started. When the main thread is detected to be in a continuous sluggish state, the current startup time point of the detection sub-thread is postponed accordingly.
[0034] Specifically, a detection sub-thread can be created and executed in a loop of start-detect-sleep-start according to predefined startup conditions. While the detection sub-thread is performing its detection, it can determine whether the main thread's runloop has been stuck in a certain state for too long based on notification messages from the main thread's observer, thereby determining whether the main thread is in a stuck state.
[0035] Step 102: Collect the event stack of the user behavior event sub-thread;
[0036] To accurately pinpoint the cause of the lag, this embodiment uses periodic data collection. When a main thread timeout occurs, the most time-consuming stack trace can be found in the collected stack trace to accurately locate the cause of the lag. Only a specified number of stack traces whose collection time is closest to the current time can be retained to avoid consuming too much storage space.
[0037] Step 103: Add the user behavior event of the current page to the event stack;
[0038] The user behavior events include at least: mouse events, keyboard events, pointer events, touch events, etc.; among which, mouse events include at least: mousedown, mouseover, etc.; pointer events include at least: pointerup, pointerdown, pointermove, etc.; keyboard events include at least: keydown, keypress, keyup, etc.; touch events include at least: touchstart, touchmove, touchend, etc.
[0039] Step 104: Detect whether the main thread of the page is in a sluggish state according to the preset detection rules;
[0040] In this embodiment, when detecting whether the main thread of the page is in a sluggish state according to preset detection rules, the sluggish state of the main thread can be determined in the following way:
[0041] The `PerformanceObserver`, a long-task observer used in the main thread to monitor performance metrics events, monitors the existence of long-tasks through the `PerformanceObserver` object. If long-tasks are detected, it's determined that the user behavior event triggered the page lag. The "Performance Timeline" also defines a crucial interface for observing new performance information recorded on the "Performance Timeline." When new performance information is recorded, the observer receives a notification. This is `PerformanceObserver`. The `PerformanceObserver` interface is used to observe performance evaluation events and notify them when new performance metrics are recorded in the browser's performance timeline. The `PerformanceObserver` interface's function is to invoke a callback function whenever a task exceeding 50 milliseconds is executed.
[0042] Step 105: If the main thread is detected to be in a lag state, the latest user behavior event at the top of the corresponding event stack is found, and lag location information is generated based on the latest user behavior event at the top of the stack.
[0043] In this embodiment, step S105 can be performed in the following manner:
[0044] The getLastAction method retrieves the top of the event stack to obtain the Event object of the user's most recent action.
[0045] The XPath parsing method of Extensible Markup Language is used to query the XPath in the user behavior event, and the unique value of the Event object is calculated by XPath to locate the location that causes the page to freeze.
[0046] The lag location information is uploaded to the server, wherein the location information includes data related to the location causing the page lag. The data related to the location causing the page lag includes at least the start time, duration, and URL path of the lag.
[0047] Due to the inherent characteristics of UIKit on the iOS platform, all UI operations must be executed on the main thread. Therefore, developers may place logic with uncertain thread safety on the main thread. The large amount of computation, I / O, and drawing work contained in this unsafe logic can potentially cause the main thread to lag.
[0048] In traditional solutions, it is possible to determine whether the main thread is lagging by monitoring the FPS. For example, a timer CADisplayLink can be added to the main thread's RunLoop so that the CADisplayLink method is executed every time the screen refreshes. This allows the number of screen refreshes within a fixed time period to be counted, which is the FPS. When the FPS drops significantly, it is determined that the main thread is lagging.
[0049] However, this traditional method has the following problems: when a lag occurs, the FPS will drop significantly, and the judgment results obtained by the traditional solution may not be accurate. In addition, the traditional solution can only determine whether a lag has occurred, but it is difficult to pinpoint exactly where on the page the lag problem is caused, which is inconvenient for front-end developers to troubleshoot.
[0050] As we know, lag occurs when an application's interface becomes unresponsive or renders sluggishly. Since the rendering of the application interface and event handling are completed on the main thread, lag can be attributed to main thread blocking.
[0051] Among the main reasons that may cause the main thread to be blocked during development, the following are some of the reasons:
[0052] a) The main thread is performing a large number of I / O operations: In order to facilitate code writing, a large amount of data is directly written to the main thread;
[0053] b) The main thread is performing a large amount of computation: the code is poorly written, and the main thread is performing complex calculations;
[0054] c) Excessive UI drawing: The interface is too complex, and UI drawing requires a lot of time;
[0055] d) The main thread is waiting for the lock: The main thread needs to acquire lock A to complete its task, but a child thread is currently holding lock A, causing the main thread to have to wait for the child thread to complete its task.
[0056] To address these possible causes, if the event stack of the sub-thread corresponding to the user behavior event at the time of the lag can be captured, then the lag can be located based on the event stack. According to the event stack, we can determine which function and line of code the main thread is stuck in, what lock it is waiting for, whether it is performing I / O operations, or complex calculations, thus enabling targeted solutions to the problem.
[0057] Therefore, in the lag monitoring method of this invention, the event stack of the user behavior event sub-thread is continuously collected on the one hand, and the main thread is detected for lag on the other. For example, the event stack of the user behavior event sub-thread can be collected and saved every 50 milliseconds, and the main thread can be detected for lag every 2 seconds. For instance, when the main thread lags, the most time-consuming event stack among the most recently saved event stacks is searched. Lag location information is generated based on the most time-consuming event stack, and this lag location information can be used to accurately locate the lag position.
[0058] Figure 2 This is a schematic diagram of another embodiment of the method for monitoring lag provided by this invention. Figure 2 As shown, the method includes the following steps:
[0059] Step 201: The main reason for page lag is that the browser's rendering phase is affected. Browsers have a JS thread and a GUI thread, which are mutually exclusive. When the JS thread is occupied for an extended period, it leads to delayed rendering and page lag. Therefore, the root cause is to find the existing JS logic on the page that is occupying the thread for an extended period, namely JavaScriptLongTasks.
[0060] Step 202 requires exploring methods for obtaining LongTasks. PerformanceObserver is used to monitor performance measurement events. It will be notified when a new performance entry is recorded on the browser's performance timeline. In this way, LongTasks issues can be monitored through the PerformanceObserver object.
[0061] Ensuring a smooth UI is important, so how do you test if the UI is smooth?
[0062] According to the RAIL performance model, if a web application responds to user input within 100 milliseconds, the user will perceive the application as having a smooth interaction. If the response time exceeds 100 milliseconds, the user will experience a slight delay. If it exceeds 1 second, the user's attention will wander from the task they are performing.
[0063] Because JavaScript is single-threaded, if a task takes too long to execute, it will block the UI thread and other tasks. For the user, this typically results in a "locked" page where the browser is unable to respond to user input.
[0064] A task that occupies the UI thread for a long time and prevents other critical tasks from being executed is called a "long task".
[0065] A more specific explanation is: event loop tasks that take longer than 50 milliseconds are considered long tasks.
[0066] So how do we detect if an application has "long-running tasks"?
[0067] One known approach is to use a short-cycle timer and check the time between two calls. If the time between two calls is greater than the timer's cycle time, then it is very likely that one or more "long tasks" are delaying the timer's execution.
[0068] While this approach achieves the desired result, it's not perfect. It requires constant polling to check for long-running tasks, which is detrimental to mobile phone battery life, and it also lacks a way to determine the cause of the delay (e.g., your own code vs. third-party code).
[0069] The W3C Performance Working Group provides the Long Tasks specification, which defines an interface that allows web developers to monitor the existence of "long tasks".
[0070] The PerformanceObserver interface is used to observe performance evaluation events and notify them when new performance metrics are logged in the browser's performance timeline.
[0071] Register a "long-task" observer, PerformanceObserver, whose function is to invoke a callback function whenever a task exceeding 50 milliseconds is executed. The "Performance Timeline" also defines a crucial interface for observing new performance information recorded on the timeline. When new performance information is recorded, the observer will be notified. This is PerformanceObserver. The callback is triggered when a new long-task performance update is recorded.
[0072] Step 203: When monitoring the LongTasks thread, it is necessary to associate it with the user's UI operations on the current page. Define a method getLastAction to retrieve the top of the event stack and obtain the Event object that the user recently performed.
[0073] Step 204: XPath, or XML Path Language, is a computer language used to locate specific parts of an XML document. By calculating a unique value for the XPath of an Event object, the location causing page lag can be pinpointed.
[0074] Step 205: By reporting the XPath value that caused the lag, the page lag behavior can be monitored and accurately located.
[0075] Extracting data from web pages is often achieved using XPath. XPath stands for XML Path Language, a language used to find information and locate specific parts of an XML document. XPath can be used by developers as a small query language for navigating through elements and attributes within an XML document. There are seven types of nodes in XPath: elements, attributes, text, namespaces, processing instructions, comments, and the document (root) node. An XML document is treated as a tree of nodes, with the root node called the document node or root node. XPath uses path expressions to select nodes or sets of nodes within an XML document. These path expressions are very similar to those found in a regular computer file system. The path can be absolute or relative. Path expressions can contain predicates, wildcards, and operators. XPath also includes over 100 built-in standard functions for comparing string values, numbers, dates and times, node manipulation, sequence manipulation, logical values, and more. Some exemplary XPath path expressions are shown below: / html / body / div / div / form / table / tr[1] / td / input[@name=keyword]; / html / body / div / ... / p / div / a[@content=next]; and .. / input[@id=12345].
[0076] Numerous new technologies and applications exist in business, academia, and industry, developed and implemented for extracting data, functions, and processes from the Web based on XPath. For example, a webpage is first parsed into an HTML (Hypertext Markup Language) DOM (Document Object Model) tree. The DOM, as used here, refers to the standard document object model defined by the W3C (World Wide Web Consortium). It represents HTML and XML (Extensible Markup Language) documents in a tree structure, defining methods and properties for traversing this tree and inspecting and modifying its nodes. Within the DOM tree structure, each node of the HTML document is treated as a node object of various types. Each node object has its own properties and methods, which are used to traverse the entire document tree. After generating the DOM document tree, the desired element can be found using attributes or tag names. Then, XPath can be used to locate that element, i.e., the required data. Once the data needed by the user is extracted from the webpage, its XPath-based path expression can be recorded, and the data can be located and accessed again in the future using the recorded XPath path expression.
[0077] An Event object represents the state of an event, such as the element in which the event occurred, the state of keyboard keys, the mouse position, and the state of mouse buttons. When is an Event object created? For example, when a user clicks on an element, the event we registered for that element is triggered. Each event has a corresponding object that describes this information; we call this object the event object. The event object allows us to quickly find the event source, locate the element's coordinates on the page, and also know the mouse's coordinates on the element, etc.
[0078] Step 206: Analysts can combine different dimensions and flexibly adjust them according to the granularity of business monitoring thresholds to build a complete page performance monitoring system.
[0079] This invention provides a method for monitoring page stuttering. It collects the event stack of user behavior events from sub-threads and determines whether the main page thread is stuttering. When the main thread stutters, it extracts the corresponding stuttering event stack to generate stuttering location information. This allows for rapid assessment of page performance, pinpointing relevant points affecting page performance, and helping developers quickly identify and fix the causes, thus improving user experience. This method also enables monitoring of development quality, reducing the online execution of inefficient code, and decreasing the online bug rate.
[0080] Corresponding to the above method embodiments, this invention also provides a device 300 for monitoring online page lag, see [link to device]. Figure 3As shown, the device 300 may include: a startup module 310, a data acquisition module 320, a status detection module 330, and a lag location module 340.
[0081] Startup module 310 is used to start the main page thread and the user behavior event sub-thread;
[0082] The current startup time point is obtained. When the current startup time point is reached, it is determined that the startup condition of the detection sub-thread is met. The current startup time point is determined by the sluggish state of the main thread detected when the detection sub-thread was last started. When the main thread is detected to be in a continuous sluggish state, the current startup time point of the detection sub-thread is postponed accordingly.
[0083] Specifically, a detection sub-thread can be created and executed in a loop of start-detect-sleep-start according to predefined startup conditions. While the detection sub-thread is performing its detection, it can determine whether the main thread's runloop has been stuck in a certain state for too long based on notification messages from the main thread's observer, thereby determining whether the main thread is in a stuck state.
[0084] The acquisition module 320 is used to acquire the event stack of the user behavior event sub-thread; and to add the user behavior events of the current page to the event stack.
[0085] To accurately pinpoint the cause of the lag, this embodiment uses periodic data collection. When a main thread timeout occurs, the most time-consuming stack trace can be found in the collected stack trace to accurately locate the cause of the lag. Only a specified number of stack traces whose collection time is closest to the current time can be retained to avoid consuming too much storage space.
[0086] The user behavior events include at least: mouse events, keyboard events, pointer events, touch events, etc.; among which, mouse events include at least: mousedown, mouseover, etc.; pointer events include at least: pointerup, pointerdown, pointermove, etc.; keyboard events include at least: keydown, keypress, keyup, etc.; touch events include at least: touchstart, touchmove, touchend, etc.
[0087] The status detection module 330 is used to detect whether the main thread of the page is in a sluggish state according to preset detection rules.
[0088] In this embodiment, when detecting whether the main thread of the page is in a sluggish state according to preset detection rules, the sluggish state of the main thread can be determined in the following way:
[0089] The `PerformanceObserver`, a long-task observer used in the main thread to monitor performance metrics events, monitors the existence of long-tasks through the `PerformanceObserver` object. If long-tasks are detected, it's determined that the user behavior event triggered the page lag. The "Performance Timeline" also defines a crucial interface for observing new performance information recorded on the "Performance Timeline." When new performance information is recorded, the observer receives a notification. This is `PerformanceObserver`. The `PerformanceObserver` interface is used to observe performance evaluation events and notify them when new performance metrics are recorded in the browser's performance timeline. The `PerformanceObserver` interface's function is to invoke a callback function whenever a task exceeding 50 milliseconds is executed.
[0090] The stuttering location module 340 is used to find the latest user behavior event at the top of the corresponding event stack if the main thread is detected to be in a stuttering state, and generate stuttering location information based on the latest event at the top of the stack.
[0091] In this embodiment, the stuttering positioning module 340 is specifically used for:
[0092] The getLastAction method retrieves the top of the event stack to obtain the Event object of the user's most recent action.
[0093] The XPath parsing method, used in Extensible Markup Language (XLP), is employed to query the XPath within the user behavior event. A unique value is calculated using the XPath of the Event object to pinpoint the location causing the page lag. The relevant data for the location causing the lag includes at least the start time, duration, and URL path (Pathname) of the lag.
[0094] This invention also provides an electronic device, which includes at least a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the program to implement the aforementioned lag monitoring method, including:
[0095] Start the main page thread and the user behavior event sub-thread;
[0096] Collect the event stack of the sub-thread that collects user behavior events;
[0097] Add the user action event of the current page to the event stack;
[0098] The system detects whether the main thread of the page is in a sluggish state according to preset detection rules.
[0099] If the main thread is detected to be in a lag state, the latest user behavior event at the top of the corresponding event stack is found, and lag location information is generated based on the latest user behavior event at the top of the stack.
[0100] Figure 4 A schematic structural diagram of an electronic device according to an exemplary embodiment of the present invention is shown. Please refer to... Figure 4 At the hardware level, the electronic device 400 includes a processor 402, an internal bus 403, a network interface 410, memory 404, and non-volatile memory 405, and may also include other hardware required for business operations. The processor 402 reads the corresponding computer program from the non-volatile memory 405 into the memory 404 and then runs it, forming a device for executing the stuttering detection method at the logical level. Of course, in addition to the software implementation, this invention does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.
[0101] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the aforementioned stuttering detection method, including:
[0102] Start the main page thread and the user behavior event sub-thread;
[0103] Collect the event stack of the sub-thread that collects user behavior events;
[0104] Add the user action event of the current page to the event stack;
[0105] The system detects whether the main thread of the page is in a sluggish state according to preset detection rules.
[0106] If the main thread is detected to be in a lag state, the latest user behavior event at the top of the corresponding event stack is found, and lag location information is generated based on the latest user behavior event at the top of the stack.
[0107] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic storage devices or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0108] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the present invention according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0109] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.
[0110] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this invention.
Claims
1. A method for monitoring lag / stuttering, characterized in that, include: Collect the event stack of the sub-thread that collects user behavior events; Add the user action event of the current page to the event stack; The user behavior events include at least: mouse events, keyboard events, or pointer events; The system detects whether the main thread of the current page is in a sluggish state according to preset detection rules, including: detecting the long task observer in the main thread used to monitor performance measurement events, and monitoring the existence of long tasks through the long task observer; the long task is a task that occupies the UI thread for more than a period of time and prevents other critical tasks from being executed. If the main thread is detected to be in a lag state, the latest user behavior event at the top of the event stack is found, and lag location information is generated based on the latest user behavior event at the top of the stack.
2. The method as described in claim 1, characterized in that, If there are long-running tasks being monitored, then the user behavior event is determined to have triggered page lag.
3. The method as described in claim 1, characterized in that, The long-task observer used in the main detection thread to monitor performance metric events includes: The long task observer records a new performance information on the performance timeline of the current page, and the observer will be notified when a new performance information is recorded.
4. The method as described in claim 1, characterized in that, Locate the latest user behavior event at the top of the event stack, including: By retrieving the latest event from the top of the event stack, we can obtain the event object of the user's most recent operation.
5. The method as described in claim 4, characterized in that, The generation of stuttering location information based on the latest event at the top of the stack includes: The Extensible Markup Language (XML) path parsing method is used to query the XML path in the user behavior event and calculate a unique value for the XML path of the event object to locate the location that causes page lag.
6. The method as described in claim 4, characterized in that, The relevant data for the location causing the page lag should include at least the start time of the lag, the duration of the lag, and the page URL path.
7. A device for monitoring online page performance lag, characterized in that, include: The data collection module is used to collect the event stack of the user behavior event sub-thread; Add the user action event of the current page to the event stack; The status detection module is used to detect whether the main thread of the page is in a sluggish state according to preset detection rules; The stuttering location module is used to find the latest user behavior event at the top of the corresponding event stack if the main thread is detected to be in a stuttering state, and generate stuttering location information based on the latest user behavior event at the top of the stack.
8. An electronic device, characterized in that, include: processor; A memory for storing processor-executable instructions; wherein the processor executes the instructions to implement the method as described in any one of claims 1 to 6.
9. A computer storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Application program monitoring method and device
CN108345524A
Jamming positioning method and device
CN111625456A
