[go: up one dir, main page]

CN116225357A - A method, system, device, and storage medium for preventing freezing of an application interface - Google Patents

A method, system, device, and storage medium for preventing freezing of an application interface Download PDF

Info

Publication number
CN116225357A
CN116225357A CN202310227042.8A CN202310227042A CN116225357A CN 116225357 A CN116225357 A CN 116225357A CN 202310227042 A CN202310227042 A CN 202310227042A CN 116225357 A CN116225357 A CN 116225357A
Authority
CN
China
Prior art keywords
task
time
application interface
refresh
time consumption
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310227042.8A
Other languages
Chinese (zh)
Inventor
欧阳典玖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bigo Technology Pte Ltd
Original Assignee
Bigo Technology Pte Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bigo Technology Pte Ltd filed Critical Bigo Technology Pte Ltd
Priority to CN202310227042.8A priority Critical patent/CN116225357A/en
Publication of CN116225357A publication Critical patent/CN116225357A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/14Digital output to display device ; Cooperation and interconnection of the display device with other functional units
    • G06F3/147Digital output to display device ; Cooperation and interconnection of the display device with other functional units using display panels
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72469User interfaces specially adapted for cordless or mobile telephones for operating the device by selecting functions from two or more displayed items, e.g. menus or icons
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Digital Computer Display Output (AREA)
  • User Interface Of Digital Computer (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

本申请实施例公开了一种应用界面卡顿预防方法、系统、设备及存储介质。本申请实施例提供的技术方案,通过获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;进而累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。采用上述技术手段,通过在任务耗时接近屏幕刷新时间节点的情况下,停止执行指定任务,以让出主线程的处理资源用于应用界面的绘制与刷新,确保应用界面按照正常的刷新频率进行刷新,进而避免屏幕卡顿的情况。提升应用界面显示的流畅性,提升用户的使用体验。

Figure 202310227042

The embodiment of the present application discloses a method, system, device and storage medium for preventing freezing of an application interface. In the technical solution provided by the embodiment of the present application, by obtaining the refresh time interval of the screen, when the system time is within the refresh time interval, each specified task is sequentially executed through the main thread; When the set time threshold is reached, the execution of the specified task is stopped, and the application interface drawing process is executed through the main thread at the screen refresh time node, and the time threshold is set according to the refresh time interval. Using the above technical means, by stopping the execution of the specified task when the task time is close to the screen refresh time node, the processing resources of the main thread are used for drawing and refreshing the application interface, so as to ensure that the application interface is refreshed according to the normal frequency. Refresh to avoid screen freeze. Improve the fluency of the application interface display and improve the user experience.

Figure 202310227042

Description

一种应用界面卡顿预防方法、系统、设备及存储介质A method, system, device, and storage medium for preventing freezing of an application interface

技术领域technical field

本申请实施例涉及计算机技术领域,尤其涉及一种应用界面卡顿预防方法、系统、设备及存储介质。The embodiments of the present application relate to the field of computer technology, and in particular, to a method, system, device, and storage medium for preventing freezing of an application interface.

背景技术Background technique

目前,随着移动互联网的快速发展,应用程序的业务也越来越复杂。一般而言,应用程序会通过主线程执行用户界面(User Interface,UI)绘制流程,根据设定的屏幕刷新频率执行用户界面的绘制与刷新。此外,应用程序在启动时往往需要对很多的自身服务、业务功能模块或是第三方库等内容进行初始化。在初始化任务中,应用程序的主线程需要执行一些相关的业务,如显示一张图片,执行一个动画等等。At present, with the rapid development of the mobile Internet, the business of application programs is becoming more and more complex. Generally speaking, an application program executes a user interface (UI) drawing process through a main thread, and performs drawing and refreshing of the user interface according to a set screen refresh frequency. In addition, applications often need to initialize many of their own services, business function modules, or third-party libraries when they start. In the initialization task, the main thread of the application needs to perform some related services, such as displaying a picture, performing an animation, and so on.

但是,由于应用程序主线程需要执行界面绘制和其他相关业务,当应用程序中过多的业务代码插入到主线程中执行时,会占用主线程的处理时间,影响界面绘制业务。此时应用程序界面的刷新会存在延迟,导致屏幕显示画面出现明显卡顿的现象,影响用户的使用体验。However, since the main thread of the application program needs to perform interface drawing and other related services, when too much business code in the application program is inserted into the main thread for execution, it will occupy the processing time of the main thread and affect the interface drawing service. At this time, there will be a delay in refreshing the application program interface, resulting in an obvious freeze phenomenon on the screen display, affecting the user experience.

发明内容Contents of the invention

本申请实施例提供一种应用界面卡顿预防方法、系统、设备及存储介质,能够预测应用界面卡顿现象,提升应用界面刷新流畅度,解决应用程序界面的刷新存在延迟的技术问题。Embodiments of the present application provide a method, system, device, and storage medium for preventing application interface freezing, which can predict application interface freezing, improve application interface refreshing fluency, and solve the technical problem of delay in application interface refreshing.

在第一方面,本申请实施例提供了一种应用界面卡顿预防方法,包括:In the first aspect, the embodiment of the present application provides a method for preventing freezing of the application interface, including:

获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;Obtain the refresh interval of the screen, and execute each specified task sequentially through the main thread when the system time is within the refresh interval;

累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。Accumulate the task time consumption of each specified task. When the task time consumption reaches the set time threshold, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node. The time threshold is set according to the refresh interval.

在第二方面,本申请实施例提供了一种应用界面卡顿预防系统,包括:In the second aspect, the embodiment of the present application provides an application interface freeze prevention system, including:

执行模块,配置为获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;The execution module is configured to obtain the refresh time interval of the screen, and when the system time is within the refresh time interval, each specified task is sequentially executed through the main thread;

预防模块,配置为累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。The prevention module is configured to accumulate the task time consumption of each specified task. When the task time consumption reaches the set time threshold, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node. The time threshold is based on Refresh interval settings.

在第三方面,本申请实施例提供了一种应用界面卡顿预防设备,包括:In a third aspect, the embodiment of the present application provides an application interface freeze prevention device, including:

存储器以及一个或多个处理器;memory and one or more processors;

所述存储器,配置为存储一个或多个程序;the memory configured to store one or more programs;

当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如第一方面所述的应用界面卡顿预防方法。When the one or more programs are executed by the one or more processors, the one or more processors are made to implement the application interface freeze prevention method as described in the first aspect.

在第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令在由计算机处理器执行时配置为执行如第一方面所述的应用界面卡顿预防方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and when executed by a computer processor, the computer-executable instructions are configured to perform the following steps: The method for preventing freezing of the application interface described in the first aspect.

在第五方面,本申请实施例提供了一种计算机程序产品,所述计算机程序产品中包含有指令,当指令在计算机或处理器上运行时,使得计算机或处理器执行如第一方面所述的应用界面卡顿预防方法。In the fifth aspect, the embodiment of the present application provides a computer program product, the computer program product contains instructions, and when the instructions are run on the computer or the processor, the computer or the processor executes the computer program described in the first aspect. The application interface freeze prevention method.

本申请实施例通过获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;进而累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。采用上述技术手段,通过在屏幕的刷新时间间隔使用主线程处理相关任务,并累计任务耗时,在任务耗时达到设定时间阈值,接近屏幕刷新时间节点的情况下,停止执行指定任务,以让出主线程的处理资源用于应用界面的绘制与刷新,确保应用界面按照正常的刷新频率进行刷新,进而避免屏幕卡顿的情况。提升应用界面显示的流畅性,提升用户的使用体验。并且,通过在刷新时间间隔尽可能地处理指定任务,可以充分利用主线程的处理资源,优化主线程技术资源的利用。In the embodiment of the present application, by obtaining the refresh time interval of the screen, when the system time is within the refresh time interval, each specified task is executed sequentially through the main thread; In the case of the threshold, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node, and the time threshold is set according to the refresh interval. Using the above technical means, by using the main thread to process related tasks at the refresh time interval of the screen, and accumulating the task time consumption, when the task time consumption reaches the set time threshold and is close to the screen refresh time node, stop executing the specified task, so as to Let the processing resources of the main thread be used for drawing and refreshing the application interface to ensure that the application interface is refreshed according to the normal refresh frequency, thereby avoiding the situation of screen freeze. Improve the fluency of the application interface display and improve the user experience. Moreover, by processing the specified tasks as much as possible at the refresh time interval, the processing resources of the main thread can be fully utilized, and the utilization of technical resources of the main thread can be optimized.

附图说明Description of drawings

图1是本申请实施例提供的一种应用界面卡顿预防方法的流程图;FIG. 1 is a flow chart of a method for preventing application interface freeze provided by an embodiment of the present application;

图2是本申请实施例中主线程的不同处理时段示意图;Fig. 2 is a schematic diagram of different processing periods of the main thread in the embodiment of the present application;

图3是本申请实施例中指定任务的一种执行流程图;Fig. 3 is a kind of execution flowchart of the specified task in the embodiment of the present application;

图4是本申请实施例中指定任务的另一种执行流程图;Fig. 4 is another execution flowchart of the specified task in the embodiment of the present application;

图5是本申请实施例中主线程的业务处理流程图;Fig. 5 is the business processing flowchart of main thread in the embodiment of the present application;

图6是本申请实施例提供的一种应用界面卡顿预防系统的结构示意图;FIG. 6 is a schematic structural diagram of an application interface freeze prevention system provided by an embodiment of the present application;

图7是本申请实施例提供的一种应用界面卡顿预防设备的结构示意图。Fig. 7 is a schematic structural diagram of an application interface freeze prevention device provided by an embodiment of the present application.

具体实施方式Detailed ways

为了使本申请的目的、技术方案和优点更加清楚,下面结合附图对本申请具体实施例作进一步的详细描述。可以理解的是,此处所描述的具体实施例仅仅用于解释本申请,而非对本申请的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本申请相关的部分而非全部内容。在更加详细地讨论示例性实施例之前应当提到的是,一些示例性实施例被描述成作为流程图描绘的处理或方法。虽然流程图将各项操作(或步骤)描述成顺序的处理,但是其中的许多操作可以被并行地、并发地或者同时实施。此外,各项操作的顺序可以被重新安排。当其操作完成时所述处理可以被终止,但是还可以具有未包括在附图中的附加步骤。所述处理可以对应于方法、函数、规程、子例程、子程序等等。In order to make the purpose, technical solution and advantages of the present application clearer, specific embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. It should be understood that the specific embodiments described here are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, only parts relevant to the present application are shown in the drawings but not all content. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe various operations (or steps) as sequential processing, many of the operations may be performed in parallel, concurrently, or simultaneously. In addition, the order of operations can be rearranged. The process may be terminated when its operations are complete, but may also have additional steps not included in the figure. The processing may correspond to a method, function, procedure, subroutine, subroutine, or the like.

本申请提供的一种应用界面卡顿预防方法,旨在通过在屏幕的刷新时间间隔使用主线程处理相关任务,并累计任务耗时,在任务耗时达到设定时间阈值,接近屏幕刷新时间节点的情况下,停止执行指定任务,以让出主线程的处理资源用于应用界面的绘制与刷新,进而避免屏幕卡顿的情况。This application provides a method for preventing freezing of the application interface, which aims to use the main thread to process related tasks at the screen refresh time interval, and accumulate task time consumption. When the task time consumption reaches the set time threshold, it is close to the screen refresh time node. In the case of , stop the execution of the specified task, so as to let the processing resources of the main thread be used for drawing and refreshing the application interface, thereby avoiding the situation of screen freezing.

由于应用程序在初始化过程中,一些任务不可避免地必须在应用程序的主线程中进行。然而,应用程序所有的用户界面(User Interface,UI)绘制过程也需要在主线程中进行。因此当应用程序中过多的业务代码插入到主线程中执行时,会占用主线程的时间,对主线程中用户界面绘制业务造成阻塞。对用户而言,用户在终端上就会感到应用程序界面刷新有延迟,有比较明显的画面卡顿现象。基于此,提供本申请实施例的一种应用界面卡顿预防方法,以解决应用程序界面的刷新存在延迟进而导致页面刷新卡顿的技术问题。As the application initializes, some tasks inevitably have to be performed in the application's main thread. However, all user interface (UI) drawing processes of the application also need to be performed in the main thread. Therefore, when too much business code in the application program is inserted into the main thread for execution, it will take up the time of the main thread and block the user interface drawing business in the main thread. For the user, the user will feel that there is a delay in refreshing the interface of the application program on the terminal, and there is a relatively obvious picture freeze phenomenon. Based on this, a method for preventing application interface freezing according to an embodiment of the present application is provided to solve the technical problem that there is a delay in refreshing the application interface, which leads to page refreshing freezing.

实施例:Example:

图1给出了本申请实施例提供的一种应用界面卡顿预防方法的流程图,本实施例中提供的应用界面卡顿预防方法可以由应用界面卡顿预防设备执行,该应用界面卡顿预防设备可以通过软件和/或硬件的方式实现,该应用界面卡顿预防设备可以是两个或多个物理实体构成,也可以是一个物理实体构成。一般而言,该应用界面卡顿预防设备可以是手机,电脑,平板,智能手表等终端设备。Figure 1 shows a flow chart of a method for preventing application interface freezing provided in an embodiment of the present application. The method for preventing application interface freezing provided in this embodiment can be executed by an application interface freezing prevention device. The prevention device may be realized by means of software and/or hardware, and the application interface freeze prevention device may be composed of two or more physical entities, or may be composed of one physical entity. Generally speaking, the application interface freeze prevention device can be a terminal device such as a mobile phone, a computer, a tablet, and a smart watch.

下述以该应用界面卡顿预防设备为执行应用界面卡顿预防方法的主体为例,进行描述。参照图1,该应用界面卡顿预防方法具体包括:The following description will be made by taking the application interface freeze prevention device as an example for executing the application interface freeze prevention method. Referring to Figure 1, the application interface freeze prevention method specifically includes:

S110、获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;S110. Obtain the refresh time interval of the screen, and execute each specified task sequentially through the main thread when the system time is within the refresh time interval;

S120、累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。S120. Accumulate the task time consumption of each specified task. When the task time consumption reaches the set time threshold, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node. The time threshold is based on the refresh time interval set up.

本申请实施例为了解决应用界面刷新延迟导致的画面卡顿问题,通过提供一种预防性的方案,利用主线程在屏幕刷新时间间隔内处理处理相关任务的累计耗时,判断主线程继续执行相关任务是否会影响界面绘制任务的处理,进而实现界面卡顿的预测效果。In order to solve the screen freeze problem caused by the application interface refresh delay, the embodiment of the present application provides a preventive solution, using the main thread to process the accumulated time spent on processing related tasks within the screen refresh time interval, and judging that the main thread continues to execute related tasks. Whether the task will affect the processing of the interface drawing task, and then realize the prediction effect of the interface freeze.

系统在进行应用界面绘制和刷新时,通常是按照固定的刷新频率进行应用界面绘制地,即系统会每隔一个固定的时间间隔执行一次界面绘制任务,定义该时间间隔为刷新时间间隔。通过确定这一屏幕的刷新时间间隔,当系统时间进入这一时间间隔的时候,即可利用主线程执行各个相关任务,如显示一张图片,执行一个动画等等,定义这些相关任务为指定任务。当系统时间处于屏幕刷新时间节点时,则需要通过主线程执行应用界面绘制任务。系统只需要保证主线程在屏幕刷新时间节点能够停止执行指定任务,按时执行应用界面刷新任务,保证指定任务不影响应用界面刷新任务的执行,即可避免应用界面的刷新延迟,从而避免画面卡顿现象,提升应用界面刷新流畅性。When the system draws and refreshes the application interface, it usually draws the application interface according to a fixed refresh rate, that is, the system will execute the interface drawing task at a fixed time interval, and define this time interval as the refresh interval. By determining the refresh time interval of this screen, when the system time enters this time interval, the main thread can be used to perform various related tasks, such as displaying a picture, executing an animation, etc., and defining these related tasks as specified tasks . When the system time is at the screen refresh time node, the application interface drawing task needs to be executed through the main thread. The system only needs to ensure that the main thread can stop executing the specified task at the screen refresh time node, execute the application interface refresh task on time, and ensure that the specified task does not affect the execution of the application interface refresh task, so as to avoid the refresh delay of the application interface and avoid screen freeze Phenomenon, improve application interface refresh fluency.

不同于现有卡顿解决方案在发现画面卡顿问题并找到复现路径后,使用调试工具检测引起卡顿的耗时任务以及该任务具体时长,然后将耗时长的任务移除,延迟执行使该任务不影响当次界面绘制和刷新任务的处理方式。本申请实施例不需要事先明确知道是否有卡顿发生进而进行卡顿任务的处理。通过在检测到卡顿即将发生时,不再执行耗时任务,防止耗时任务阻塞了画面刷新,从而减少界面卡顿,以此来实现应用界面卡顿预防效果,更及时地应对画面卡顿问题,提升用户体验。Different from the existing freeze solution, after discovering the screen freeze problem and finding a reproduction path, use the debugging tool to detect the time-consuming task that caused the freeze and the specific duration of the task, and then remove the time-consuming task and delay execution using This task does not affect the processing method of the current interface drawing and refreshing tasks. In the embodiment of the present application, it is not necessary to clearly know in advance whether there is a freeze, and then to process the freeze task. By no longer executing time-consuming tasks when it is detected that a freeze is about to occur, it prevents time-consuming tasks from blocking the screen refresh, thereby reducing interface freezes, thereby achieving the effect of preventing application interface freezes and responding to screen freezes in a more timely manner problems and improve user experience.

参照图2,提供本申请实施中主线程的不同处理时段示意图。其中,T1~T5表示屏幕刷新时间节点,系统会在这些时间节点上执行应用界面绘制和屏幕刷新业务,将当前系统的最新画面状态显示到屏幕上,使用户能够看到最新的画面。t1~t5表示刷新时间间隔,在这些时段,主线程处于空闲状态,无需执行应用界面绘制和屏幕刷新业务。因此可以利用这一空闲的刷新时间间隔执行指定任务,保障主线程计算资源的充分利用。Referring to FIG. 2 , a schematic diagram of different processing periods of the main thread in the implementation of the present application is provided. Among them, T1-T5 represent screen refresh time nodes, and the system will execute application interface drawing and screen refresh services at these time nodes, and display the latest screen status of the current system on the screen, so that users can see the latest screen. t1-t5 represent refresh time intervals. During these periods, the main thread is in an idle state, and there is no need to perform application interface drawing and screen refreshing services. Therefore, this idle refresh time interval can be used to execute specified tasks to ensure full utilization of main thread computing resources.

基于此,本申请实施例在进行应用界面的卡顿预防时,通过监测系统时间,当系统时间处于刷新时间间隔的情况下,则调用主线程开始执行各个指定任务,即需要主线程处理的相关任务。进一步地,通过累计各个指定任务的任务耗时,将这个任务耗时比对设定的时间阈值,并在任务耗时超出设定时间阈值的情况下,停止指定任务的执行,将主线程的处理资源交给应用界面绘制和刷新任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,避免任务冲突导致界面刷新延迟。需要说明的是,该时间阈值根据上述刷新时间间隔设置,可以理解的是,累计的任务耗时只要不超过该刷新时间间隔,即可避免指定任务与应用界面绘制和刷新任务冲突,达到预防卡顿的效果。基于此,通过对应该刷新时间间隔设置该设定时间阈值,以精准控制指定任务的处理。Based on this, the embodiment of the present application monitors the system time when preventing freezing of the application interface. When the system time is within the refresh time interval, the main thread is invoked to start executing each specified task, that is, related tasks that need to be processed by the main thread. Task. Further, by accumulating the task time consumption of each specified task, the task time consumption is compared with the set time threshold, and when the task time consumption exceeds the set time threshold, the execution of the specified task is stopped, and the main thread's The processing resources are handed over to the application interface drawing and refreshing tasks, and the application interface drawing process is executed through the main thread at the screen refresh time node to avoid delays in interface refresh caused by task conflicts. It should be noted that the time threshold is set according to the above refresh time interval. It can be understood that as long as the accumulated task time does not exceed the refresh time interval, the conflict between the specified task and the application interface drawing and refresh task can be avoided to prevent stuck ton effect. Based on this, by setting the set time threshold corresponding to the refresh time interval, the processing of the specified task can be precisely controlled.

可选地,设定时间阈值等于刷新时间间隔或者小于刷新时间间隔设定值。一般而言,设定时间阈值等于刷新时间间隔,则可以充分利用该刷新时间间隔,使得主线程的计算资源能够尽可能的处理更多的指定任务。而将设定时间阈值设置为小于刷新时间间隔设定值,可以留出至少为设定值的时间供主线程缓冲,保障主线程可以准时地切换为应用界面绘制与刷新任务进行处理。Optionally, the set time threshold is equal to the refresh time interval or less than a set value of the refresh time interval. Generally speaking, if the time threshold is set equal to the refresh interval, the refresh interval can be fully utilized, so that the computing resources of the main thread can process as many specified tasks as possible. However, if the set time threshold is set to be less than the set value of the refresh interval, time at least the set value can be set aside for the main thread to buffer, ensuring that the main thread can switch to the application interface drawing and refreshing tasks on time for processing.

具体地,参照图3,基于上述时间间隔,指定任务处理流程包括:Specifically, referring to FIG. 3, based on the above-mentioned time interval, the specified task processing flow includes:

S1201、在当前指定任务执行完成后,统计刷新时间间隔内各个已执行完成的指定任务的任务耗时;S1201. After the execution of the current designated task is completed, count the task time consumption of each completed designated task within the refresh time interval;

S1202、将任务耗时比对设定时间阈值,在任务耗时达到设定时间阈值的情况下,停止执行下一个指定任务。S1202. Compare the task time consumption with the set time threshold, and stop executing the next specified task when the task time reaches the set time threshold.

示例性地,以手机的应用界面刷新为例,当前移动端手机系统的屏幕刷新频率一般是固定的。以60Hz为例,即每秒钟屏幕会刷新60次,也就是说系统每1秒种会执行60次应用界面绘制任务。由此可以得出每两次应用界面绘制任务的间隔约为0.0166秒(16.6毫秒),即该刷新时间间隔。利用该16.6毫秒的空闲间隔,应用程序的主线程可以在这个空闲间隔期执行一些自身业务相关的任务。Exemplarily, taking the refreshing of the application interface of the mobile phone as an example, the screen refreshing frequency of the current mobile phone system is generally fixed. Taking 60Hz as an example, the screen will be refreshed 60 times per second, which means that the system will execute 60 application interface drawing tasks every second. From this, it can be concluded that the interval between two drawing tasks of the application interface is about 0.0166 seconds (16.6 milliseconds), that is, the refresh time interval. Using the idle interval of 16.6 milliseconds, the main thread of the application program can perform some tasks related to its own business during this idle interval.

由于如果这些任务无法在这个空闲间隔内完成,就会导致下一次界面刷新延迟,从而使用户感受到画面卡顿。基于此,本申请实施例在刷新时间间隔内,对指定任务执行完成后,记录当前指定任务加上此前已完成的指定任务的累计消耗时长,即任务耗时。如果这个任务耗时已经达到了设定时间阈值,则会立刻停止执行新的指定任务,把主线程的资源空闲出来,将使用权转交给系统,让系统可以进行下一帧画面的绘制刷新,从而避免画面卡顿的发生。If these tasks cannot be completed within this idle interval, it will cause a delay in the next interface refresh, which makes the user feel that the screen is stuck. Based on this, in the embodiment of the present application, after the execution of the specified task is completed within the refresh time interval, the accumulated time spent on the current specified task plus the previously completed specified task is recorded, that is, the time spent on the task. If the time-consuming of this task has reached the set time threshold, it will immediately stop executing the new specified task, free up the resources of the main thread, and transfer the right to use to the system, so that the system can refresh the drawing of the next frame. In order to avoid the occurrence of screen freeze.

可以理解的是,由于在刷新时间间隔的空闲期间,应用程序占有主线程使用权限,应用程序需要在刷新时间间隔结束前完成自身的指定任务并且将主线程使用权转交给系统。但是业务代码往往是复杂不可控的,很容易在指定任务执行过程中超出了刷新时间间隔,使得系统没有及时获得主线程使用权,无法在正常的屏幕刷新时间节点去绘制刷新屏幕,从而导致屏幕画面卡在上一帧。对用户而言,看到的现象就是应用程序卡顿,体验不好。因此本方案通过在每一次指定任务完成后,累计刷新时间间隔内所有已完成指定任务的任务耗时,通过任务耗时和设定时间阈值的比对,实现主线程任务的精准控制和切换,避免屏幕刷新延迟。It can be understood that, since the application program occupies the main thread usage right during the idle period of the refresh time interval, the application program needs to complete its own designated tasks and transfer the main thread usage right to the system before the refresh time interval ends. However, the business code is often complex and uncontrollable, and it is easy to exceed the refresh interval during the execution of the specified task, so that the system does not obtain the right to use the main thread in time, and cannot draw and refresh the screen at the normal screen refresh time node, resulting in screen The screen is stuck at the previous frame. For users, what they see is that the application freezes and the experience is not good. Therefore, this solution achieves precise control and switching of main thread tasks by accumulating the task time consumption of all completed specified tasks within the time interval after each specified task is completed, and comparing the task time consumption with the set time threshold. Avoid screen refresh delays.

需要说明的是,由于指定任务是在执行完成后方才累计任务耗时的,如果将设定时间阈值设置为等于该刷新时间间隔,则可能出现前一个指定任务完成时,累计的任务耗时未达到设定时间阈值,此时继续执行下一个指定任务,累计的任务耗时超出刷新时间间隔而指定任务仍然未执行完成的情况。基于此,本申请实施例通过将设定时间阈值设置为小于刷新时间间隔设定值,以此可以针对任务耗时接近该刷新时间间隔的情况,及时停止指定任务的执行,避免上述累计的任务耗时超出刷新时间间隔而指定任务仍然未执行完成的情况。It should be noted that the time consumption of the task is accumulated after the execution of the specified task is completed. If the set time threshold is set equal to the refresh interval, it may happen that when the previous specified task is completed, the accumulated time consumption of the task does not When the set time threshold is reached, continue to execute the next specified task at this time, the accumulated task time exceeds the refresh interval and the specified task is still not completed. Based on this, the embodiment of the present application sets the set time threshold to be less than the set value of the refresh time interval, so that the execution of the specified task can be stopped in time when the task time is close to the refresh time interval, and the above-mentioned accumulated tasks can be avoided. The situation where the specified task is still not completed when the time-consuming exceeds the refresh interval.

在一个实施例中,参照图4,上述累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,还包括:In one embodiment, referring to FIG. 4 , the task time consumption of each specified task is accumulated above, and when the task time consumption reaches the set time threshold, the execution of the specified task is stopped, and further includes:

S1203、在执行当前指定任务之前,确定当前指定任务的预测耗时,根据刷新时间间隔内各个已执行完成的指定任务的累计耗时以及预测耗时确定任务耗时;S1203. Before executing the current designated task, determine the predicted time consumption of the current designated task, and determine the task time consumption according to the cumulative time consumption and the predicted time consumption of each completed designated task within the refresh time interval;

S1204、将任务耗时比对设定时间阈值,在任务耗时达到设定时间阈值的情况下,停止执行当前指定任务。S1204. Compare the task time consumption with the set time threshold, and stop executing the currently specified task when the task time reaches the set time threshold.

不同于上述在指定任务完成后方才累计任务耗时的方案,本申请实施例还可以对即将处理的指定任务进行单个任务的耗时预测,结合已完成的各个指定任务的实际累计耗时,确定当前准备执行的指定任务在执行完成后,此次刷新时间间隔内各个已执行完成的指定任务的任务耗时。通过指定任务耗时预测的方式,得到当前指定任务执行完成后,总任务耗时的大概的预测结果。可以理解的是,若此时任务耗时超过设定时间阈值,则如果指向当前指定任务,会导致主线程无法及时处理应用界面绘制与刷新任务,导致界面刷新延迟。因此需要停止当前指定任务的执行。反之,若此时任务耗时未超过设定时间阈值,则可以执行当前指定任务,充分利用主线程计算资源。Different from the above scheme of accumulating the time consumption of tasks after the specified tasks are completed, this embodiment of the present application can also predict the time consumption of a single task for the specified tasks to be processed, and determine After the specified task that is currently ready to be executed is completed, the task time of each specified task that has been executed within this refresh interval. By means of the specified task time-consuming prediction method, the approximate prediction result of the total task time consumption after the current specified task is executed is obtained. It is understandable that if the task takes longer than the set time threshold at this time, if it points to the currently specified task, the main thread will not be able to process the application interface drawing and refreshing tasks in time, resulting in a delay in interface refreshing. Therefore, it is necessary to stop the execution of the currently specified task. Conversely, if the task time consumption does not exceed the set time threshold at this time, the currently specified task can be executed to make full use of the main thread computing resources.

可选地,本申请实施例确定当前指定任务的预测耗时,包括:Optionally, the embodiment of the present application determines the predicted time consumption of the currently specified task, including:

获取当前指定任务的任务类型,基于当前指定任务的任务类型查询预构建的映射关系,获取当前指定任务的预测耗时,映射关系预先对应不同任务类型设置相应的预测耗时。Obtain the task type of the currently specified task, query the pre-built mapping relationship based on the task type of the currently specified task, and obtain the predicted time consumption of the currently specified task, and set the corresponding predicted time consumption for the mapping relationship in advance corresponding to different task types.

可以理解的是,对于不同任务类型的指定任务,其处理耗时会处于一个大致的范围内,则根据不同的任务类型,通过预先人工设定其合理的处理耗时,该处理耗时即为对应类型的指定任务的预测耗时。进而将不同类型的指定任务与其预测耗时绑定构建映射关系,后续根据已确定的任务类型即可通过查询映射关系确定其对应的预测耗时,进而根据预测耗时判断是否执行当前指定任务。It can be understood that, for the specified tasks of different task types, the processing time will be in a general range. According to different task types, by manually setting the reasonable processing time in advance, the processing time is The predicted time consumption of the specified task of the corresponding type. Furthermore, different types of specified tasks are bound to their predicted time-consuming to build a mapping relationship. Then, according to the determined task type, the corresponding predicted time-consuming can be determined by querying the mapping relationship, and then it is judged whether to execute the current specified task according to the predicted time-consuming.

在一个实施例中,根据主线程处理不同类型指定任务的预测耗时,系统还可以在系统时间进入刷新时间间隔时,先按照刷新时间间隔的总时长,预先布局当前刷新时间间隔内准备处理的各个指定任务。这些指定任务的预测耗时之和需小于等于该刷新时间间隔。通过预先确定刷新时间间隔内所有准备处理的指定任务,提供一个精准的任务处理预期,可以优化系统的任务调度效果,提升各个指定任务处理的稳定性和可靠性。In one embodiment, according to the predicted time consumption of the main thread processing different types of specified tasks, the system can also pre-layout tasks to be processed in the current refresh interval according to the total duration of the refresh interval when the system time enters the refresh interval. each assigned task. The sum of the predicted time consumption of these specified tasks must be less than or equal to the refresh interval. By pre-determining all specified tasks to be processed within the refresh interval and providing an accurate task processing expectation, the task scheduling effect of the system can be optimized, and the stability and reliability of each specified task processing can be improved.

在一个实施例中,还可以根据当前指定任务的具体任务内容等属性信息进行当前指定任务的耗时预测。本申请实施例对具体的耗时预测方案不做固定限制,在此不多赘述。In one embodiment, the time-consuming prediction of the currently designated task can also be performed according to attribute information such as the specific task content of the currently designated task. The embodiment of the present application does not impose fixed restrictions on specific time-consuming prediction schemes, and details are not repeated here.

此外,本申请实施例在执行当前指定任务之前,还包括:获取刷新时间间隔内各个已执行完成的指定任务的累计耗时,在累计耗时与设定时间阈值的时间差小于设定时长的情况下,停止执行指定任务。可以理解的是,如果将设定时间阈值设置为等于该刷新时间间隔,则可能出现前一个指定任务完成时,累计的任务耗时未达到设定时间阈值,此时继续执行下一个指定任务,累计的任务耗时超出刷新时间间隔而指定任务仍然未执行完成的情况。基于此,本申请通过在各个已执行完成的指定任务的累计耗时与设定时间阈值的时间差小于设定时长的情况下,提前终止执行指定任务,以此可以留出适当缓冲时间供主线程切换任务,准备进行屏幕绘制和刷新流程,保障屏幕绘制和刷新流畅性。In addition, before executing the current specified task, the embodiment of the present application also includes: obtaining the cumulative time consumption of each specified task that has been executed within the refresh interval, and when the time difference between the cumulative time consumption and the set time threshold is less than the set duration Next, stop executing the specified task. It can be understood that if the set time threshold is set equal to the refresh interval, it may happen that when the previous specified task is completed, the accumulated task time consumption does not reach the set time threshold, and the next specified task will continue to be executed at this time. The accumulated task time exceeds the refresh interval and the specified task is still not completed. Based on this, the application terminates the execution of the specified task in advance when the time difference between the cumulative time-consuming of each completed specified task and the set time threshold is less than the set time, so as to reserve an appropriate buffer time for the main thread Switch tasks, prepare for the screen drawing and refreshing process, and ensure the smoothness of screen drawing and refreshing.

示例性地,参照图5的步骤a1~a7,在系统启动后,通过上述应用界面卡顿预防方法,首先获取当前系统的屏幕刷新频率,通过该刷新频率确定刷新时间间隔。进而在确定系统进入屏幕刷新时间间隔后,系统会进入一个循环。参照图5,系统每次完成屏幕画面绘制和刷新后,就会通知应用程序进入空闲状态,即刷新时间间隔。进入刷新时间间隔后,系统就将主线程资源交给了应用程序,开始利用主线程执行指定任务。每次指定任务完成后,检测累计的任务耗时是否达到了设定时间阈值,如若任务耗时小于设定时间阈值,说明系统时间还没有到下一个屏幕绘制时间节点,系统还处于空闲间隔,可以继续执行下一个指定任务。此时流程来到a7,开始执行下一个指定任务。下一个指定任务执行完成后,记录本次任务消耗的时间,更新已完成指定任务的累计耗时。再次进入到a4步骤,重新判断累计的任务耗时是否达到了设定时间阈值。Exemplarily, referring to steps a1 to a7 in FIG. 5 , after the system is started, the screen refresh frequency of the current system is first obtained through the above-mentioned application interface freeze prevention method, and the refresh time interval is determined based on the refresh frequency. Then, after it is determined that the system enters the screen refresh time interval, the system enters a loop. Referring to FIG. 5 , after the system finishes drawing and refreshing the screen picture each time, it will notify the application program to enter the idle state, that is, the refresh time interval. After entering the refresh interval, the system will hand over the main thread resources to the application program, and start to use the main thread to execute the specified tasks. After each specified task is completed, check whether the accumulated task time has reached the set time threshold. If the task time is less than the set time threshold, it means that the system time has not reached the next screen drawing time node, and the system is still in the idle interval. You can proceed to the next specified task. At this time, the flow comes to a7, and the next specified task is started. After the execution of the next specified task is completed, record the time consumed by this task, and update the cumulative time spent on the completed specified task. Go to step a4 again, and re-judge whether the accumulated task time has reached the set time threshold.

以此类推,如果在a4步骤检测到累计的任务耗时达到了设定时间阈值,说明当前刷新时间间隔的时间已经耗尽,系统需要马上进行屏幕画面绘制刷新工作。此时流程进入到a5,影响程序停止执行新的指定任务,并将主线程使用权转交给系统。流程到a6,系统则在预期的屏幕刷新时间节点上进行屏幕绘制刷新工作,屏幕画面如期完成绘制刷新,用户看到的画面就不会出现卡顿现象了。同样地,系统完成屏幕绘制刷新工作后,再次进入刷新时间间隔的空闲状态,主线程使用权再次交给应用程序,基于上述应用界面卡顿预防方法,循环进行应用界面的卡顿预防操作。By analogy, if it is detected in step a4 that the accumulated task time consumption has reached the set time threshold, it means that the current refresh time interval has been exhausted, and the system needs to immediately refresh the screen image. At this time, the process enters a5, and the affected program stops executing new specified tasks, and transfers the right to use the main thread to the system. When the process reaches a6, the system will refresh the screen at the expected screen refresh time node, and the screen image will be refreshed as scheduled, and the image seen by the user will not appear stuck. Similarly, after the system finishes drawing and refreshing the screen, it enters the idle state of the refresh time interval again, and the right to use the main thread is handed over to the application program again. Based on the above-mentioned application interface freeze prevention method, the application interface freeze prevention operation is cyclically performed.

整个循环过程中通过不断地检测每个刷新时间间隔的指定任务是否耗时过多,及时发现可能出现卡顿的隐患,从而主动释放主线程的使用权,让系统在屏幕刷新时间节点能正常获取主线程使用权,执行屏幕绘制与刷新任务。以此在应用程序运行过程中不断地检测预判卡顿是否即将发生,及时释放主线程资源,从而避免卡顿,一劳永逸地解决卡顿问题。During the whole cycle, by continuously checking whether the specified task of each refresh time interval takes too much time, timely discovering the hidden danger of jamming may occur, so as to actively release the right to use the main thread, so that the system can normally obtain the refresh time node of the screen The right to use the main thread to perform screen drawing and refreshing tasks. In this way, during the running process of the application, it is continuously detected whether the predicted freeze is about to occur, and the resources of the main thread are released in time, so as to avoid the freeze and solve the freeze problem once and for all.

上述,通过获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;进而累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。采用上述技术手段,通过在屏幕的刷新时间间隔使用主线程处理相关任务,并累计任务耗时,在任务耗时达到设定时间阈值,接近屏幕刷新时间节点的情况下,停止执行指定任务,以让出主线程的处理资源用于应用界面的绘制与刷新,确保应用界面按照正常的刷新频率进行刷新,进而避免屏幕卡顿的情况。提升应用界面显示的流畅性,提升用户的使用体验。并且,通过在刷新时间间隔尽可能地处理指定任务,可以充分利用主线程的处理资源,优化主线程技术资源的利用。As mentioned above, by obtaining the refresh time interval of the screen, when the system time is within the refresh time interval, each specified task is executed sequentially through the main thread; then the task time consumption of each specified task is accumulated, and when the task time consumption reaches the set time threshold In this case, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node, and the time threshold is set according to the refresh interval. Using the above technical means, by using the main thread to process related tasks at the refresh time interval of the screen, and accumulating the task time consumption, when the task time consumption reaches the set time threshold and is close to the screen refresh time node, stop executing the specified task, so as to Let the processing resources of the main thread be used for drawing and refreshing the application interface to ensure that the application interface is refreshed according to the normal refresh frequency, thereby avoiding the situation of screen freeze. Improve the fluency of the application interface display and improve the user experience. Moreover, by processing the specified tasks as much as possible at the refresh time interval, the processing resources of the main thread can be fully utilized, and the utilization of technical resources of the main thread can be optimized.

在上述实施例的基础上,图6为本申请提供的一种应用界面卡顿预防系统的结构示意图。参考图6,本实施例提供的应用界面卡顿预防系统具体包括:执行模块21和预防模块22。On the basis of the above-mentioned embodiments, FIG. 6 is a schematic structural diagram of an application interface freeze prevention system provided by the present application. Referring to FIG. 6 , the application interface freeze prevention system provided by this embodiment specifically includes: an execution module 21 and a prevention module 22 .

其中,执行模块21配置为获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;Wherein, the execution module 21 is configured to obtain the refresh time interval of the screen, and when the system time is within the refresh time interval, each specified task is sequentially executed through the main thread;

预防模块22配置为累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。The prevention module 22 is configured to accumulate the task time consumption of each specified task. When the task time consumption reaches the set time threshold, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node. The time threshold is based on Refresh interval settings.

具体地,累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,包括:Specifically, the task time consumption of each specified task is accumulated, and when the task time consumption reaches the set time threshold, the execution of the specified task is stopped, including:

在当前指定任务执行完成后,统计刷新时间间隔内各个已执行完成的指定任务的任务耗时;After the execution of the current specified task is completed, the task time consumption of each specified task that has been executed within the statistical refresh interval;

将任务耗时比对设定时间阈值,在任务耗时达到设定时间阈值的情况下,停止执行下一个指定任务。其中,设定时间阈值等于刷新时间间隔或者小于刷新时间间隔设定值。Compare the task time consumption with the set time threshold, and stop executing the next specified task when the task time reaches the set time threshold. Wherein, the set time threshold is equal to the refresh time interval or less than a set value of the refresh time interval.

具体地,累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,还包括:Specifically, accumulating the task time consumption of each specified task, and stopping the execution of the specified task when the task time consumption reaches the set time threshold, also includes:

在执行当前指定任务之前,确定当前指定任务的预测耗时,根据刷新时间间隔内各个已执行完成的指定任务的累计耗时以及预测耗时确定任务耗时;Before executing the currently specified task, determine the predicted time consumption of the current specified task, and determine the task time consumption according to the cumulative time consumption and predicted time consumption of each completed specified task within the refresh interval;

将任务耗时比对设定时间阈值,在任务耗时达到设定时间阈值的情况下,停止执行当前指定任务。Compare the task time consumption with the set time threshold, and stop executing the currently specified task when the task time reaches the set time threshold.

具体地,确定当前指定任务的预测耗时,包括:Specifically, determine the predicted time consumption of the currently specified task, including:

获取当前指定任务的任务类型,基于当前指定任务的任务类型查询预构建的映射关系,获取当前指定任务的预测耗时,映射关系预先对应不同任务类型设置相应的预测耗时。Obtain the task type of the currently specified task, query the pre-built mapping relationship based on the task type of the currently specified task, and obtain the predicted time consumption of the currently specified task, and set the corresponding predicted time consumption for the mapping relationship in advance corresponding to different task types.

具体地,在执行当前指定任务之前,还包括:Specifically, before executing the currently specified task, it also includes:

获取刷新时间间隔内各个已执行完成的指定任务的累计耗时,在累计耗时与设定时间阈值的时间差小于设定时长的情况下,停止执行指定任务。Acquire the cumulative time consumption of each specified task that has been executed within the refresh interval, and stop executing the specified task if the time difference between the cumulative time consumption and the set time threshold is less than the set duration.

上述,通过获取屏幕的刷新时间间隔,在系统时间处于刷新时间间隔的情况下,通过主线程依次执行各个指定任务;进而累计各个指定任务的任务耗时,在任务耗时达到设定时间阈值的情况下,停止执行指定任务,并在屏幕刷新时间节点通过主线程执行应用界面绘制流程,时间阈值根据刷新时间间隔设置。采用上述技术手段,通过在屏幕的刷新时间间隔使用主线程处理相关任务,并累计任务耗时,在任务耗时达到设定时间阈值,接近屏幕刷新时间节点的情况下,停止执行指定任务,以让出主线程的处理资源用于应用界面的绘制与刷新,确保应用界面按照正常的刷新频率进行刷新,进而避免屏幕卡顿的情况。提升应用界面显示的流畅性,提升用户的使用体验。并且,通过在刷新时间间隔尽可能地处理指定任务,可以充分利用主线程的处理资源,优化主线程技术资源的利用。As mentioned above, by obtaining the refresh time interval of the screen, when the system time is within the refresh time interval, each specified task is executed sequentially through the main thread; then the task time consumption of each specified task is accumulated, and when the task time consumption reaches the set time threshold In this case, stop executing the specified task, and execute the application interface drawing process through the main thread at the screen refresh time node, and the time threshold is set according to the refresh interval. Using the above technical means, by using the main thread to process related tasks at the refresh time interval of the screen, and accumulating the task time consumption, when the task time consumption reaches the set time threshold and is close to the screen refresh time node, stop executing the specified task, so as to Let the processing resources of the main thread be used for drawing and refreshing the application interface to ensure that the application interface is refreshed according to the normal refresh frequency, thereby avoiding the situation of screen freeze. Improve the fluency of the application interface display and improve the user experience. Moreover, by processing the specified tasks as much as possible at the refresh time interval, the processing resources of the main thread can be fully utilized, and the utilization of technical resources of the main thread can be optimized.

本申请实施例提供的应用界面卡顿预防系统可以配置为执行上述实施例提供的应用界面卡顿预防方法,具备相应的功能和有益效果。The application interface freeze prevention system provided in the embodiments of the present application can be configured to execute the application interface freeze prevention method provided in the above embodiments, and has corresponding functions and beneficial effects.

在上述实际上例的基础上,本申请实施例还提供了一种应用界面卡顿预防设备,参照图7,该应用界面卡顿预防设备包括:处理器31、存储器32、通信模块33、输入装置34及输出装置35。存储器32作为一种计算机可读存储介质,可配置为存储软件程序、计算机可执行程序以及模块,如本申请任意实施例所述的应用界面卡顿预防方法对应的程序指令/模块(例如,应用界面卡顿预防系统中的执行模块和预防模块)。通信模块33配置为进行数据传输。处理器通过运行存储在存储器中的软件程序、指令以及模块,从而执行设备的各种功能应用以及数据处理,即实现上述的应用界面卡顿预防方法。输入装置34可配置为接收输入的数字或字符信息,以及产生与设备的用户设置以及功能控制有关的键信号输入。输出装置35可包括显示屏等显示设备。上述提供的应用界面卡顿预防设备可配置为执行上述实施例提供的应用界面卡顿预防方法,具备相应的功能和有益效果。On the basis of the above practical examples, the embodiment of the present application also provides an application interface freeze prevention device. Referring to FIG. 7, the application interface freeze prevention device includes: a processor 31, a memory 32, a communication module 33, an input device 34 and output device 35 . The memory 32, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs and modules, such as program instructions/modules corresponding to the application interface freeze prevention method described in any embodiment of the present application (for example, application Execution module and prevention module in the interface freeze prevention system). The communication module 33 is configured to perform data transmission. The processor executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory, that is, realizes the above-mentioned method for preventing freezing of the application interface. The input device 34 may be configured to receive input of numeric or character information, and to generate key signal input related to user settings and function control of the device. The output device 35 may include a display device such as a display screen. The application interface freeze prevention device provided above can be configured to execute the application interface freeze prevention method provided in the above embodiment, and has corresponding functions and beneficial effects.

在上述实施例的基础上,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令在由计算机处理器执行时配置为执行一种应用界面卡顿预防方法,存储介质可以是任何的各种类型的存储器设备或存储设备。当然,本申请实施例所提供的一种计算机可读存储介质,其计算机可执行指令不限于如上所述的应用界面卡顿预防方法,还可以执行本申请任意实施例所提供的应用界面卡顿预防方法中的相关操作。On the basis of the above-mentioned embodiments, the embodiments of the present application also provide a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a computer processor It is configured to implement a method for preventing application interface freeze, and the storage medium may be any storage device or storage device of various types. Of course, the computer-readable storage medium provided in the embodiments of the present application, its computer-executable instructions are not limited to the method for preventing application interface freezing as described above, and can also execute the application interface freezing provided in any embodiment of the application Related actions in the prevention method.

在上述实施例的基础上,本申请实施例还提供一种计算机程序产品,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机程序产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备、移动终端或其中的处理器执行本申请各个实施例所述应用界面卡顿预防方法的全部或部分步骤。On the basis of the above-mentioned embodiments, the embodiments of the present application also provide a computer program product. The technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be implemented as a software product It is embodied in the form that the computer program product is stored in a storage medium, and includes several instructions to enable a computer device, a mobile terminal, or a processor therein to execute all of the methods for preventing application interface freezing in various embodiments of the present application. or partial steps.

Claims (10)

1. An application interface jamming prevention method, comprising:
acquiring a refreshing time interval of a screen, and sequentially executing each appointed task through a main thread under the condition that the system time is in the refreshing time interval;
and accumulating the task time consumption of each appointed task, stopping executing the appointed task under the condition that the task time consumption reaches a set time threshold, and executing an application interface drawing process through the main thread at a screen refreshing time node, wherein the time threshold is set according to the refreshing time interval.
2. The method for preventing application interface jamming according to claim 1, wherein accumulating task time consumption of each of the specified tasks, and stopping execution of the specified tasks if the task time consumption reaches a set time threshold, comprises:
after the execution of the current appointed task is completed, counting the time consumption of each executed appointed task in the refreshing time interval;
comparing the task time consumption with the set time threshold, and stopping executing the next designated task when the task time consumption reaches the set time threshold.
3. The application interface jamming prevention method according to any one of claims 1-2, wherein the set time threshold is equal to the refresh time interval or less than the refresh time interval set point.
4. The application interface jamming prevention method according to claim 1, wherein the accumulating task time consumption of each of the specified tasks stops executing the specified tasks if the task time consumption reaches a set time threshold, further comprising:
before executing the current specified task, determining the predicted time consumption of the current specified task, and determining the task time consumption according to the accumulated time consumption of each executed specified task and the predicted time consumption in the refresh time interval;
comparing the task time consumption with the set time threshold, and stopping executing the current designated task when the task time consumption reaches the set time threshold.
5. The application interface jam prevention method of claim 4, wherein said determining the predicted time consumption of the current specified task includes:
acquiring the task type of the current appointed task, inquiring a pre-constructed mapping relation based on the task type of the current appointed task, and acquiring the predicted time consumption of the current appointed task, wherein the mapping relation is used for setting corresponding predicted time consumption in advance corresponding to different task types.
6. The application interface jam prevention method of claim 4, further comprising, prior to executing the current specified task:
and acquiring the accumulated time consumption of each executed appointed task in the refreshing time interval, and stopping executing the appointed task when the time difference between the accumulated time consumption and the set time threshold is smaller than the set time length.
7. An application interface jamming prevention system, comprising:
the execution module is configured to acquire a refreshing time interval of the screen, and sequentially execute each appointed task through the main thread under the condition that the system time is in the refreshing time interval;
and the prevention module is configured to accumulate the task time consumption of each designated task, stop executing the designated task when the task time consumption reaches a set time threshold, and execute an application interface drawing process through the main thread at a screen refreshing time node, wherein the time threshold is set according to the refreshing time interval.
8. An application interface jamming prevention device, comprising:
a memory and one or more processors;
the memory is configured to store one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the application interface jam-prevention method of any of claims 1-6.
9. A computer readable storage medium storing computer executable instructions which, when executed by a computer processor, are configured to perform the application interface jam prevention method of any of claims 1-6.
10. A computer program product comprising instructions which, when executed on a computer or processor, cause the computer or processor to perform the application interface jam prevention method of any of claims 1-6.
CN202310227042.8A 2023-03-09 2023-03-09 A method, system, device, and storage medium for preventing freezing of an application interface Pending CN116225357A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310227042.8A CN116225357A (en) 2023-03-09 2023-03-09 A method, system, device, and storage medium for preventing freezing of an application interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310227042.8A CN116225357A (en) 2023-03-09 2023-03-09 A method, system, device, and storage medium for preventing freezing of an application interface

Publications (1)

Publication Number Publication Date
CN116225357A true CN116225357A (en) 2023-06-06

Family

ID=86576648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310227042.8A Pending CN116225357A (en) 2023-03-09 2023-03-09 A method, system, device, and storage medium for preventing freezing of an application interface

Country Status (1)

Country Link
CN (1) CN116225357A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060132817A1 (en) * 2003-10-24 2006-06-22 Microsoft Corporation Synchronization of plugins
WO2018161578A1 (en) * 2017-03-10 2018-09-13 广东欧珀移动通信有限公司 Method, device, storage medium, and electronic apparatus for dynamically adjusting screen refresh rate
CN109861966A (en) * 2018-12-06 2019-06-07 北京达佳互联信息技术有限公司 Method, apparatus, terminal and the storage medium of processing status event
CN111190590A (en) * 2020-01-07 2020-05-22 广州虎牙科技有限公司 Catton optimization method, device, terminal and computer readable storage medium
CN111399930A (en) * 2018-12-28 2020-07-10 广州市百果园信息技术有限公司 Page starting method, device, equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060132817A1 (en) * 2003-10-24 2006-06-22 Microsoft Corporation Synchronization of plugins
WO2018161578A1 (en) * 2017-03-10 2018-09-13 广东欧珀移动通信有限公司 Method, device, storage medium, and electronic apparatus for dynamically adjusting screen refresh rate
CN109861966A (en) * 2018-12-06 2019-06-07 北京达佳互联信息技术有限公司 Method, apparatus, terminal and the storage medium of processing status event
CN111399930A (en) * 2018-12-28 2020-07-10 广州市百果园信息技术有限公司 Page starting method, device, equipment and storage medium
CN111190590A (en) * 2020-01-07 2020-05-22 广州虎牙科技有限公司 Catton optimization method, device, terminal and computer readable storage medium

Similar Documents

Publication Publication Date Title
US9501319B2 (en) Method and apparatus for scheduling blocking tasks
US9201693B2 (en) Quota-based resource management
WO2019174474A1 (en) Lag information acquisition method and device and terminal
US20210208935A1 (en) Method for Scheduling Multi-Core Processor, Terminal, and Storage Medium
CN111221643B (en) Task processing method and task processing device
CN107273278B (en) Caton determination method, device and terminal
US8782674B2 (en) Wait on address synchronization interface
US11455024B2 (en) Idle state estimation by scheduler
US20120159258A1 (en) Debugging in data parallel computations
CN116048757A (en) Task processing method, device, electronic equipment and storage medium
CN112463370B (en) Task execution method, device and readable storage medium
CN110704187A (en) Method and device for adjusting system resources and readable storage medium
CN113190427A (en) Caton monitoring method and device, electronic equipment and storage medium
CN116225357A (en) A method, system, device, and storage medium for preventing freezing of an application interface
JP2005228301A (en) System and method for implicitness-configurable synchronization of message queue-based user interface automation
CN113687942A (en) Detection method and device and electronic equipment
CN114896013B (en) Page loading time length determining method and device, electronic equipment and storage medium
CN112650465B (en) Terminal control method, device, terminal and storage medium
WO2025001675A1 (en) Service message processing method and system based on mobile live broadcast
CN113918350B (en) Garbage collection method, garbage collection device, storage medium and electronic equipment
CN113220554B (en) Method and apparatus for testing performance of program code
CN119248354B (en) A control method for a graphics processor, an electronic device, and a storage medium.
CN101295269B (en) A Method of Component Interaction Synchronization Based on Transaction
CN112114967A (en) GPU resource reservation method based on service priority
CN113778624B (en) Object processing method and device, intelligent terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination