A small program startup control method and device
By preloading the applet process with broadcast technology on the Android platform, the problem of the applet startup speed is solved, and faster startup speed and better user experience is achieved.
Patent Information
- Application Number
- CN202110075175.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-20
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2041-01-20
AI Technical Summary
The startup speed of existing technology is too slow, especially on low-end Android devices, resulting in poor user experience.
By preloading the applet process using broadcast technology on the Android platform, and preparing the applet process in advance after the host App is started or sent broadcast events at the same time, so as to directly use the preloaded process when starting the applet.
It greatly improves the startup speed of the mini program, avoids the time-consuming waiting for the empty process, and improves the user's experience of opening the mini program.
Smart Images

Figure CN114090104B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a small program startup control method and device. Background Art
[0002] Mini programs are a new species that have emerged in recent years. They are hybrid applications that integrate front-end H5, native Android, iOS and other technologies, and can enable a set of programs to run seamlessly on two platforms. On the Android platform, each mini program is an independent process, which means that it can occupy exclusive memory and reduce the memory pressure of the main process (host, such as WeChat App). For example: the upper limit of each process is 100MB. When you open an Android mini program, it is equivalent to having 100MB of memory available for use, and it does not occupy the main process memory.
[0003] On the Android platform, multiple mini-programs can be opened, which means multiple processes. However, starting a process requires a price. Even if the new process does not operate anything, it still takes time. According to statistics, it usually takes about 0.5 to 3 seconds, and it takes even longer on mid- and low-end Android devices. In order to avoid the first and subsequent opening of mini-programs being too slow, and not affecting the normal main process and mini-program startup process, a solution to speed up the mini-program startup is required. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method and device for controlling the startup of a small program, which can at least solve the problem of slow startup speed of small programs in the prior art.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for controlling the startup of an applet is provided, comprising:
[0006] After the application is started normally, a broadcast event is sent to the first broadcast to start a first applet process corresponding to the first broadcast;
[0007] In response to a start operation on an applet, loading the applet using the first applet process;
[0008] While displaying the operation homepage of the mini program in the application, a broadcast event is sent to a second broadcast located after the first broadcast to start a second mini program process corresponding to the second broadcast.
[0009] Optionally, after the application is started normally, before sending a broadcast event to the first broadcast through the mini program development toolkit SDK, the method further includes:
[0010] During the application startup process, the application environment and the non-applet development toolkit are initialized, and after jumping to the homepage of the application, it is determined that the application is started normally.
[0011] Optionally, using the first applet process to load the applet includes:
[0012] Determine whether the first applet process is currently started normally and idle, and if so, use the first applet process to load the applet;
[0013] Otherwise, restart the first applet process to load the applet using the first applet process started normally.
[0014] Optionally, the method further includes: after all configured applet threads have been started normally and applet loading has been completed, in response to a start operation of a new applet, replacing the applet currently loaded using the first applet process with the new applet.
[0015] Optionally, the number of applet processes configured is 5.
[0016] To achieve the above object, according to another aspect of an embodiment of the present invention, a mini-program startup control device is provided, comprising:
[0017] A first broadcast module, configured to send 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;
[0018] A loading module, configured to, in response to a start operation on a mini-program, load the mini-program using the first mini-program process;
[0019] The second broadcast module is used to send a broadcast event to a second broadcast after the first broadcast while displaying the operation homepage of the mini program in the application, so as to start a second mini program process corresponding to the second broadcast.
[0020] Optionally, it also includes an application startup module, which is used to: during the application startup process, initialize the application environment and non-mini program development toolkit, and after jumping to the homepage of the application, determine that the application is started normally.
[0021] Optionally, the loading module is used to:
[0022] Determine whether the first applet process is currently started normally and idle, and if so, use the first applet process to load the applet;
[0023] Otherwise, restart the first applet process to load the applet using the first applet process started normally.
[0024] Optionally, it also includes a mini-program replacement module, which is used to: after all configured mini-program threads have been started normally and the mini-programs have been loaded, in response to a startup operation of a new mini-program, replace the mini-program currently loaded using the first mini-program process with the new mini-program.
[0025] Optionally, the number of applet processes configured is 5.
[0026] To achieve the above objective, according to another aspect of an embodiment of the present invention, a small program is provided to start controlling an electronic device.
[0027] The electronic device of an embodiment of the present invention includes: one or more processors; a storage device 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 implement any of the mini-program startup control methods described above.
[0028] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned mini-program startup control methods is implemented.
[0029] According to the solution provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: using Android platform broadcast technology to preload the mini-program process, after or at the same time as the host App is started, sending a broadcast event to prepare the mini-program process in advance, when starting the mini-program, directly using the preloaded process, avoiding the waiting problem of starting an empty process, and greatly improving the startup speed of the mini-program.
[0030] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0032] Figure 1 This is a main flow chart of a method for controlling the startup of a small program according to an embodiment of the present invention;
[0033] Figure 2 This is a schematic diagram of the application starting the preheating applet process;
[0034] Figure 3 This is a flowchart of the mini program startup;
[0035] Figure 4 It is a schematic diagram of the overall implementation process;
[0036] Figure 5 is a schematic diagram of main modules of a small program startup control device according to an embodiment of the present invention;
[0037] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0038] Figure 7 It is a schematic diagram of the structure of a computer system of a mobile device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0039] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0040] The following are the explanations for the terms involved in this plan:
[0041] App (full name: Application) refers to an executable application. In this article, it refers to an application that can be run on smartphones, computers, etc.
[0042] Broadcast (full name: BroadcastReceiver): One of the four major components of Android, configured in the Android manifest file. It can be configured to run in an independent process through its process attribute, and can also achieve cross-process communication.
[0043] Main process: A program represents a process, such as WeChat App. Since the mini program needs to rely on the host (such as WeChat mini program relies on WeChat) and is an independent process, the process running by the host is usually called the main process.
[0044] Mini Program: A program that runs on top of the host application. It does not need to be installed and can be opened by scanning or searching the host application. It is very lightweight.
[0045] See also Figure 1 , which shows a main flow chart of a small program startup control method provided by an embodiment of the present invention, including the following steps:
[0046] S101: After the application is started normally, a broadcast event is sent to a first broadcast to start a first applet process corresponding to the first broadcast;
[0047] S102: In response to a start operation on a small program, use the first small program process to load the small program;
[0048] S103: While displaying the operation homepage of the mini program in the application, a broadcast event is sent to a second broadcast after the first broadcast to start a second mini program process corresponding to the second broadcast.
[0049] In the above implementation, for step S101, one current approach is to start an empty applet process when the App application is started to speed up the initial opening of the applet. However, App startup is generally a relatively heavyweight operation, such as initializing some non-app SDKs (Software Development Kits), such as monitoring SDKs, tracking SDKs, etc., and the startup of an empty applet process will affect the App startup speed.
[0050] When the host / main process (such as WeChat App) starts, this solution prefers to initialize the environment and various non-app SDKs first, such as tracking, hot fixes, crash monitoring, etc. After the initialization is completed and the main process jumps to the home page normally, it means that the application has started normally. For details, see Figure 2 shown.
[0051] Since application startup and non-mini program SDK initialization take a certain amount of time, this solution will not call the mini program SDK to preload the process (or container) immediately when the application starts. Instead, at the same time as the application jumps to the home page normally (or called parallel), a broadcast event is sent to the first broadcast through the mini program SDK to preheat a first mini program process corresponding to the first broadcast.
[0052] For steps S102 and S103, sending a broadcast event will not affect the normal startup process of the mini-program. When the broadcast is received, the Android system will start a new empty mini-program process to complete the preload process startup operation. When the mini-program is started later, the mini-program process can be used directly.
[0053] When the mini program is started (similar to the startup of an App), the pre-started first mini program process can be used directly to open the mini program in the first mini program process. After the mini program is started, it will jump to the mini program operation homepage normally, and at the same time, a broadcast event will be sent to the second broadcast (located after the first broadcast) through the mini program SDK to start the second mini program process corresponding to the second broadcast. Through the above steps, a process will be preloaded in the entire engine layer to load the next mini program to be opened.
[0054] Furthermore, when the mini program is started, it can first be determined whether the current mini program process has been started normally and is idle. If it has been started normally and is idle, it can be reused directly. Otherwise, the mini program process needs to be restarted and finally used to load the mini program. The pre-started mini program process may be recycled by the Android system, or the pre-start process fails, so it is necessary to determine whether the mini program process has been started normally and is idle. For details, see Figure 3 shown.
[0055] For the overall operation process, see Figure 4 As shown:
[0056] 1. When the application is started, a broadcast event is sent to Broadcast 1 through the Mini Program SDK to start Mini Program process 1 corresponding to Broadcast 1;
[0057] 2. When starting a mini program (such as mini program 1), you can directly use the pre-started process 1 to load mini program 1 directly;
[0058] 3. After Mini Program 1 is started, a broadcast event is sent to Broadcast 2 through the Mini Program SDK to start Mini Program Process 2 corresponding to Broadcast 2;
[0059] 4. If there is no mini program started, it will stay after the mini program process 2 is started. However, if there is another mini program started, the above start and send operations will be repeated until all mini program processes are started and mini programs are loaded, forming a queue of running mini programs;
[0060] 5. If you still need to start a mini program later, you need to replace mini program 1 loaded by process 1 with another mini program.
[0061] In actual operation, mini-programs can be opened infinitely, but due to the limited resources of mobile phones and computers, 5 broadcasts and corresponding 5 mini-program processes are usually configured. When there are more than 5, the mini-programs that have been opened will be replaced. As shown in the figure above, mini-program 1 is running in process 1, and then mini-program 1 is replaced by mini-program 6, thus forming a cycle.
[0062] For example, after the browser opens web page A, and then enters the address of web page B in the address bar of the web page, the browser will display web page B. Here, the browser is the mini program process, page A is mini program 1, and page B is mini program 6.
[0063] The embodiment of the present invention provides an idea for improving the startup speed of the mini-program from the Android mini-program engine layer. It is based on Android SDK technology and Android mini-program technology, combined with Android's broadcast mechanism, and preloads the mini-program process without affecting the startup of the App and the mini-program, thereby accelerating the startup of the mini-program and improving the user experience of opening the mini-program.
[0064] Comparison of this solution with the prior art:
[0065] 1. Existing technology: When the mini program is started, the mini program process is started again. That is, when the mini program is not started, the mini program process is always in a waiting and idle state;
[0066] 2. This solution: When the application that hosts the mini-program is started, only one broadcast and one mini-program process are started through the broadcast event. When the mini-program is started subsequently, the started mini-program process is directly used, and the start operation of the second broadcast and the second mini-program process is triggered, forming a trigger loop, and multiple mini-program processes will not be triggered at one time to avoid wasting system resources.
[0067] See also Figure 5 , showing a schematic diagram of main modules of a mini-program startup control device 500 provided in an embodiment of the present invention, including:
[0068] The first broadcast module 501 is used to send a broadcast event to the first broadcast after the application is started normally, so as to start the first applet process corresponding to the first broadcast;
[0069] A loading module 502, configured to load a mini program using the first mini program process in response to a start operation on the mini program;
[0070] The second broadcast module 503 is used to send a broadcast event to a second broadcast after the first broadcast while displaying the operation homepage of the mini program in the application, so as to start a second mini program process corresponding to the second broadcast.
[0071] The implementation device of the present invention further includes an application startup module 504 (not shown in the figure), which is used to:
[0072] During the application startup process, the application environment and the non-applet development toolkit are initialized, and after jumping to the homepage of the application, it is determined that the application is started normally.
[0073] In the implementation device of the present invention, the loading module 502 is used to:
[0074] Determine whether the first applet process is currently started normally and idle, and if so, use the first applet process to load the applet;
[0075] Otherwise, restart the first applet process to load the applet using the first applet process started normally.
[0076] The implementation device of the present invention further includes a small program replacement module 505 (not shown in the figure), which is used to:
[0077] After all configured applet threads have been started normally and applet loading has been completed, in response to a start operation of a new applet, the applet currently loaded using the first applet process is replaced with the new applet.
[0078] In the implementation device of the present invention, the number of configured applet processes is 5.
[0079] In addition, the specific implementation content of the device described in the embodiment of the present invention has been described in detail in the method described above, so the repeated content will not be described again here.
[0080] Figure 6 An exemplary system architecture 600 is shown in which embodiments of the present invention may be applied.
[0081] like Figure 6 As shown, the system architecture 600 may include terminal devices 601, 602, 603, a network 604 and a server 605 (just an example). The network 604 is used to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0082] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603.
[0083] 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.
[0084] It should be noted that the method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device is generally set in the server 605 .
[0085] It should be understood that Figure 6The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0086] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0087] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required 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 the bus 704.
[0088] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. 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, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0089] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0090] It should be noted that 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 above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0091] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0092] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a first broadcast module, a loading module, and a second broadcast module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the loading module may also be described as a "small program loading module".
[0093] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0094] After the application is started normally, a broadcast event is sent to the first broadcast to start a first applet process corresponding to the first broadcast;
[0095] In response to a start operation on an applet, loading the applet using the first applet process;
[0096] While displaying the operation homepage of the mini program in the application, a broadcast event is sent to a second broadcast located after the first broadcast to start a second mini program process corresponding to the second broadcast.
[0097] According to the technical solution of the embodiment of the present invention, the Android platform broadcast technology is used to preload the process. After the host App is started, a broadcast event is sent to prepare the mini-program process in advance. When the mini-program is started, the preloaded mini-program process is directly used to load it, avoiding the time-consuming waiting of starting an empty process and greatly improving the startup speed of the mini-program.
[0098] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for controlling the startup of a small program, characterized in that: include: After the application is started normally, a broadcast event is sent to the first broadcast to start a first applet process corresponding to the first broadcast; In response to a startup operation on an applet, using the first applet process to load the applet includes: determining whether the first applet process has been normally started and is idle, and if so, using the first applet process to load the applet; otherwise, restarting the first applet process to load the applet using the normally started first applet process; While displaying the operation homepage of the mini program in the application, a broadcast event is sent to a second broadcast located after the first broadcast to start a second mini program process corresponding to the second broadcast.
2. The method according to claim 1, characterized in that After the application is started normally, before sending a broadcast event to the first broadcast through the mini program development toolkit SDK, it also includes: During the application startup process, the application environment and the non-applet development toolkit are initialized, and after jumping to the homepage of the application, it is determined that the application is started normally.
3. The method according to claim 1 or 2, characterized in that: Also includes: After all configured applet threads have been started normally and applet loading has been completed, in response to a start operation of a new applet, the applet currently loaded using the first applet process is replaced with the new applet.
4. The method according to claim 1, characterized in that: The number of configured applet processes is 5.
5. A small program startup control device, characterized in that: include: A first broadcast module, configured to send 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; A loading module, for responding to a startup operation on a mini-program, using the first mini-program process to load the mini-program, comprising: determining whether the first mini-program process has been normally started and is idle, and if so, using the first mini-program process to load the mini-program; otherwise, restarting the first mini-program process to load the mini-program using the normally started first mini-program process; The second broadcast module is used to send a broadcast event to a second broadcast after the first broadcast while displaying the operation homepage of the mini program in the application, so as to start a second mini program process corresponding to the second broadcast.
6. The device according to claim 5, characterized in that Also includes applet replacement modules for: After all configured applet threads have been started normally and applet loading has been completed, in response to a start operation of a new applet, the applet currently loaded using the first applet process is replaced with the new applet.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, 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 4.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Method and device for running applet and computer storage medium
CN110377369A
Running process multiplexing method and device
CN111913707A