Flutter application screen static background continuous rendering monitoring method and device
By binding lifecycle events to Flutter applications and periodically capturing and comparing screen pixel data, the issues of automation and accuracy in invalid rendering detection are resolved, resource consumption is reduced, and application performance is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-18
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies lack automated and high-precision detection methods, making it difficult to identify the problem of Flutter applications continuously rendering in the background when the screen is still, resulting in wasted CPU and GPU resources and affecting application performance.
By binding to the lifecycle of a Flutter application, setting monitoring parameters, periodically capturing screen pixel data and comparing it pixel by pixel, and combining it with rendering activity thresholds, the system can automatically identify visually static states and generate alarm information.
It achieves accurate identification of invalid rendering behavior, reduces CPU and memory usage, reduces false alarms, and adapts to complex application scenarios.
Smart Images

Figure CN121807663A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Flutter application performance optimization technology, and in particular to a monitoring method and apparatus for continuous background rendering of Flutter applications when the screen is still. Background Technology
[0002] Flutter, as a mainstream declarative UI framework, is widely used in mobile and desktop application development due to its efficient rendering pipeline and consistent cross-platform experience. Its rendering process includes key steps such as widget building, element updating, and rendering object drawing. Under normal circumstances, the rendering process is only triggered when the UI state changes.
[0003] However, in actual development, issues such as improper state management, excessive animation triggering, and unnecessary listener responses can lead to a situation where Flutter applications exhibit a phenomenon where the screen UI appears static while the background rendering process continues to run. This ineffective rendering continuously consumes CPU and GPU resources, reducing application energy efficiency. Especially on battery-powered mobile devices, it can shorten battery life and impact overall application performance.
[0004] Existing technologies lack effective detection methods for this type of problem: traditional performance testing methods often focus on a single aspect (such as only counting Build method calls), failing to consider actual rendering overhead; some solutions rely on developers manually inserting logs, which is highly intrusive and cannot be automated; at the same time, they lack accurate judgment of "visual stillness," making them prone to misjudgment due to minute pixel jitter. These shortcomings make it difficult for developers to discover and locate invalid rendering behaviors, hindering the performance optimization of Flutter applications. Summary of the Invention
[0005] This invention provides a monitoring method and apparatus for continuous background rendering of Flutter applications when the screen is still, in order to solve the defects of existing technologies that cannot automatically and accurately detect continuous background rendering of Flutter applications when the screen is still, and to achieve accurate identification and alarm of invalid rendering behavior, providing a reliable basis for application performance optimization.
[0006] This invention provides a method for monitoring the continuous background rendering of a Flutter application when the screen is still, including:
[0007] During the Flutter application startup phase, the lifecycle of the Flutter application is bound and monitoring parameters are set. These monitoring parameters include: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0008] The original pixel data of the screen of the Flutter application is captured and stored according to the screen snapshot capture cycle.
[0009] The widget building activity and rendering object drawing activity of the Flutter application are tracked synchronously, and the number of first calls to the widget building activity and the number of second calls to the rendering object drawing activity are counted within each screenshot capture cycle.
[0010] The first raw pixel data of the current screen snapshot capture cycle is compared with the second raw pixel data of the previous screen snapshot capture cycle, and combined with the pixel difference tolerance, it is determined whether the screen of the Flutter application is in a visually static state.
[0011] If the screen is in a static state, it is determined whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or whether the second number of calls has reached the drawing activity threshold.
[0012] If so, the number of consecutive static and continuous rendering cycles is accumulated. When the accumulated number of cycles reaches the continuous static alarm threshold, alarm information is generated and output.
[0013] According to the monitoring method for continuous background rendering of a Flutter application when the screen is still, provided by the present invention, after generating and outputting alarm information, the method further includes:
[0014] Reset the cumulative number of cycles.
[0015] According to a monitoring method for continuous background rendering of a Flutter application when the screen is still, provided by the present invention, after determining whether the screen of the Flutter application is in a visually still state, the method further includes:
[0016] If the visual state is not static, then reset the first and second call counts.
[0017] According to the present invention, a monitoring method for continuous background rendering of a Flutter application with a static screen includes a pixel-by-pixel comparison of the first raw pixel data of the current screen snapshot capture period with the second raw pixel data of the previous screen snapshot capture period, and a determination of whether the screen of the Flutter application is in a visually static state based on the pixel difference tolerance.
[0018] Pixel comparison compares the RGBA channel byte values of the first and second original pixel data one pixel at a step size of 4 bytes, and counts the number of different pixels.
[0019] If the percentage of the difference in pixels does not exceed the pixel difference tolerance, the screen of the Flutter application is determined to be in a visually static state; otherwise, the screen of the Flutter application is determined to be in a visually non-static state.
[0020] A monitoring method for continuous background rendering of a Flutter application when the screen is still, provided by the present invention, further includes:
[0021] If the number of differing pixels counted exceeds the pixel difference tolerance before the pixel comparison process is completed, the pixel comparison process will be terminated.
[0022] According to the present invention, a monitoring method for continuous background rendering of a Flutter application when the screen is still includes capturing and storing the raw pixel data of the Flutter application's screen according to the screen snapshot capture period, comprising:
[0023] During each screen snapshot capture cycle, the screen image is obtained by calling the toImage method of the rendering object;
[0024] The screen image is converted into an RGBA format Uint8List byte array using the toByteData method to obtain and store the original pixel data.
[0025] A monitoring method for continuous background rendering of a Flutter application when the screen is still, provided by the present invention, further includes:
[0026] When the lifecycle ends or monitoring is disabled, resources are released and the monitoring process is terminated.
[0027] The present invention also provides a monitoring device for Flutter applications that continue rendering in the background when the screen is still, comprising:
[0028] The settings module is used to bind the lifecycle of the Flutter application during the Flutter application startup phase and set monitoring parameters, including: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0029] The capture module is used to capture and store the raw pixel data of the screen of the Flutter application according to the screen snapshot capture cycle;
[0030] The statistics module is used to synchronously track the Widget building activities and rendering object drawing activities of the Flutter application, and to count the first number of times the Widget building activities are called and the second number of times the rendering object drawing activities are called within each screen snapshot capture cycle;
[0031] The comparison module is used to compare the first raw pixel data of the current screen snapshot capture cycle with the second raw pixel data of the previous screen snapshot capture cycle pixel by pixel, and in combination with the pixel difference tolerance, determine whether the screen of the Flutter application is in a visually static state.
[0032] The determination module is used to determine whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or the second number of calls has reached the drawing activity threshold if the screen is in a visually static state.
[0033] The alarm module is used to accumulate the number of consecutive static and continuous rendering cycles if the condition is met. When the accumulated number of cycles reaches the continuous static alarm threshold, an alarm message is generated and output.
[0034] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the monitoring method for continuous background rendering of a Flutter application when the screen is still, as described above.
[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in any of the above.
[0036] The present invention provides a monitoring method and apparatus for continuous background rendering of Flutter applications when the screen is still. Compared with the prior art, the present invention has the following significant technical advantages:
[0037] 1. Automated high-precision detection: By periodically capturing pixels and comparing them pixel by pixel, combined with a quantized rendering activity threshold, it can accurately identify static but continuously rendering behaviors on the screen, avoiding subjective judgment errors.
[0038] 2. Low-intrusion integration: Based on the native binding mechanism and callback interface of the Flutter framework, it can be enabled without modifying the application business code. Only the monitoring module needs to be initialized, which has minimal impact on the application development process.
[0039] 3. Dual rendering activity tracking: It covers both the Widget building and rendering object drawing stages simultaneously. Compared with single-stage tracking, it provides more comprehensive detection and can discover hidden invalid rendering such as "no build but paint".
[0040] 4. Controllable resource consumption: By reasonably setting the capture cycle and terminating the comparison in advance, the CPU and memory usage are reduced while ensuring detection accuracy, and the monitoring function itself is prevented from affecting the application performance.
[0041] 5. Strong robustness: Introducing pixel difference tolerance, it can ignore tiny pixel jitter or color deviation, reduce false alarms, and adapt to complex application scenarios. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0043] Figure 1 This is a flowchart illustrating the monitoring method for continuous background rendering of a Flutter application when the screen is still, provided by this invention.
[0044] Figure 2 This is a schematic diagram of the structure of the monitoring device for continuous background rendering of Flutter applications when the screen is still, provided by the present invention.
[0045] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0047] It should be noted that in the description of the embodiments of the present invention, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. The terms "upper," "lower," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Unless otherwise expressly specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly, for example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two elements. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0048] The terms "first," "second," etc., used in this invention are used to distinguish similar objects, not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0049] The following is combined with Figures 1 to 3 This invention describes a method and apparatus for monitoring continuous background rendering of a Flutter application when the screen is still.
[0050] like Figure 1 As shown, this invention constructs a complete technical system of "initial binding - pixel capture - rendering tracking - state determination - alarm triggering", providing a monitoring method for continuous background rendering of Flutter applications when the screen is still. Specifically, it includes the following steps:
[0051] Step 110: During the Flutter application startup phase, bind the lifecycle of the Flutter application and set monitoring parameters, including: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0052] Specifically, during the Flutter application startup phase, `WidgetsFlutterBinding.ensureInitialized()` ensures the underlying framework bindings are ready, and `WidgetsBinding.instance.addObserver` registers a custom `BindingBase` derived class `PerformanceMonitorBinding`, deeply integrating performance monitoring functionality into the Flutter framework's lifecycle management. This binding class is instantiated early in the application startup and runs as part of the Flutter framework, achieving native framework-level monitoring, ensuring the globality and persistence of the monitoring service, and avoiding intrusive dependencies on application business logic.
[0053] The monitoring component is implemented as a global singleton using PerformanceMonitorBinding. The global singleton is initialized using PerformanceMonitorBinding.ensureInstance() to ensure the uniqueness and global availability of the monitoring component. The monitoring component inherits from the BindingBase class of the Flutter framework, integrates core Binding capabilities such as scheduling and rendering, and is registered as an application lifecycle observer through the addObserver method, enabling the monitoring component to perceive changes in the application's state such as startup, running, and termination.
[0054] Fixed monitoring parameters are set during the initialization of PerformanceMonitorBinding. In some embodiments, the parameter values have been verified in practice to balance detection accuracy and resource consumption.
[0055] Screen snapshot capture period (CHECK_INTERVAL_MS): The period for capturing screen snapshots and determining the status, fixed at 500 milliseconds, to control the capture frequency and reduce resource consumption;
[0056] Build activity threshold (BUILD_ACTIVITY_THRESHOLD): 3 times / cycle, the minimum number of calls required for a Widget to build within the determination cycle;
[0057] Paint Activity Threshold (PAINT_ACTIVITY_THRESHOLD): 3 times / cycle, the minimum number of times a rendering object is active within the determination cycle;
[0058] Continuous static alarm threshold (CONSECUTIVE_NO_VISUAL_CHANGE_THRESHOLD): Fixed at 5 times, the number of consecutive static and continuous rendering cycles required to trigger an alarm;
[0059] Pixel Difference Tolerance (PIXEL_DIFFERENCE_TOLERANCE_PERCENT): 0.5%, the percentage of minute pixel differences allowed, used to determine whether there is a visual change between two frames and avoid misjudgment.
[0060] Step 120: Capture and store the raw pixel data of the screen of the Flutter application according to the screen snapshot capture cycle.
[0061] Specifically, raw pixel data is captured to provide data support for determining the screen state. The monitoring module maintains a periodic timer, triggering the core processing function at 500-millisecond intervals to start the screen pixel capture process. When the timer triggers, it accesses the Flutter rendering layer to capture the image of the currently visible area of the application. It calls RenderBinding.instance.renderView asynchronously to obtain the root rendering object (RenderView) of the Flutter application, and then accesses its subordinate child rendering objects to ensure that the capture range covers the application's visible area.
[0062] In some embodiments, step 120 may include:
[0063] During each screen snapshot capture cycle, the screen image is obtained by calling the toImage method of the rendering object;
[0064] The screen image is converted into an RGBA format Uint8List byte array using the toByteData method to obtain and store the original pixel data.
[0065] In this embodiment, toImage and toByteData are methods (functions) in the Flutter framework used to process image data. toImage is a member method of the RenderObject, and toByteData is a member method of the Image object. Both are used for capturing and converting raw pixel data.
[0066] The `toImage(pixelRatio:ui.window.devicePixelRatio)` method of the rendering object is called asynchronously to obtain the screen image. Then, the `image.toByteData(format:ui.ImageByteFormat.rawRgba)` method converts the screen image into a raw byte array (Uint8List) in RGBA format. This process does not perform image encoding such as PNG or JPG, obtaining raw pixel data to maximize the efficiency of subsequent comparison. The converted raw pixel data is stored in the module instance variable `_currentFramePixels` to prepare for subsequent comparison.
[0067] Step 130: Synchronously track the Widget building activity and rendering object drawing activity of the Flutter application, and count the first call count of the Widget building activity and the second call count of the rendering object drawing activity within each screen snapshot capture cycle.
[0068] Specifically, the rendering intensity within a cycle is quantified by synchronously tracking two core rendering activities: Widget Build and Render Object Paint.
[0069] Build activity tracking: Register a global callback function via SchedulerBinding.instance.addBuildCallback(). Whenever the Flutter application triggers the Widget build method, the callback function is triggered, the module's _buildCallCount counter is incremented, and the first call count of the Build method within the current cycle is counted.
[0070] Paint Activity Tracking: The module provides the registerPaintCallback(VoidCallback callback) interface, which allows developers to bind the Paint method of the target rendering object (RenderObject) to this interface. When the rendering object performs a drawing operation, the bound callback function is triggered, and the module's _paintCallCount counter increments to count the second call to the Paint method within the current cycle.
[0071] Step 140: Compare the first raw pixel data of the current screen snapshot capture cycle with the second raw pixel data of the previous screen snapshot capture cycle pixel by pixel, and combine the pixel difference tolerance to determine whether the screen of the Flutter application is in a visually static state.
[0072] Specifically, by comparing pixels, it can accurately determine whether there are significant visual changes in the screen image.
[0073] In some embodiments, step 140 may include:
[0074] Pixel comparison compares the RGBA channel byte values of the first and second original pixel data one pixel at a step size of 4 bytes, and counts the number of different pixels.
[0075] If the percentage of the difference in pixels does not exceed the pixel difference tolerance, the screen of the Flutter application is determined to be in a visually static state; otherwise, the screen of the Flutter application is determined to be in a visually non-static state.
[0076] In this embodiment, the R, G, B, and A channel byte values of the pixel data in the current period and the previous period are traversed and compared with a step size of 4 bytes (corresponding to one RGBA pixel); whenever a difference in any channel byte value is detected, the diffByteCount difference counter is incremented.
[0077] Based on the total length of pixel data and the preset pixel difference tolerance, the maximum number of allowed difference pixels can be obtained. When the number of difference pixels counted does not exceed the maximum number of allowed difference pixels, it is considered that the screen image has not undergone significant visual changes and is judged to be in a visually static state; otherwise, it is considered that the screen image has undergone significant visual changes, that is, it is in a visually non-static state.
[0078] It employs direct comparison of low-level pixel buffers (RGBA raw byte streams) to achieve the highest precision detection of changes in image state. Furthermore, it introduces a percentage-based pixel difference tolerance, achieving robust tolerance to subtle rendering jitter or minute color deviations, thereby distinguishing realistic visual changes from acceptable rendering noise.
[0079] To optimize performance, some embodiments further include: during the pixel comparison process, if the number of statistically differing pixels exceeds the pixel difference tolerance in advance, then the pixel comparison process is terminated.
[0080] In this embodiment, during the pixel comparison process, if the number of statistically different pixels exceeds the pixel difference tolerance in advance, the traversal is stopped immediately and it is directly determined that the image is in a visually non-static state, that is, the image has undergone significant visual changes, so as to reduce invalid calculations.
[0081] Before performing pixel comparison, data verification can also be performed. First, check whether the pixel data of the previous cycle is empty, and whether the length of the pixel data of the current cycle is consistent with that of the previous cycle. If there is an anomaly, it is directly determined that the image has undergone a significant visual change and is in a non-static visual state.
[0082] Step 150: If the screen is in a visually static state, determine whether the first number of calls within the current screen snapshot capture period has reached the construction activity threshold or whether the second number of calls has reached the drawing activity threshold.
[0083] Step 160: If yes, then accumulate the number of consecutive static and continuous rendering cycles. When the accumulated number of cycles reaches the continuous static alarm threshold, generate alarm information and output it.
[0084] Specifically, by combining screen display status with rendering activity, invalid rendering behavior can be identified and alerted.
[0085] During the current screen snapshot capture period, the screen is in a visually static state. By counting the number of Widget building activities and the number of rendering object drawing activities, when the number of calls to either of these two rendering activities reaches a preset threshold, it indicates that background rendering is in progress. The cumulative number of consecutive static and continuous rendering periods increases by 1.
[0086] By monitoring whether the screen is still rendering in the background during each screenshot capture period when it appears to be in a visually static state, the system accumulates the number of consecutive periods that meet the criteria. When a preset consecutive static state alarm threshold is reached, an alarm message is generated and output to the application console or log interface. Furthermore, the alarm message can include multi-dimensional information such as timestamps, the number of consecutive static periods, rendering activity data (Build call count, Paint call count), application context (including the current root Widget type to help locate the problem scenario), etc., providing developers with direct evidence to quickly pinpoint the source of invalid rendering.
[0087] In some embodiments, after generating and outputting the alarm information, the method further includes resetting the cumulative period count. Specifically, after triggering an alarm, the cumulative period count counter is reset.
[0088] Understandably, if the current cumulative period count is 2, and the next period is determined by monitoring to be a visually non-static state, or a visually static state but the number of background rendering activity calls has not reached the preset threshold, then the cumulative period count will not be incremented by 1. In this case, the cumulative period count counter will also be reset to prepare for the next period's statistics.
[0089] Correspondingly, in some embodiments, after determining whether the screen of the Flutter application is in a visually static state, the method further includes: if it is in a visually non-static state, then resetting the first call count and the second call count.
[0090] In this embodiment, if a significant visual change occurs, the counters for the number of Widget construction activity calls and the counters for the number of rendering object drawing activity calls are reset. Additionally, the counters for consecutive static cycles are reset, awaiting the next monitoring cycle. Steps 120 to 160 are driven by a timer and continuously execute as the Flutter application runs, achieving full-time monitoring.
[0091] In some embodiments, the method further includes: releasing resources and terminating the monitoring process when the lifecycle ends or monitoring is disabled.
[0092] In this embodiment, when the lifecycle of the Flutter application ends or the monitoring function is disabled, the module's dispose() method is called to cancel the timer, remove the global callback, clear the Paint callback list, release all occupied resources, and avoid memory leaks.
[0093] The above-described method for monitoring continuous background rendering of Flutter applications when the screen is still has the following significant advantages compared to existing technologies:
[0094] 1. Automated high-precision detection: By periodically capturing pixels and comparing them pixel by pixel, combined with a quantized rendering activity threshold, it can accurately identify static but continuously rendering behaviors on the screen, avoiding subjective judgment errors.
[0095] 2. Low-intrusion integration: Based on the native binding mechanism and callback interface of the Flutter framework, it can be enabled without modifying the application business code. Only the monitoring module needs to be initialized, which has minimal impact on the application development process.
[0096] 3. Dual rendering activity tracking: It covers both the Widget building and rendering object drawing stages simultaneously. Compared with single-stage tracking, it provides more comprehensive detection and can discover hidden invalid rendering such as "no build but paint".
[0097] 4. Controllable resource consumption: By reasonably setting the capture cycle and terminating the comparison in advance, the CPU and memory usage are reduced while ensuring detection accuracy, and the monitoring function itself is prevented from affecting the application performance.
[0098] 5. Strong robustness: Introducing pixel difference tolerance, it can ignore tiny pixel jitter or color deviation, reduce false alarms, and adapt to complex application scenarios.
[0099] The monitoring device for continuous background rendering of Flutter applications when the screen is still, provided by the present invention, is described below. The monitoring device for continuous background rendering of Flutter applications when the screen is still and the monitoring method for continuous background rendering of Flutter applications when the screen is still can be referred to in correspondence with each other.
[0100] like Figure 2 As shown, the present invention provides a monitoring device for continuous background rendering of a Flutter application when the screen is still, comprising:
[0101] The setting module 210 is used to bind the lifecycle of the Flutter application during the Flutter application startup phase and set monitoring parameters, including: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0102] The capture module 220 is used to capture and store the raw pixel data of the screen of the Flutter application according to the screen snapshot capture cycle;
[0103] The statistics module 230 is used to synchronously track the Widget building activities and rendering object drawing activities of the Flutter application, and to count the first number of times the Widget building activities are called and the second number of times the rendering object drawing activities are called within each screen snapshot capture cycle;
[0104] The comparison module 240 is used to compare the first raw pixel data of the current screen snapshot capture cycle with the second raw pixel data of the previous screen snapshot capture cycle pixel by pixel, and in combination with the pixel difference tolerance, determine whether the screen of the Flutter application is in a visually static state.
[0105] The determination module 250 is used to determine whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or the second number of calls has reached the drawing activity threshold if the screen is in a visually static state.
[0106] The alarm module 260 is used to accumulate the number of consecutive static and continuous rendering cycles if the condition is met, and to generate and output alarm information when the accumulated number of cycles reaches the continuous static alarm threshold.
[0107] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a monitoring method for continuous background rendering of a Flutter application when the screen is still. This method includes:
[0108] During the Flutter application startup phase, the lifecycle of the Flutter application is bound and monitoring parameters are set. These monitoring parameters include: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0109] The original pixel data of the screen of the Flutter application is captured and stored according to the screen snapshot capture cycle.
[0110] The widget building activity and rendering object drawing activity of the Flutter application are tracked synchronously, and the number of first calls to the widget building activity and the number of second calls to the rendering object drawing activity are counted within each screenshot capture cycle.
[0111] The first raw pixel data of the current screen snapshot capture cycle is compared with the second raw pixel data of the previous screen snapshot capture cycle, and combined with the pixel difference tolerance, it is determined whether the screen of the Flutter application is in a visually static state.
[0112] If the screen is in a static state, it is determined whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or whether the second number of calls has reached the drawing activity threshold.
[0113] If so, the number of consecutive static and continuous rendering cycles is accumulated. When the accumulated number of cycles reaches the continuous static alarm threshold, alarm information is generated and output.
[0114] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0115] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the monitoring method for continuous background rendering of a Flutter application with a static screen provided by the above methods, the method comprising:
[0116] During the Flutter application startup phase, the lifecycle of the Flutter application is bound and monitoring parameters are set. These monitoring parameters include: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0117] The original pixel data of the screen of the Flutter application is captured and stored according to the screen snapshot capture cycle.
[0118] The widget building activity and rendering object drawing activity of the Flutter application are tracked synchronously, and the number of first calls to the widget building activity and the number of second calls to the rendering object drawing activity are counted within each screenshot capture cycle.
[0119] The first raw pixel data of the current screen snapshot capture cycle is compared with the second raw pixel data of the previous screen snapshot capture cycle, and combined with the pixel difference tolerance, it is determined whether the screen of the Flutter application is in a visually static state.
[0120] If the screen is in a static state, it is determined whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or whether the second number of calls has reached the drawing activity threshold.
[0121] If so, the number of consecutive static and continuous rendering cycles is accumulated. When the accumulated number of cycles reaches the continuous static alarm threshold, alarm information is generated and output.
[0122] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the monitoring method for continuous background rendering of a Flutter application when the screen is still, as provided by the methods described above, the method comprising:
[0123] During the Flutter application startup phase, the lifecycle of the Flutter application is bound and monitoring parameters are set. These monitoring parameters include: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance.
[0124] The original pixel data of the screen of the Flutter application is captured and stored according to the screen snapshot capture cycle.
[0125] The widget building activity and rendering object drawing activity of the Flutter application are tracked synchronously, and the number of first calls to the widget building activity and the number of second calls to the rendering object drawing activity are counted within each screenshot capture cycle.
[0126] The first raw pixel data of the current screen snapshot capture cycle is compared with the second raw pixel data of the previous screen snapshot capture cycle, and combined with the pixel difference tolerance, it is determined whether the screen of the Flutter application is in a visually static state.
[0127] If the screen is in a static state, it is determined whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or whether the second number of calls has reached the drawing activity threshold.
[0128] If so, the number of consecutive static and continuous rendering cycles is accumulated. When the accumulated number of cycles reaches the continuous static alarm threshold, alarm information is generated and output.
[0129] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. 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 this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0130] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for monitoring continuous background rendering of a Flutter application when the screen is still, characterized in that, include: During the Flutter application startup phase, the lifecycle of the Flutter application is bound and monitoring parameters are set. These monitoring parameters include: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance. The original pixel data of the screen of the Flutter application is captured and stored according to the screen snapshot capture cycle. The widget building activity and rendering object drawing activity of the Flutter application are tracked synchronously, and the number of first calls to the widget building activity and the number of second calls to the rendering object drawing activity are counted within each screenshot capture cycle. The first raw pixel data of the current screen snapshot capture cycle is compared with the second raw pixel data of the previous screen snapshot capture cycle, and combined with the pixel difference tolerance, it is determined whether the screen of the Flutter application is in a visually static state. If the screen is in a visually static state, it is determined whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or whether the second number of calls has reached the drawing activity threshold. If so, the number of consecutive static and continuous rendering cycles is accumulated. When the accumulated number of cycles reaches the continuous static alarm threshold, alarm information is generated and output.
2. The monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in claim 1, is characterized in that... After generating and outputting the alarm information, the following is also included: Reset the cumulative number of cycles.
3. The monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in claim 1, is characterized in that... After determining whether the screen of the Flutter application is in a visually static state, the method further includes: If the visual state is not static, then reset the first and second call counts.
4. The monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in claim 1, is characterized in that... The step of comparing the first raw pixel data of the current screen snapshot capture cycle with the second raw pixel data of the previous screen snapshot capture cycle pixel by pixel, and combining this with the pixel difference tolerance, to determine whether the screen of the Flutter application is in a visually static state includes: Pixel comparison compares the RGBA channel byte values of the first and second original pixel data one pixel at a step size of 4 bytes, and counts the number of differences in pixels. If the percentage of the difference in pixels does not exceed the pixel difference tolerance, the screen of the Flutter application is determined to be in a visually static state; otherwise, the screen of the Flutter application is determined to be in a visually non-static state.
5. The monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in claim 1, is characterized in that... Also includes: If the number of differing pixels counted exceeds the pixel difference tolerance before the pixel comparison process is completed, the pixel comparison process will be terminated.
6. The method according to claim 1, characterized in that, The step of capturing and storing the raw pixel data of the Flutter application's screen according to the screen snapshot capture period includes: During each screen snapshot capture cycle, the screen image is obtained by calling the toImage method of the rendering object; The screen image is converted into an RGBA format Uint8List byte array using the toByteData method to obtain and store the original pixel data.
7. The monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in claim 1, is characterized in that... Also includes: When the lifecycle ends or monitoring is disabled, resources are released and the monitoring process is terminated.
8. A monitoring device for continuous background rendering of a Flutter application when the screen is still, characterized in that, include: The settings module is used to bind the lifecycle of the Flutter application during the Flutter application startup phase and set monitoring parameters, including: screen snapshot capture cycle, build activity threshold, draw activity threshold, continuous stillness alarm threshold, and pixel difference tolerance. The capture module is used to capture and store the raw pixel data of the screen of the Flutter application according to the screen snapshot capture cycle; The statistics module is used to synchronously track the Widget building activities and rendering object drawing activities of the Flutter application, and to count the first number of times the Widget building activities are called and the second number of times the rendering object drawing activities are called within each screen snapshot capture cycle; The comparison module is used to compare the first raw pixel data of the current screen snapshot capture cycle with the second raw pixel data of the previous screen snapshot capture cycle pixel by pixel, and combine the pixel difference tolerance to determine whether the screen of the Flutter application is in a visually static state. The determination module is used to determine whether the first number of calls within the current screen snapshot capture cycle has reached the construction activity threshold or the second number of calls has reached the drawing activity threshold if the screen is in a visually static state. The alarm module is used to accumulate the number of consecutive static and continuous rendering cycles if the condition is met. When the accumulated number of cycles reaches the continuous static alarm threshold, an alarm message is generated and output.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the monitoring method for continuous background rendering of a Flutter application when the screen is still, as described in any one of claims 1 to 7.