[go: up one dir, main page]

CN113391847B - Application startup optimization method and device - Google Patents

Application startup optimization method and device Download PDF

Info

Publication number
CN113391847B
CN113391847B CN202010163723.9A CN202010163723A CN113391847B CN 113391847 B CN113391847 B CN 113391847B CN 202010163723 A CN202010163723 A CN 202010163723A CN 113391847 B CN113391847 B CN 113391847B
Authority
CN
China
Prior art keywords
loading
view controller
application
view
started
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.)
Active
Application number
CN202010163723.9A
Other languages
Chinese (zh)
Other versions
CN113391847A (en
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010163723.9A priority Critical patent/CN113391847B/en
Publication of CN113391847A publication Critical patent/CN113391847A/en
Application granted granted Critical
Publication of CN113391847B publication Critical patent/CN113391847B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

本发明公开了应用程序的启动优化方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:根据应用程序启动请求,获取待启动应用程序对应的至少一个视图控制器;对至少一个视图控制器进行加载拦截,利用待启动应用程序对应的加载权限文件,对至少一个视图控制器进行加载预处理;根据加载预处理结果,加载至少一个视图控制器对应的页面元素。该实施方式能够达到对每个视图控制器分时加载的效果,避免了现有技术中所有视图控制器同时加载造成的启动时间长的问题,减少了应用程序的启动时间,提升了用户体验。

The present invention discloses an application startup optimization method and device, and relates to the field of computer technology. A specific implementation of the method includes: according to an application startup request, obtaining at least one view controller corresponding to the application to be started; intercepting the loading of at least one view controller, using the loading permission file corresponding to the application to be started, and pre-processing the loading of at least one view controller; according to the loading pre-processing result, loading the page element corresponding to at least one view controller. This implementation can achieve the effect of time-sharing loading of each view controller, avoiding the problem of long startup time caused by loading all view controllers at the same time in the prior art, reducing the startup time of the application and improving the user experience.

Description

Application program starting optimization method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for optimizing startup of an application program.
Background
The starting time of the application program refers to the time from when the user clicks on the icon of the application program to when the application program is completely displayed. Typically, the starting speed of an application determines the first impression of the user on the application, so the starting speed of an application is an important criterion for evaluating the quality of an application, for example, if an application can complete starting within 0.25s, it is important to say how to optimize the starting speed of the application if the starting performance of the application is good.
The factors for determining the starting speed of the application program are the size of the executable file and the optimization of the completion of the whole display of the page after the executable file is loaded. The existing scheme is mainly aimed at the optimization scheme before the main function (such as main function), namely optimizing the executable file, such as deleting useless codes, integrating similar codes and avoiding time-consuming operations in load functions (i.e. the method called by the system after the class is loaded in the starting process).
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art, namely, for an application program, the amount of codes which can be deleted is relatively small, most business codes are optimized, and the large business requirements also determine that the executable files of the application program cannot be reduced to an ideal range.
Disclosure of Invention
In view of the above, the embodiment of the invention provides a method and a device for optimizing the starting of an application program, which can avoid the problem of long starting time caused by simultaneous loading of all view controllers in the prior art, reduce the starting time of the application program and promote user experience.
In order to achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a startup optimization method for an application.
The method for optimizing the starting of the application program comprises the steps of obtaining at least one view controller corresponding to an application program to be started according to an application program starting request, loading and intercepting the at least one view controller, loading and preprocessing the at least one view controller by using a loading authority file corresponding to the application program to be started, and loading page elements corresponding to the at least one view controller according to a loading preprocessing result.
Optionally, the loading interception of the at least one view controller includes invoking a preset code instead of invoking a loading code corresponding to the at least one view controller when the at least one view controller is loaded, so as to complete the loading interception of the at least one view controller.
Optionally, the loading preprocessing of the at least one view controller by using the loading authority file corresponding to the application program to be started includes screening the view controller needing to be loaded in a delayed manner and the view controller needing to be directly loaded from the at least one view controller according to the loading authority file corresponding to the application program to be started, and acquiring the delayed loading time of the view controller needing to be loaded in a delayed manner.
Optionally, the loading the page element corresponding to the at least one view controller according to the loading preprocessing result includes directly calling a loading code corresponding to the view controller to be directly loaded to complete loading of the page element corresponding to the view controller to be directly loaded, and calling a loading code corresponding to the view controller to be delayed loaded according to the delayed loading time of the view controller to be delayed loaded to complete loading of the page element corresponding to the view controller to be delayed loaded.
Optionally, before the loading pretreatment is performed on the at least one view controller by using the loading permission file corresponding to the application program to be started, the method further comprises the steps of loading the loading permission file corresponding to the application program to be started into a memory, and after loading the page element corresponding to the at least one view controller according to the loading pretreatment result, removing the loading permission file corresponding to the application program to be started from the memory.
Optionally, before the loading preprocessing is performed on the at least one view controller by using the loading authority file corresponding to the application program to be started, the method further comprises creating the loading authority file corresponding to the application program to be started in advance.
In order to achieve the above object, according to a second aspect of the embodiments of the present invention, there is provided a start-up optimization apparatus for an application.
The device for optimizing the starting of the application program comprises an acquisition module, a processing module and a loading module, wherein the acquisition module is used for acquiring at least one view controller corresponding to the application program to be started according to an application program starting request, the processing module is used for loading and intercepting the at least one view controller, loading pretreatment is carried out on the at least one view controller by utilizing a loading authority file corresponding to the application program to be started, and the loading module is used for loading page elements corresponding to the at least one view controller according to a loading pretreatment result.
Optionally, the processing module is further configured to call a preset code to replace a loading code corresponding to the at least one view controller when the at least one view controller is loaded, so as to complete loading interception of the at least one view controller.
Optionally, the processing module is further configured to obtain, from the at least one view controller, a view controller to be delayed for loading and a view controller to be directly loaded from the at least one view controller according to a loading permission file corresponding to the application program to be started, and obtain a delayed loading time of the view controller to be delayed for loading.
Optionally, the loading module is further configured to directly call a loading code corresponding to the view controller to be directly loaded to complete loading of a page element corresponding to the view controller to be directly loaded, and call the loading code corresponding to the view controller to be delayed loaded according to the delayed loading time of the view controller to be delayed loaded to complete loading of the page element corresponding to the view controller to be delayed loaded.
Optionally, the processing module is further configured to load the loading right file corresponding to the application program to be started into the memory, and remove the loading right file corresponding to the application program to be started from the memory.
Optionally, the processing module is further configured to create a loading authority file corresponding to the application program to be started in advance.
To achieve the above object, according to a third aspect of the embodiments of the present invention, there is provided an electronic apparatus.
The electronic equipment comprises one or more processors and a storage device, wherein the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the starting optimization method of the application program.
To achieve the above object, according to a fourth aspect of the embodiments of the present invention, there is provided a computer-readable medium.
A computer readable medium of an embodiment of the present invention has stored thereon a computer program which, when executed by a processor, implements a method for start-up optimization of an application of an embodiment of the present invention.
The embodiment of the invention has the advantages that the method has the advantages that each view controller of the application program to be started is loaded and intercepted, and then each view controller is loaded and preprocessed by the aid of the pre-created loading authority file, so that each view controller can be loaded according to a loading preprocessing result, the effect of time-sharing loading of each view controller is achieved, the problem of long starting time caused by simultaneous loading of all view controllers in the prior art is avoided, the starting time of the application program is shortened, and user experience is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method for start-up optimization of an application according to an embodiment of the invention;
FIG. 2 is a schematic diagram of the main flow of a startup optimization method of an application according to an embodiment of the present invention;
FIG. 3 is a loading schematic diagram of a view controller according to an embodiment of the invention;
FIG. 4 is a schematic diagram of the main modules of a start-up optimization device of an application according to an embodiment of the invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
At present, application program development is more focused on user experience, mainly on using application programs which enable users to smooth flow and on enabling users to quickly start the application programs. The smoothness and smoothness during use depend on many factors, such as network, picture loading, etc., which require a developer to write robust codes, so the starting speed of an application is an important criterion for evaluating whether an application is good or bad, for example, if an application can complete starting within 0.25s, it is important to say that the starting performance of the application is good, and how to optimize the starting speed of the application.
The starting time of the application program refers to the time from when the user clicks on the icon of the application program to when the application program is completely displayed. The factors for determining the starting speed of the application program are the size of the executable file and the optimization of the completion of the whole display of the page after the executable file is loaded. The existing scheme mainly optimizes the executable files, but for the application program, the amount of codes which can be deleted is small, most of service codes are already optimized, and the large amount of service requirements also determine that the executable files of the application program cannot be reduced to an ideal range.
In order to solve the above problems, the embodiments of the present invention provide a method for optimizing the start of an application, which can reduce the start time of the application and give a user a feeling of one second start. Fig. 1 is a schematic diagram of main steps of a start-up optimization method of an application according to an embodiment of the present invention. As shown in fig. 1, the main steps of the method for optimizing the start of the application program according to the embodiment of the present invention may include:
step S101, according to an application program starting request, at least one view controller corresponding to an application program to be started is obtained;
Step S102, loading interception is carried out on at least one view controller, and loading preprocessing is carried out on the at least one view controller by utilizing a loading authority file corresponding to an application program to be started;
step S103, loading at least one page element corresponding to the view controller according to the loading preprocessing result.
In the method for optimizing the starting of the application program in the embodiment of the invention, in the process of receiving the application program starting request, the application program to be started is determined, for example, if a user clicks an icon of a certain application program, the application program to be started can be determined as the application program. After determining the application program to be started, at least one view controller corresponding to the application program to be started can be obtained. The view controller refers to a controller capable of displaying pages, an application program can comprise a plurality of pages, each page is equivalent to a controller, and since the application program is started and is equivalent to the page corresponding to the display application program, the view controller corresponding to the application program can be obtained after the application program to be started is determined.
In the starting method of the application program in the prior art, after the view controller of the application program to be started is acquired, the view controller is directly loaded, so that the situation that a plurality of view controllers need to be loaded simultaneously occurs, but a user opens an application program, and one page of the application program is presented to the user, so that other pages do not need to be loaded for the first time, that is, one view controller of the application program is loaded, and all view controllers of the application program do not need to be loaded. In summary, in the prior art, loading all view controllers corresponding to the application program at the same time increases the starting time of the application program, so in step S102, the acquired at least one view controller corresponding to the application program to be started is loaded and intercepted, and then the loading preprocessing is performed on the at least one view controller by using the loading authority file corresponding to the application program to be started. In the embodiment of the invention, the Hook function can be utilized to intercept and load, the Hook function is called as a Hook function, the Hook program captures the message before the system does not call the function, the Hook function obtains control right first, and the Hook function can process (change) the execution behavior of the function and can forcedly finish the transfer of the message. In short, the program of the system is pulled out to become the code segment executed by the user. In the embodiment of the invention, before loading at least one view controller, the at least one view controller is loaded and intercepted by using the Hook technology, namely, before calling the page loading code of the view controller, the Hook program captures the message, the Hook function can obtain the control right, and the Hook function can process (change) the loading behavior of the view controller, and at this time, the loading preprocessing can be performed on the at least one view controller by using the loading authority file corresponding to the application program to be started. The loading authority file refers to an authority control file of the view controller, and may include loading time of the view controller.
After the view controllers are subjected to loading preprocessing, namely the loading time of each view controller corresponding to the application program to be started is obtained, page elements corresponding to each view controller can be loaded according to the loading time of each view controller, so that the starting of the application program to be started is completed.
For example, for ios system, the code executing process dynamically decides the call of the function through the running time in the running process of the application program, so that the dynamic characteristic of the application program development language can be utilized to dynamically change the corresponding relation (Method Swizzle) between SEL (method number) and IMP (method implementation), thus intercepting the necessary flow of loading the view controller in the starting process of the application program, respectively setting the loading time of the view controller, and carrying out delayed loading on the view controller which is not immediately loaded, namely carrying out delayed display on the page which does not need to be immediately displayed to the user, thereby realizing that only the page which needs to be immediately displayed is loaded in the starting process of the application program, and other background pages are delayed to be loaded, and the starting of the application program can be optimized by the existing code without any modification.
In the method for optimizing the starting of the application program, which is disclosed by the embodiment of the invention, each view controller of the application program to be started is loaded and intercepted by using the Hook technology, and then each view controller is loaded and preprocessed by using the pre-created loading authority file, so that each view controller can be loaded according to the loading preprocessing result, the effect of time-sharing loading of each view controller is achieved, the problem of long starting time caused by simultaneous loading of all view controllers in the prior art is avoided, the starting time of the application program is reduced, and the user experience is improved.
In the method for optimizing the starting of the application program, which is disclosed by the embodiment of the invention, the loading interception of the video controller is an important part. The method for intercepting the loading of the at least one view controller can comprise the steps of obtaining control authority of a life cycle method corresponding to the at least one view controller by using Hook technology so as to complete the intercepting of the loading of the at least one view controller. Each view controller represents a page so that a page has its life cycle, e.g., creation, completion, disappearance, etc. of a view. According to the embodiment of the invention, the control authority of the life cycle method of each view controller can be controlled by using the Hook technology, so that the loading interception of each view controller can be completed.
In the embodiment of the invention, the control authority of the lifecycle method corresponding to the at least one view controller is obtained by using the Hook technology, and the method can comprise the step of calling a preset code to replace a loading code corresponding to the at least one view controller when the at least one view controller is loaded. That is to say, the preset code is used for replacing the loading code corresponding to the at least one view controller, so that when the loading code corresponding to the at least one view controller is called, the preset code is called for replacement. For example, when the Hook technology is used to control the loading of the view controller, the loadView method and the viewDidLoad method are called, so that the correct function is not called when the page corresponding to the view controller is loaded, but the preset code is called, and thus, special processing can be performed on the view controller which does not need to be immediately displayed, namely, loading preprocessing is performed on the view controller.
The loadView method is called when the view controller starts loading, and is mainly used for creating views managed by the controller, but if any other initialization operation is to be performed on the views, the method should be placed in the viewDidLoad method, and the method is not directly called, and only when the view controller requests the corresponding view attribute and cannot acquire the view object (self. View=nil), the method is called to load or create the corresponding view. Typically, during the loading of a view, if the view controller has an associated nib file, the method will load the view directly from the nib file. If the view controller does not have an associated nib file, the method creates a blank object. The viewDidLoad method is called after the view creation is completed and before the screen appears, i.e. the view controller loads its view hierarchy into memory, whether it is loaded from the nib file or using code in the loadView method, and only once in a lifecycle, and can also be used to perform the view controller-related one-time initialization operation, but without adding any initialization information about the view geometry in the method. This is because when viewDidLoad is invoked, the view controller has not yet been shown in the interface, the boundaries of the view have not yet been determined, and if it is made to run on a different device, or in a different place, or rotated, etc., it may not appear in a predetermined location when it is presented on the screen.
In the method for optimizing the starting of the application program, after the video controller is loaded and intercepted, the video controller can be loaded and preprocessed, which is an important part of the method for optimizing the starting of the application program. Therefore, before the loading preprocessing is performed on at least one view controller by using the loading authority file corresponding to the application program to be started, the loading authority file corresponding to the application program to be started can be created in advance. The created loading authority file is used for describing which view controllers need special processing, namely, describing which view controllers need delayed loading, so that which view controllers need immediate loading can be judged according to the loading authority file, that is, pages needing immediate display are directly determined by using the loading authority file after a starting request of an application program to be started is received. In addition, the loading authority file of the embodiment of the invention can be a json file, namely a lightweight data exchange and storage format.
The loading authority file of the embodiment of the invention can record the names of the view controllers needing special processing, namely the names of the view controllers needing delayed loading. In addition, in the embodiment of the invention, the page corresponding to the view controller which needs to be directly loaded can be displayed to the user after the application program is started by default. In general, the first page of the application program needs to be displayed immediately, and other pages can be loaded in a delayed manner, or of course, other pages of the application program need to be displayed immediately, and the first page can be set according to practical situations.
As a further reference embodiment of the present invention, the loading preprocessing for at least one view controller by using the loading authority file corresponding to the application to be started may include screening the view controller needing to be loaded with delay and the view controller needing to be loaded directly from at least one view controller according to the loading authority file corresponding to the application to be started, and obtaining the delay loading time of the view controller needing to be loaded with delay. Considering that not all view controllers need to be loaded in a delayed manner, the names of the view controllers needing to be loaded in a delayed manner are recorded in the loading authority file, so that the loading preprocessing in the embodiment of the invention can be to acquire the view controllers needing to be loaded in a delayed manner in at least one view controller by utilizing the loading authority file, so that the rest view controllers needing to be loaded directly are the view controllers needing to be loaded directly, and the loading time of the view controllers needing to be loaded in a delayed manner is required to be acquired. Assuming that the view controller of the application program a to be started has names of A1, A2, A3 and A4, and the names of A2, A3 and A4 exist in the loading authority file corresponding to a, it is stated that A2, A3 and A4 need to be loaded with delay, A1 can be directly loaded, and the time that A2, A3 and A4 need to be loaded with delay is acquired, for example, A2 is loaded after 0.5s, A3 is loaded after 0.8s, and A4 is loaded after 0.3 s.
In the embodiment of the invention, after loading preprocessing is performed, page elements corresponding to at least one view controller can be loaded according to a loading preprocessing result, and the method is concretely realized by directly calling loading codes corresponding to the view controllers which need to be directly loaded in the at least one view controller to finish loading the page elements corresponding to the view controllers which need to be directly loaded, and calling loading codes corresponding to the view controllers which need to be delayed to finish loading the page elements corresponding to the view controllers which need to be delayed to be loaded according to the delayed loading time of the view controllers which need to be delayed to be loaded.
For the view controllers needing to be directly loaded, loading codes corresponding to the view controllers can be directly loaded, so that loading of page elements can be completed, namely, after a starting request of an application program is received, namely, after a user clicks an icon of the application program, the view controllers needing to be directly loaded can be immediately loaded, and pages corresponding to the view controllers needing to be directly loaded are directly displayed to the user.
For the view controllers needing to be loaded in a delayed manner, loading codes of the view controllers needing to be loaded in a delayed manner can be loaded according to the delayed loading time, so that loading of page elements can be completed, namely, after a starting request of an application program is received, namely, after a user clicks an icon of the application program, the view controllers needing to be loaded in a delayed manner are loaded according to the delayed loading time, and pages corresponding to the view controllers needing to be loaded in a delayed manner can be directly displayed to the user.
For example, in the method after Hook replacement, it is determined whether the current view controller is in the loading authority file, if not, the original loading method viewDidLoad or loadView method is directly called, if so, a delay operation is performed, and after the delay, the main thread is asynchronously returned to call the original method.
It should be noted that, before the loading authority file corresponding to the application program to be started is utilized to perform loading pretreatment on at least one view controller, the method for optimizing the starting of the application program according to the embodiment of the invention further comprises the steps of loading the loading authority file corresponding to the application program to be started into a memory, correspondingly, after loading the page element corresponding to the at least one view controller according to the loading pretreatment result, moving the loading authority file corresponding to the application program to be started out of the memory. After the application program finishes loading, the corresponding loading authority file is moved out of the memory, and can be normally loaded when other view controllers with the same name are created. For example, in the loading authority file, A2 of the view controller of the application program a to be started needs to be removed from the memory after the loading of A2 is completed, so that when the view controller named as A2 is loaded, the view controller can be loaded normally and cannot be loaded in a delayed manner.
Fig. 2 is a schematic diagram of the main flow of a start-up optimization method of an application according to an embodiment of the present invention. As shown in fig. 2, the main flow of the method for optimizing the start of the application program according to the embodiment of the present invention may include:
Step S201, according to an application program starting request, at least one view controller corresponding to an application program to be started is obtained;
step S202, when at least one view controller is loaded, calling a preset code to replace a loading code corresponding to the at least one view controller so as to complete loading interception of the at least one view controller;
step S203, a loading authority file corresponding to the application program to be started is created in advance, and the loading authority file corresponding to the application program to be started is loaded into a memory;
Step S204, screening out a view controller needing to be loaded in a delayed manner and a view controller needing to be loaded directly from at least one view controller according to a loading authority file corresponding to an application program to be started, and acquiring the delayed loading time of the view controller needing to be loaded in a delayed manner;
Step S205, directly calling the loading codes corresponding to the view controllers needing to be directly loaded in at least one view controller, and calling the loading codes corresponding to the view controllers needing to be delayed to be loaded according to the delayed loading time of the view controllers needing to be delayed to finish the loading of page elements corresponding to the view controllers;
step S206, the loading authority files corresponding to the application programs to be started are moved out of the memory.
For ease of understanding, the method of starting the application of the prior art will be described in comparison with the method of starting the application of the present invention, where the page of the application is composed of four parts of home page, category, shopping cart and my.
(1) In the existing starting method of the application program, four pages of a home page, a classification, a shopping cart and my are initialized immediately after being started, a plurality of network requests are available at the same time, and a plurality of data processes are performed after the network returns, so that the starting cannot be completed quickly.
(2) The method for starting the application program comprises the steps of recording the page to be immediately displayed, storing the page by writing files or writing codes (represented by data D), loading display information of the page into a memory in the process of starting the application program, loading and requesting a network for each page (such as a first page, a classification, a shopping cart and My) by a normal process after the application program is started, calling a pre-written code because a Hook is carried out on a life cycle method of the page, judging whether the page is required to be immediately displayed or not through the data D, stopping the process if the page is not required, and carrying out post-processing after delay, thereby achieving the purposes of saving initialization time and accelerating the starting.
(3) FIG. 3 is a loading schematic diagram of a view controller according to an embodiment of the invention. As shown in fig. 3, the Tar Bar view controller manages 4 view controllers in the form of an array, which are respectively a home page, a category, a shopping cart and my, and it can also be seen that the home page is directly displayed to a user and is therefore directly loaded for initialization, at this time, the other three pages are not processed, and after the processing of the home page is completed, the other three pages are processed, that is, the other three pages need to be loaded in a delayed manner, that is, the data stored in the loading authority file is the names of the category, the shopping cart and my corresponding view controllers, and in the Hook method, the recorded category, shopping cart and my corresponding view controllers need to be delayed for waiting, and then data loading is performed.
According to the starting optimization technical scheme of the application program, each view controller of the application program to be started can be loaded and intercepted, and then each view controller is subjected to loading pretreatment by utilizing the pre-established loading authority file, so that each view controller can be loaded according to the loading pretreatment result, the effect of time-sharing loading of each view controller is achieved, the problem of long starting time caused by simultaneous loading of all view controllers in the prior art is avoided, the starting time of the application program is shortened, and user experience is improved.
Fig. 4 is a schematic diagram of main modules of a start-up optimization device of an application according to an embodiment of the present invention. As shown in fig. 4, the main modules of the start-up optimization device of the application program according to the embodiment of the present invention may include an acquisition module 401, a processing module 402, and a loading module 403.
The obtaining module 401 may be configured to obtain at least one view controller corresponding to an application to be started according to an application starting request, the processing module 402 may be configured to load and intercept the at least one view controller, perform loading preprocessing on the at least one view controller by using a loading authority file corresponding to the application to be started, and the loading module 403 may be configured to load a page element corresponding to the at least one view controller according to a loading preprocessing result.
In the embodiment of the present invention, the processing module 402 may be further configured to call a preset code instead of calling a loading code corresponding to the at least one view controller when the at least one view controller performs loading, so as to complete loading interception of the at least one view controller.
In the embodiment of the present invention, the processing module 402 may be further configured to obtain, from at least one view controller, a view controller to be loaded in a delayed manner and a view controller to be loaded directly from the at least one view controller according to a loading permission file corresponding to the application to be started, and obtain a delayed loading time of the view controller to be loaded in a delayed manner.
In the embodiment of the present invention, the loading module 403 may be further configured to directly call a loading code corresponding to a view controller to be directly loaded to complete loading of a page element corresponding to the view controller to be directly loaded, and call a loading code corresponding to a view controller to be delay loaded according to a delay loading time of the view controller to be delay loaded to complete loading of a page element corresponding to the view controller to be delay loaded.
In the embodiment of the present invention, the processing module 402 may be further configured to load the loading right file corresponding to the application to be started into the memory, and remove the loading right file corresponding to the application to be started from the memory.
In the embodiment of the present invention, the processing module 402 may be further configured to pre-create a loading permission file corresponding to the application to be started.
From the above description, it can be seen that the start-up optimization device for an application program according to the embodiment of the present invention can perform loading interception on each view controller of the application program to be started, and then perform loading preprocessing on each view controller by using a pre-created loading authority file, so that each view controller can be loaded according to the loading preprocessing result, the effect of time-sharing loading of each view controller is achieved, the problem of long start-up time caused by simultaneous loading of all view controllers in the prior art is avoided, the start-up time of the application program is reduced, and the user experience is improved.
Fig. 5 illustrates an exemplary system architecture 500 of a launch optimization method of an application or a launch optimization apparatus of an application to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process the received data such as the product information query request, and feedback the processing result (e.g., the target push information, the product information—only an example) to the terminal device.
It should be noted that, the method for optimizing the start-up of the application program according to the embodiment of the present invention is generally executed by the server 505, and accordingly, the device for optimizing the start-up of the application program is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Connected to the I/O interface 605 are an input section 606 including a keyboard, a mouse, and the like, an output section 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 608 including a hard disk, and the like, and a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a computer-readable storage medium may include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, which may be described as a processor comprising an acquisition module, a processing module and a loading module, for example. The names of these modules do not in any way limit the module itself, and for example, the acquisition module may also be described as "a module for acquiring at least one view controller corresponding to an application to be started according to an application start request".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs, and when the one or more programs are executed by the equipment, the equipment comprises at least one view controller corresponding to an application program to be started according to an application program starting request, loading interception is carried out on the at least one view controller, loading preprocessing is carried out on the at least one view controller by utilizing a loading authority file corresponding to the application program to be started, and page elements corresponding to the at least one view controller are loaded according to a loading preprocessing result.
According to the technical scheme provided by the embodiment of the invention, each view controller of the application program to be started can be loaded and intercepted, and then each view controller is loaded and preprocessed by utilizing the pre-created loading authority file, so that each view controller can be loaded according to the loading preprocessing result, the effect of time-sharing loading of each view controller is achieved, the problem of long starting time caused by simultaneous loading of all view controllers in the prior art is avoided, the starting time of the application program is shortened, and the user experience is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (9)

1.一种应用程序的启动优化方法,其特征在于,包括:1. A method for optimizing the startup of an application, comprising: 根据应用程序启动请求,获取待启动应用程序对应的至少一个视图控制器;其中,视图控制器是指可以展示页面的控制器,一个应用程序包含一个或多个页面,每个页面相当于是一个控制器;According to the application startup request, at least one view controller corresponding to the application to be started is obtained; wherein the view controller refers to a controller that can display a page, an application includes one or more pages, and each page is equivalent to a controller; 对所述至少一个视图控制器进行加载拦截,利用所述待启动应用程序对应的加载权限文件,对所述至少一个视图控制器进行加载预处理;其中,所述对所述至少一个视图控制器进行加载拦截,包括:在所述至少一个视图控制器进行加载时,调用预设的代码替代调用所述至少一个视图控制器对应的加载代码,以完成对所述至少一个视图控制器的加载拦截;The loading of the at least one view controller is intercepted, and the loading preprocessing of the at least one view controller is performed using the loading permission file corresponding to the application to be started; wherein the loading interception of the at least one view controller includes: when the at least one view controller is loaded, calling a preset code instead of calling the loading code corresponding to the at least one view controller to complete the loading interception of the at least one view controller; 根据加载预处理结果,加载所述至少一个视图控制器对应的页面元素。According to the loading preprocessing result, the page element corresponding to the at least one view controller is loaded. 2.根据权利要求1所述的方法,其特征在于,所述利用所述待启动应用程序对应的加载权限文件,对所述至少一个视图控制器进行加载预处理,包括:2. The method according to claim 1, characterized in that the step of using the loading permission file corresponding to the application to be started to perform loading preprocessing on the at least one view controller comprises: 根据所述待启动应用程序对应的加载权限文件,从所述至少一个视图控制器中筛选出需要延迟加载的视图控制器和需要直接加载的视图控制器;Filtering, from the at least one view controller, a view controller that needs to be lazily loaded and a view controller that needs to be directly loaded according to the loading permission file corresponding to the application to be started; 获取所述需要延迟加载的视图控制器的延迟加载时间。Gets the delayed loading time of the view controller that needs to be delayed loading. 3.根据权利要求2所述的方法,其特征在于,所述根据加载预处理结果,加载所述至少一个视图控制器对应的页面元素,包括:3. The method according to claim 2, characterized in that the step of loading the page element corresponding to the at least one view controller according to the loading preprocessing result comprises: 直接调用所述需要直接加载的视图控制器对应的加载代码,以完成对所述需要直接加载的视图控制器对应的页面元素的加载;Directly call the loading code corresponding to the view controller that needs to be directly loaded to complete the loading of the page element corresponding to the view controller that needs to be directly loaded; 按照所述需要延迟加载的视图控制器的延迟加载时间,调用所述需要延迟加载的视图控制器对应的加载代码,以完成对所述需要延迟加载的视图控制器对应的页面元素的加载。According to the delayed loading time of the view controller that needs to be delayed loading, the loading code corresponding to the view controller that needs to be delayed loading is called to complete the loading of the page element corresponding to the view controller that needs to be delayed loading. 4.根据权利要求1所述的方法,其特征在于,在利用所述待启动应用程序对应的加载权限文件,对所述至少一个视图控制器进行加载预处理之前,所述方法还包括:将所述待启动应用程序对应的加载权限文件加载到内存中;以及4. The method according to claim 1, characterized in that before using the loading permission file corresponding to the application to be started to perform loading preprocessing on the at least one view controller, the method further comprises: loading the loading permission file corresponding to the application to be started into a memory; and 在根据加载预处理结果,加载所述至少一个视图控制器对应的页面元素之后,所述方法还包括:将所述待启动应用程序对应的加载权限文件从内存中移出。After loading the page element corresponding to the at least one view controller according to the loading preprocessing result, the method further includes: removing the loading permission file corresponding to the application to be started from the memory. 5.根据权利要求1所述的方法,其特征在于,在利用所述待启动应用程序对应的加载权限文件,对所述至少一个视图控制器进行加载预处理之前,所述方法还包括:5. The method according to claim 1, characterized in that before using the loading permission file corresponding to the application to be started to perform loading preprocessing on the at least one view controller, the method further comprises: 预先创建所述待启动应用程序对应的加载权限文件。A loading permission file corresponding to the application to be started is created in advance. 6.一种应用程序的启动优化装置,其特征在于,包括:6. A device for optimizing the startup of an application, comprising: 获取模块,用于根据应用程序启动请求,获取待启动应用程序对应的至少一个视图控制器;其中,视图控制器是指可以展示页面的控制器,一个应用程序包含一个或多个页面,每个页面相当于是一个控制器;An acquisition module is used to acquire at least one view controller corresponding to the application to be started according to the application start request; wherein the view controller refers to a controller that can display a page, an application includes one or more pages, and each page is equivalent to a controller; 处理模块,用于对所述至少一个视图控制器进行加载拦截,利用所述待启动应用程序对应的加载权限文件,对所述至少一个视图控制器进行加载预处理;其中,所述对所述至少一个视图控制器进行加载拦截,包括:在所述至少一个视图控制器进行加载时,调用预设的代码替代调用所述至少一个视图控制器对应的加载代码,以完成对所述至少一个视图控制器的加载拦截;A processing module, used to intercept the loading of the at least one view controller, and perform loading preprocessing on the at least one view controller using the loading permission file corresponding to the application to be started; wherein the intercepting the loading of the at least one view controller includes: when the at least one view controller is loaded, calling a preset code instead of calling the loading code corresponding to the at least one view controller, so as to complete the interception of the loading of the at least one view controller; 加载模块,用于根据加载预处理结果,加载所述至少一个视图控制器对应的页面元素。The loading module is used to load the page elements corresponding to the at least one view controller according to the loading preprocessing result. 7.根据权利要求6所述的装置,其特征在于,所述处理模块还用于:7. The device according to claim 6, characterized in that the processing module is further used for: 根据所述待启动应用程序对应的加载权限文件,从所述至少一个视图控制器中筛选出需要延迟加载的视图控制器和需要直接加载的视图控制器;Filtering, from the at least one view controller, a view controller that needs to be lazily loaded and a view controller that needs to be directly loaded according to the loading permission file corresponding to the application to be started; 获取所述需要延迟加载的视图控制器的延迟加载时间。Gets the delayed loading time of the view controller that needs to be delayed loading. 8.一种电子设备,其特征在于,包括:8. An electronic device, comprising: 一个或多个处理器;one or more processors; 存储装置,用于存储一个或多个程序,a storage device for storing one or more programs, 当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-5中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5. 9.一种计算机可读介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现如权利要求1-5中任一所述的方法。9. A computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
CN202010163723.9A 2020-03-10 2020-03-10 Application startup optimization method and device Active CN113391847B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010163723.9A CN113391847B (en) 2020-03-10 2020-03-10 Application startup optimization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010163723.9A CN113391847B (en) 2020-03-10 2020-03-10 Application startup optimization method and device

Publications (2)

Publication Number Publication Date
CN113391847A CN113391847A (en) 2021-09-14
CN113391847B true CN113391847B (en) 2024-12-06

Family

ID=77615248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010163723.9A Active CN113391847B (en) 2020-03-10 2020-03-10 Application startup optimization method and device

Country Status (1)

Country Link
CN (1) CN113391847B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114237755B (en) * 2021-12-20 2025-01-17 百度在线网络技术(北京)有限公司 Application running method, device, electronic equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013163903A1 (en) * 2012-05-04 2013-11-07 惠州Tcl移动通信有限公司 Android system-based application program starting method and system

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080163185A1 (en) * 2006-12-29 2008-07-03 Rto Software, Inc. Delay-load optimizer
US8341609B2 (en) * 2007-01-26 2012-12-25 Oracle International Corporation Code generation in the presence of paged memory
CN102662690B (en) * 2012-03-14 2014-06-11 腾讯科技(深圳)有限公司 Method and apparatus for starting application program
US9075995B2 (en) * 2013-03-11 2015-07-07 Microsoft Technology Licensing, Llc Dynamically loaded measured environment for secure code launch
CN104102500B (en) * 2013-04-03 2017-12-01 腾讯科技(深圳)有限公司 The process initiation method and computer system of a kind of application program
CN105867956A (en) * 2015-10-28 2016-08-17 乐视网信息技术(北京)股份有限公司 Method and device for showing plugin view element in host application page
CN109782977B (en) * 2017-11-13 2022-11-29 腾讯科技(深圳)有限公司 View processing method, electronic device and storage medium
CN107748686B (en) * 2017-11-30 2021-03-12 Oppo广东移动通信有限公司 Application program starting optimization method and device, storage medium and intelligent terminal
CN110058893B (en) * 2018-01-16 2022-11-29 视联动力信息技术股份有限公司 Application control display method and device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013163903A1 (en) * 2012-05-04 2013-11-07 惠州Tcl移动通信有限公司 Android system-based application program starting method and system

Also Published As

Publication number Publication date
CN113391847A (en) 2021-09-14

Similar Documents

Publication Publication Date Title
CN110262807B (en) Cluster creation progress log acquisition system, method and device
JP2016529599A (en) Content clipboard synchronization
CN107943594A (en) Data capture method and device
US12099886B2 (en) Techniques for performing clipboard-to-file paste operations
CN107862044A (en) The method and apparatus of displayed page
KR20150113106A (en) Providing access to information across multiple computing devices
CN110764930B (en) Request or response processing method and device based on message mode
CN109472540A (en) Business processing method and device
CN112214250A (en) Method and device for loading application components
CN112784195B (en) A method and system for publishing page data
CN113656041A (en) Data processing method, device, equipment and storage medium
CN113391847B (en) Application startup optimization method and device
CN110119418A (en) Data export method and device
US9292457B2 (en) Networking cloud and method of using the same
US20140365430A1 (en) Information processing apparatus, system, and control method
CN113760965B (en) Data query method and device
CN110347654B (en) A method and device for launching cluster features
CN117389475A (en) A data processing method and device
US12001458B2 (en) Multi-cloud object store access
CN113746661B (en) A business processing method and device
CN117667437A (en) A file copying method, device and electronic equipment
CN113449215B (en) A method and device for loading pictures
CN113742010B (en) Method and device for displaying pages in multiple languages
WO2018217406A1 (en) Providing instant preview of cloud based file
CN116503005A (en) Process dynamic modification method, device, system 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
GR01 Patent grant
GR01 Patent grant