Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for controlling applet starting, which can at least solve the problem in the prior art that the applet starting speed is too slow.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an applet starting control method including:
after the application is normally started, sending a broadcast event to a first broadcast so as to start a first applet process corresponding to the first broadcast;
in response to a startup operation on an applet, loading the applet by using the first applet process;
and sending a broadcast event to a second broadcast after the first broadcast while displaying the operation home page of the applet in the application so as to start a second applet process corresponding to the second broadcast.
Optionally, before the sending a broadcast event to the first broadcast through the applet development kit SDK after the application is normally started, the method further includes:
and in the application starting process, initializing an application environment and a non-applet development kit, and after jumping to the home page of the application, determining that the application is normally started.
Optionally, the loading the applet by using the first applet process includes:
judging whether the first small program process is normally started and idled at present, and if the first small program process is normally started and idled, loading the small program by using the first small program process;
otherwise, restarting the first applet process to load the applet by using the normally started first applet process.
Optionally, the method further includes: and after the configured applet threads are all normally started and loaded with the applets, responding to the starting operation of a new applet, and replacing the applet loaded by using the first applet process with the new applet.
Optionally, the number of configured applet processes is 5.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an applet starting control apparatus including:
the first broadcast module is used for sending a broadcast event to a first broadcast after the application is normally started so as to start a first applet process corresponding to the first broadcast;
the loading module is used for responding to the starting operation of an applet and loading the applet by using the first applet process;
and the second broadcasting module is used for sending a broadcasting event to a second broadcast positioned after the first broadcast while displaying the operation home page of the applet in the application so as to start a second applet process corresponding to the second broadcast.
Optionally, the system further includes an application starting module, configured to: and in the application starting process, initializing an application environment and a non-applet development kit, and after jumping to the home page of the application, determining that the application is normally started.
Optionally, the loading module is configured to:
judging whether the first small program process is normally started and idled at present, and if the first small program process is normally started and idled, loading the small program by using the first small program process;
otherwise, restarting the first applet process to load the applet by using the normally started first applet process.
Optionally, the system further includes an applet replacing module, configured to: and after the configured applet threads are all normally started and loaded with the applets, responding to the starting operation of a new applet, and replacing the applet loaded by using the first applet process with the new applet.
Optionally, the number of configured applet processes is 5.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an applet starting control electronic device.
The electronic device of the embodiment of the invention comprises: one or more processors; a storage device, configured to store one or more programs, which when executed by the one or more processors, cause the one or more processors to implement any of the above-described applet launching control methods.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements any one of the applet starting control methods described above.
According to the scheme provided by the invention, one embodiment of the invention has the following advantages or beneficial effects: the Android platform broadcasting technology is used for preloading the small program process, a broadcasting event is sent to prepare the small program process in advance after or at the same time of starting the host App, and the preloaded process is directly used when the small program is started, so that the waiting problem of starting an empty process is avoided, and the small program starting speed is greatly improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as 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.
The words involved in the scheme are explained as follows:
app (full name: Application) refers to an executable Application program, and herein refers to an Application program that can be run on a smartphone, a computer, or the like.
Broadcast (full name: broadcastreever): one of the Android 4 large components is configured in an Android manifest file, can be operated in an independent process through process attribute configuration, and can also realize cross-process communication.
A main process: a program represents a process, such as a WeChat App. Since applets need to be host dependent (e.g., wechat applets depend on wechat), and are independent processes, the process run by the host is often referred to as the host process.
The small program: a program running on the host application can be opened through scanning and searching of the host without installation, and is very light.
Referring to fig. 1, a main flowchart of an applet starting control method provided in an embodiment of the present invention is shown, including the following steps:
s101: after the application is normally started, sending a broadcast event to a first broadcast so as to start a first applet process corresponding to the first broadcast;
s102: in response to a startup operation on an applet, loading the applet by using the first applet process;
s103: and sending a broadcast event to a second broadcast after the first broadcast while displaying the operation home page of the applet in the application so as to start a second applet process corresponding to the second broadcast.
In the above embodiment, for step S101, it is currently a practice to start an applet process of an empty process when the App application is started, so as to speed up the first applet opening. However, App start-up is generally a relatively heavy operation, such as initializing some non-applet SDKs (Software Development Kit), e.g., monitoring SDKs, embedded SDKs, etc., and the start-up of applet idle processes affects App start-up speed.
When a host/main process (such as a WeChat App) is started, the scheme preferably initializes the environment and various non-applet SDKs, such as point burying, hot repair, crash monitoring, and the like. After the initialization is completed and the main process normally jumps to the home page, it means that the application has been normally started, as shown in fig. 2.
Because certain time is needed for starting the application and initializing the non-applet SDK, the applet SDK preloading process (or a container) cannot be called immediately when the application is started, and a broadcast event is sent to the first broadcast through the applet SDK when the application normally jumps to a home page (or called parallel), so that the first applet process corresponding to the first broadcast is preheated.
For steps S102 and S103, sending the broadcast event does not affect the normal applet starting process, and when receiving the broadcast, the Android system starts a new empty applet process to complete the preloading process starting operation, and the applet process can be directly used subsequently when starting the applet.
When the applet is started (similar to the starting of the App), the pre-started first applet process can be directly used to open the applet in the first applet process. After the applet is started, the applet normally jumps to the applet operation home page, and simultaneously sends a broadcast event to a second broadcast (located after the first broadcast) through the applet SDK, so as to start a second applet process corresponding to the second broadcast. Through the above steps, a process is preloaded at the whole engine layer for loading the next applet to be opened.
Further, when the applet is started, it may be determined whether the current applet process has been normally started and idled, and if the current applet process has been normally started and idled, the applet process is directly reused, otherwise, the applet process needs to be restarted, and finally the applet is loaded using the applet process. Since the pre-started applet process may be recovered by the Android system or the pre-started applet process may fail, it is necessary to determine whether the applet process is normally started and idle, which is specifically shown in fig. 3.
The overall operation flow is shown in fig. 4:
1. when the application is started, sending a broadcast event to the broadcast 1 through the applet SDK so as to start the applet process 1 corresponding to the broadcast 1;
2. when the small program is started (such as the small program 1), the small program 1 can be directly loaded by using the pre-started process 1;
3. after the small program 1 is started, sending a broadcast event to the broadcast 2 through the small program SDK so as to start the small program process 2 corresponding to the broadcast 2;
4. if the small program is not started, stopping after the small program process 2 is started, if another small program is started, repeating the starting and sending operations until all small program processes are started and the small programs are loaded, and forming a running small program queue;
5. if an applet needs to be started later, the applet 1 loaded by the process 1 needs to be replaced by another applet.
In actual operation, the applet can be opened infinitely, but since resources such as mobile phones and computers are limited, 5 broadcasts and corresponding 5 applet processes are usually configured. After more than 5, the opened small program is replaced, as shown in the figure, the small program 1 runs in the process 1, and the small program 1 is replaced by the small program 6, so that a loop is formed.
For example, after the browser opens the web page a, the address of the web page B is input into the address bar of the web page, and then the browser displays the web page B, where the browser is an applet process, the page a is the applet 1, and the page B is the applet 6.
The embodiment of the invention provides a thought for increasing the starting speed of an applet from an Android applet engine layer, which is based on an Android SDK technology and an Android applet technology, combines an Android broadcasting mechanism, and preloads an applet process under the condition of not influencing the starting of an App and the applet, so that the starting of the applet is accelerated, and the experience of opening the applet by a user is improved.
The scheme is compared with the prior art:
1. the prior art is as follows: restarting the small program process when the small program is started, namely when the small program is not started, the small program process is always in a state of waiting to be started and being idle;
2. the scheme is as follows: when the application bearing the small program is started, only one broadcast and one small program process are started through the broadcast event, the started small program process is directly used when the subsequent small program is started, the starting operation of the second broadcast and the second small program process is triggered, a triggering cycle is formed, and a plurality of small program processes cannot be triggered and started at one time, so that the waste of system resources is avoided.
Referring to fig. 5, a schematic diagram of main modules of an applet starting control apparatus 500 provided in an embodiment of the present invention is shown, including:
a first broadcast module 501, configured to send a broadcast event to a first broadcast after an application is normally started, so as to start a first applet process corresponding to the first broadcast;
a loading module 502, configured to respond to a start operation on an applet, to load the applet by using the first applet process;
a second broadcasting module 503, configured to send a broadcast event to a second broadcast after the first broadcast while displaying the operation home page of the applet in the application, so as to start a second applet process corresponding to the second broadcast.
The apparatus further includes an application starting module 504 (not shown) for:
and in the application starting process, initializing an application environment and a non-applet development kit, and after jumping to the home page of the application, determining that the application is normally started.
In the implementation apparatus of the present invention, the loading module 502 is configured to:
judging whether the first small program process is normally started and idled at present, and if the first small program process is normally started and idled, loading the small program by using the first small program process;
otherwise, restarting the first applet process to load the applet by using the normally started first applet process.
The device for implementing the present invention further includes an applet replacing module 505 (not shown in the figure) for:
and after the configured applet threads are all normally started and loaded with the applets, responding to the starting operation of a new applet, and replacing the applet loaded by using the first applet process with the new applet.
In the implementation device of the invention, the number of the configured small program processes is 5.
In addition, the detailed implementation of the device in the embodiment of the present invention has been described in detail in the above method, so that the repeated description is not repeated here.
FIG. 6 illustrates an exemplary system architecture 600 to which embodiments of the invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605 (by way of example only). The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications can be installed on the terminal devices 601, 602, 603.
The terminal devices 601, 602, 603 may be various electronic devices having display screens and supporting web browsing, and the server 605 may be a server providing various services.
It should be noted that the method provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the apparatus is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the 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 illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the 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 present invention, 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, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart 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 described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a first broadcast module, a loading module and a second broadcast module. Where the names of these modules do not in some cases constitute a limitation on the module itself, for example, a load module may also be described as an "applet load module".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
after the application is normally started, sending a broadcast event to a first broadcast so as to start a first applet process corresponding to the first broadcast;
in response to a startup operation on an applet, loading the applet by using the first applet process;
and sending a broadcast event to a second broadcast after the first broadcast while displaying the operation home page of the applet in the application so as to start a second applet process corresponding to the second broadcast.
According to the technical scheme of the embodiment of the invention, the Android platform broadcasting technology is used for preloading the process, when the host App is started, a broadcasting event is sent to prepare the small program process in advance, and when the small program is started, the preloaded small program process is directly used for loading, so that the waiting time for starting the empty process is avoided, and the small program starting speed is greatly improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.