Page display method and device

By customizing the construction and cache a Flutter engine instance in the Flutter application, it solves the problem of excessive memory usage caused by frequent creation and destruction of engine instances, and improves the performance and user experience of the application.

CN114116056BActive Publication Date: 2025-04-08BOE TECHNOLOGY GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111401266.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2025-04-08
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

When loading Flutter pages, Flutter engine instances are frequently created and destroyed, resulting in excessive memory usage and affecting the user experience.

Method used

Avoid creating new engine instances by customizing the Flutter engine instance when the application starts and getting the instance directly from memory when needed.

Benefits of technology

Reduces the number of Flutter engine instances in memory, reduces memory and resource consumption, and improves application performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114116056B_ABST
    Figure CN114116056B_ABST
Patent Text Reader

Abstract

The present specification provides a page display method and device, the method comprising: in response to a first trigger operation in a target application, obtaining a target cross-platform engine instance pre-built through a custom operation from a memory, the first trigger operation being used to request a jump from a native page of the target application to a target cross-platform page; based on the target cross-platform engine instance, loading the target cross-platform page so that only one cross-platform engine instance may exist in the memory, thereby reducing memory usage, optimizing the performance of the target application, and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a page display method and device. Background Art

[0002] Flutter is a cross-platform application interface (User Interface, UI) solution. Pages developed based on Flutter, that is, Flutter pages, can run on both Android and iOS systems at the same time, achieving cross-platform.

[0003] Currently, when loading a Flutter page, you need to create a Flutter engine instance to use the Flutter engine instance to load the Flutter page. When a user uses an application, they may need to jump from a native page to a Flutter page multiple times. Each time they jump from a native page to a Flutter page, a new Flutter engine instance needs to be created. As a result, multiple Flutter engine instances need to be created, resulting in multiple Flutter engine instances in memory, which occupies a large amount of memory and affects the user experience. Summary of the invention

[0004] In order to overcome the problems existing in the related art, this specification provides a page display method and device.

[0005] According to a first aspect of an embodiment of this specification, a page display method is provided, the method comprising:

[0006] In response to a first trigger operation in a target application, obtaining a target cross-platform engine instance pre-built through a custom operation from a memory, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page;

[0007] Based on the target cross-platform engine instance, the target cross-platform page is loaded.

[0008] In one possible design, the method further includes:

[0009] In response to the start operation of the target application, constructing a target cross-platform engine instance through a cross-platform engine instance custom operation;

[0010] The target cross-platform engine instance is stored in memory.

[0011] In a possible design, obtaining from the memory a target cross-platform engine instance pre-built through a custom operation includes:

[0012] A global variable corresponding to the target cross-platform engine instance is obtained from the memory, and based on the global variable, the target cross-platform engine instance is determined from the memory, wherein the global variable is defined when the target cross-platform engine instance is constructed.

[0013] In one possible design, the method further includes:

[0014] Based on the target cross-platform engine instance, a first preset page corresponding to the target application is displayed; wherein the first preset page is a homepage corresponding to the target application.

[0015] In one possible design, the method further includes:

[0016] In response to the start-up operation of the target application, a second preset page corresponding to the target application is displayed; wherein the second preset page is a start-up page corresponding to the target application.

[0017] In one possible design, the method further includes:

[0018] When the second preset page corresponding to the target application is displayed completely and the first preset page corresponding to the target application is not displayed, the third preset page is displayed.

[0019] In one possible design, the method further includes:

[0020] In response to displaying the first preset page, the third preset page is removed.

[0021] In one possible design, the method further includes:

[0022] Initialize the target cross-platform engine instance.

[0023] In one possible design, the display content of the third preset page is the same as the display content of the second preset page.

[0024] In one possible design, the target cross-platform engine instance includes a target Flutter engine instance.

[0025] According to a second aspect of an embodiment of this specification, there is provided a page display device, including:

[0026] An instance acquisition module, configured to acquire, from a memory, a target cross-platform engine instance pre-built through a custom operation in response to a first trigger operation in a target application, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page;

[0027] The page display module is used to load the target cross-platform page based on the target cross-platform engine instance.

[0028] In one possible design, the apparatus further includes an instance construction module;

[0029] The example construction module is specifically used for:

[0030] In response to the start operation of the target application, constructing a target cross-platform engine instance through a cross-platform engine instance custom operation;

[0031] The target cross-platform engine instance is stored in memory.

[0032] In a possible design, the instance acquisition module is used to:

[0033] A global variable corresponding to the target cross-platform engine instance is obtained from the memory, and based on the global variable, the target cross-platform engine instance is determined from the memory, wherein the global variable is defined when the target cross-platform engine instance is constructed.

[0034] In one possible design, the instance building blocks are also used to:

[0035] Based on the target cross-platform engine instance, a first preset page corresponding to the target application is displayed, wherein the first preset page is a homepage corresponding to the target application.

[0036] In one possible design, the instance building blocks are also used to:

[0037] In response to the start-up operation of the target application, a second preset page corresponding to the target application is displayed; wherein the second preset page is a start-up page corresponding to the target application.

[0038] In one possible design, the device further includes a page processing module;

[0039] The page processing module is specifically used for:

[0040] When the second preset page corresponding to the target application is displayed completely and the first preset page corresponding to the target application is not displayed, the third preset page is displayed.

[0041] In a possible design, the page processing module is further used for:

[0042] In response to displaying the first preset page, the third preset page is removed.

[0043] In one possible design, the example building module is further used to:

[0044] Initialize the target cross-platform engine instance.

[0045] In one possible design, the display content of the third preset page is the same as the display content of the second preset page.

[0046] In one possible design, the target cross-platform engine instance includes a target Flutter engine instance.

[0047] According to a third aspect of an embodiment of this specification, a mobile terminal is provided, including:

[0048] processor;

[0049] a memory for storing processor-executable instructions;

[0050] Wherein, the processor is configured to:

[0051] In response to a first trigger operation in a target application, obtaining a target cross-platform engine instance pre-built through a custom operation from a memory, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page;

[0052] Based on the target cross-platform engine instance, the target cross-platform page is loaded.

[0053] According to the fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the page display method described in the first aspect and various possible designs of the first aspect is implemented.

[0054] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the page display method described in the first aspect and various possible designs of the first aspect is implemented.

[0055] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0056] In an embodiment of the present specification, during the process of a user using a target application, upon receiving a first trigger operation, indicating a need to jump from the currently displayed native page to a corresponding cross-platform page, i.e., a target cross-platform page, a custom cross-platform engine instance is directly called from the memory, i.e., a target cross-platform engine instance pre-built through a custom operation, so as to utilize the target cross-platform engine instance to load the target cross-platform page and realize the display of the cross-platform page without creating a new cross-platform engine instance, so that only one cross-platform engine instance may exist in the memory, thereby reducing memory usage, optimizing the performance of the target application, and improving the user experience.

[0057] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.

[0059] Figure 1 This is a schematic diagram of an existing page jump process shown in this specification according to an exemplary embodiment.

[0060] Figure 2 This is a schematic diagram of page stacking according to an exemplary embodiment of this specification.

[0061] Figure 3 It is a flow chart of a page display method shown in this specification according to an exemplary embodiment.

[0062] Figure 4 It is a schematic diagram of a page jump according to an exemplary embodiment of this specification.

[0063] Figure 5 It is a schematic diagram of another page jump shown in this specification according to an exemplary embodiment.

[0064] Figure 6 It is a flowchart of another page display method shown in this specification according to an exemplary embodiment.

[0065] Figure 7 It is a schematic diagram of another page jump shown in this specification according to an exemplary embodiment.

[0066] Figure 8 It is a flowchart of another page display method shown in this specification according to an exemplary embodiment.

[0067] Fig. 9It is a schematic diagram of an application display page according to an exemplary embodiment of this specification.

[0068] Fig.10 It is a hardware structure diagram of the mobile terminal where the page display device of the embodiment of this specification is located.

[0069] Fig.11 It is a structural block diagram of a page display device according to an exemplary embodiment of the present specification. DETAILED DESCRIPTION

[0070] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0071] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0072] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0073] To facilitate understanding, the terms used in this application are first explained.

[0074] Native: Android pages developed based on Java and / or iOS pages developed based on Objective-C.

[0075] Startup page: The first system page displayed during the application startup process.

[0076] Flutter: A cross-platform framework for the UI layer, mainly used to implement business development at the UI level. For example, the news list page, news detail page, personal information page, etc. in the news client can all be developed and implemented using Flutter. However, if there is location information in the news, a map needs to be displayed to inform the user of the location where the news occurred. The location function is required, which cannot be implemented by Flutter. The native function needs to be used to implement the callback to the Flutter layer.

[0077] In addition, when loading the Flutter page, you need to start the Flutter Engine. When the business does not need to jump to the Android / iOS page, only one Flutter engine is needed during the application running process. However, when the business involves functions such as taking pictures, positioning, and pushing, they need to be implemented by Android / iOS native functions. When jumping back to the Flutter page from the Android / iOS page, Flutter will start another engine by default, so that two engines exist in the memory at the same time. Due to business needs, the subsequent jump from the Flutter page to the native page, and then continue to call back to the Flutter page, another engine will be generated. Accordingly, there are multiple engines in the memory.

[0078] Next, the embodiments of this specification are described in detail.

[0079] In some embodiments, when the application is started, the homepage of the application is generally implemented by Flutter, that is, the homepage is a Flutter page, so a Flutter engine instance is initialized by default to load the homepage using the Flutter engine instance. When the application involves native functions (for example, positioning, shooting with a camera, etc.), it is necessary to jump from the Flutter page to the native page. And when the user inputs a related trigger operation, it indicates that it is necessary to jump from the native page to the corresponding Flutter page. Since the default Flutter engine instance cannot be obtained, the Flutter engine instance is reinitialized to load the corresponding Flutter page using the new Flutter engine instance.

[0080] For example, if Figure 1As shown, when the application is started, the Flutter engine instance is initialized by default, that is, Flutter engine 1 is started, so as to use Flutter engine 1 to load the homepage of the application, and when Flutter engine 1 is started, Flutter engine 1 will be saved in the memory. In the process of using the application, when the user jumps from the native page to the Flutter page, that is, page 1, because the instance of the default engine cannot be obtained, that is, Flutter engine 1 cannot be obtained, it is necessary to initialize, that is, start a new Flutter engine instance, that is, Flutter engine 2, to use Flutter engine 2 to load the page 1. And when Flutter engine 2 is started, Flutter engine 2 will be saved in the memory. At this time, there are two Flutter engine instances in the memory. It can be seen that when there are multiple scenes in the application that jump from the native page to the Flutter page, the Flutter engine needs to be instantiated multiple times, resulting in multiple Flutter engine instances in the memory, which occupies a large amount of memory and affects the performance of the application.

[0081] Among them, when loading the home page / page 1, the routing mechanism pushes the home page / page 1 into the routing stack (such as Figure 2 As shown in the figure). Since the home page / page 1 will occupy memory after being pushed into the stack, Flutter Engine 1 / Flutter Engine 2 cannot be released and will continue to occupy memory.

[0082] Therefore, in response to the above problems, the embodiment of the present disclosure proposes a Flutter page loading method, which customizes and initializes a Flutter engine instance when the application starts, and saves it to the cache. The homepage of the application is loaded using the Flutter engine instance, and when it is necessary to jump from the native page to the Flutter page later, the Flutter page is directly loaded using the Flutter engine instance in the memory without creating a new Flutter engine instance, so that only one Flutter engine instance can exist in the memory, reducing memory usage, effectively reducing memory overhead and performance overhead, optimizing the performance of the application, and improving user experience.

[0083] like Figure 3 As shown, Figure 3 This is a flow chart of a page display method according to an exemplary embodiment of the present specification, comprising the following steps:

[0084] Step 301: In response to a first trigger operation in a target application, a target cross-platform engine instance pre-built by a custom operation is obtained from a memory, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page.

[0085] In this embodiment, when the user uses the target application on the mobile terminal, when the user wants to use a specific function provided by the target application, the user enters a corresponding trigger operation, i.e., a first trigger operation. When the specific function is implemented, it is necessary to jump from the native page to the specific cross-platform page. Accordingly, the first trigger operation is used to request to jump from the native page currently displayed by the target application to the target cross-platform page.

[0086] After the mobile terminal receives the first trigger operation input by the user, it indicates that it is necessary to jump from the currently displayed native page to a specific cross-platform page (i.e., the target specific cross-platform page), which means that the cross-platform page needs to be loaded. Then, the existing target cross-platform engine instance is obtained from the memory for loading the cross-platform page using the target cross-platform engine instance.

[0087] Among them, the first trigger operation includes click operation, voice operation, gesture operation, etc.

[0088] The target cross-platform engine instance is a cross-platform engine instance pre-built by executing a custom operation when the target application is started. After the target cross-platform engine instance is saved to the memory, since the target cross-platform engine instance is customized, the relevant instance information (e.g., instance name) of the target cross-platform engine instance is known, and therefore, the target cross-platform engine instance can be obtained from the memory based on the relevant instance information.

[0089] Optionally, the target cross-platform engine instance includes a target Flutter engine instance. Accordingly, the cross-platform page includes a Flutter page, that is, a page developed based on Flutter.

[0090] Optionally, the target application is an application developed based on Flutter, which involves one or more scenarios of jumping from a native page to a Flutter page.

[0091] Take a specific application scenario as an example. The target application includes an inspection module. After entering the inspection module, Figure 4 As shown in the figure, the first page displayed is the Flutter page. When the device overview button on the page is clicked, it jumps to the device overview page containing the location, that is, the native page, so that the location of the device can be viewed through the device overview page. The device overview page displays an alarm button. When the user clicks the alarm button, it indicates that the first trigger operation is triggered, and then jumps to the corresponding alarm page, that is, the Flutter page. When the user clicks the relevant button on the alarm page, the page displays the following Figure 5 In the pop-up layer shown in (a), when the user clicks the Transfer Work Order / View Work Order control on the pop-up layer, the page will jump to the following Figure 5The new repair ticket page (i.e., Flutter page) shown in (b) above. When the user clicks the positioning control on the new repair ticket page, the target application can jump to the positioning page, and after selecting positioning on the positioning page, it jumps back to the Flutter page, thus achieving the jump between the native page and the Flutter page.

[0092] Optionally, the target application includes a native layer and a cross-platform layer (for example, a Flutter layer). In the case of jumping from a Flutter page to a native page, the mobile terminal sends a first target page information to the native layer based on the cross-platform layer, so that the native layer jumps from the cross-platform page to the native page, and the first target page information includes a jump identifier and a target native page identifier, and the jump identifier indicates a page jump, and the target native page identifier indicates a native page identifier to be displayed. After the native layer receives the first target page information, it indicates that it is necessary to jump from the currently displayed cross-platform page to the target native page, and then calls the relevant page loading method to load the target native page corresponding to the target native page identifier.

[0093] The cross-platform layer may send the first target page information to the native layer through a platform channel (PlantformChannel). Specifically, the platform channel may be a method channel (MethodChannel).

[0094] Correspondingly, the process of jumping from a native page to a cross-platform page is the opposite of the process of jumping from a cross-platform page to a native page, that is, the native layer can send the corresponding second target page information to the cross-platform layer through the platform channel, so that when the cross-platform layer receives the second target page information, it indicates that it is necessary to jump from the currently displayed native page to the target cross-platform page, and then calls the target cross-platform engine instance to load the target cross-platform page.

[0095] Step 302: Based on the target cross-platform engine instance, load the target cross-platform page.

[0096] In this embodiment, when the target cross-platform engine instance is found from the memory, the target cross-platform page is directly loaded using the target cross-platform engine instance to jump from the currently displayed page to the target cross-platform page to realize the display of the cross-platform page.

[0097] Specifically, the page information (eg, page identifier) ​​corresponding to the target cross-platform page is obtained, and the page information is used as an input parameter of the target cross-platform engine instance, so that the target cross-platform engine instance loads the corresponding cross-platform page.

[0098] Accordingly, during the operation of the target application, multiple cross-platform pages may need to be opened, so the target cross-platform engine instance needs to be used to load different cross-platform pages. When the target cross-platform engine instance loads different cross-platform pages, the page information corresponding to the cross-platform page to be loaded is obtained and used as an input parameter of the target cross-platform engine instance, so that the target cross-platform engine instance loads the corresponding cross-platform page.

[0099] Optionally, since the target application page needs to be pushed into the routing stack when it is opened, when returning to a page in the routing stack, the page can be directly obtained from the routing stack without reloading. Correspondingly, when jumping back to the target cross-platform page from the native page and the target cross-platform page exists in the routing stack, the target cross-platform page can be directly obtained from the routing stack without calling the cross-platform engine instance again for loading.

[0100] It can be understood that when a page is opened, the page will be pushed into the stack, and when the page is exited, the page will be popped out of the stack.

[0101] In this embodiment, since the target cross-platform engine instance is pre-built through a custom operation, the target cross-platform engine instance is a custom cross-platform engine instance rather than a cross-platform engine instance created by the system by default. Therefore, after the target cross-platform engine instance is saved in the memory, the target cross-platform engine instance can be obtained from the memory. Therefore, when jumping from the native page to the cross-platform page, the target cross-platform engine instance can be directly called from the memory to load the corresponding cross-platform page, avoiding the need to re-create the cross-platform engine instance to load the cross-platform page using the re-created cross-platform engine instance due to the inability to obtain the cross-platform engine instance created by the system by default.

[0102] From the above description, it can be seen that during the process of the user using the target application, when the first trigger operation is received, indicating that it is necessary to jump from the currently displayed native page to the corresponding cross-platform page, that is, the target cross-platform page, the custom cross-platform engine instance is directly called from the memory, that is, the target cross-platform engine instance pre-built through the custom operation, so as to use the target cross-platform engine instance to load the target cross-platform page to realize the display of the cross-platform page without creating a new cross-platform engine instance, so that only one cross-platform engine instance can exist in the memory, thereby reducing memory usage, optimizing the performance of the target application, and improving the user experience.

[0103] like Figure 6 As shown, Figure 6This is a flowchart of another page display method according to an exemplary embodiment of this specification. When the target application is started, a target cross-platform engine instance is constructed to load a cross-platform page using the target cross-platform engine instance. This process will be described in detail below in conjunction with a specific embodiment. Figure 6 As shown, the method comprises the following steps:

[0104] Step 601: In response to a start operation of a target application, a target cross-platform engine instance is constructed through a cross-platform engine instance custom operation.

[0105] In this embodiment, when a start operation of a target application program inputted by a user is received, the target application program is started. When the target application program is started, a cross-platform engine instance customization operation is performed to generate a customized cross-platform engine instance, namely, a target cross-platform engine instance.

[0106] The execution of the cross-platform engine instance customization operation is actually a process in which the processor executes the customized cross-platform engine instance generation code, and the code is pre-written by relevant personnel.

[0107] The start-up operation includes a click operation, a voice operation, a gesture operation, etc. For example, when a user clicks an icon corresponding to a target application, it indicates that the user has input a corresponding start-up operation.

[0108] Optionally, after executing the target method corresponding to the target application, a target cross-platform engine instance is constructed through a cross-platform engine instance custom operation.

[0109] Among them, the target method includes the main method.

[0110] Optionally, after the target cross-platform engine instance is constructed, the relevant information of the target cross-platform engine instance (e.g., instance name) is saved in a preset plug-in table. The function of the plug-in table is similar to the registration table. After the relevant information of the cross-platform engine instance is saved in the plug-in table, the cross-platform engine can be used to load the cross-platform page.

[0111] In this embodiment, optionally, in response to the start-up operation of the target application, that is, in the process of starting the target application, a second preset page corresponding to the target application is displayed, wherein the second preset page is a start-up page corresponding to the target application.

[0112] Optionally, after the target cross-platform engine instance is constructed, the target cross-platform engine instance is initialized, that is, the target cross-platform engine instance is started.

[0113] Step 602: Store the target cross-platform engine instance in the memory.

[0114] In this embodiment, after the target cross-platform engine instance is created, the target cross-platform engine instance is stored in the memory, so that when the cross-platform engine instance is used to load the corresponding cross-platform page later, the target cross-platform engine instance in the memory can be directly used without recreating the cross-platform engine instance.

[0115] Specifically, after the target cross-platform engine instance is created, the target cross-platform engine instance is initialized, and the initialized target cross-platform engine instance is added to the memory.

[0116] Optionally, the target cross-platform engine instance can be added to the cache so that when the target cross-platform engine instance is subsequently called, it can be quickly obtained from the cache, thereby improving the loading speed of the page.

[0117] Optionally, in order to facilitate searching the target cross-platform engine instance from the memory, i.e., the cache, in the process of building the target cross-platform engine instance, it is necessary to define a global variable corresponding to the target cross-platform engine instance and store the global variable in the memory. Specifically, the global variable can be stored in the cache so that when the target cross-platform engine instance is subsequently called, the global variable can be searched from the memory and the target cross-platform engine instance can be obtained from the location pointed to by the global variable.

[0118] Among them, defining global variables actually means executing the code that defines the global variables.

[0119] The code for creating a custom cross-platform engine instance, defining global variables, and storing them in the cache is as follows:

[0120] @objc func getFlutterEngine()->FlutterEngine{

[0121] / *

[0122] Search the cache for the Engine variable. If it does not exist, initialize it once. If it does exist, return it directly.

[0123] * /

[0124] if (flutterEngine == nil) {

[0125] / *

[0126] Initialize a custom Engine

[0127] * /

[0128] let flutterEngin=FlutterEngine(name:"park.flutter",project:nil);

[0129] / *

[0130] Start the Engine

[0131] * /

[0132] flutterEngin.run(withEntrypoint:nil);

[0133] GeneratedPluginRegistrant.register(with:flutterEngin);

[0134] / *

[0135] Define global variable assignment Engine and store it in memory

[0136] * /

[0137] flutterEngine=flutterEngin;

[0138] }

[0139] / *

[0140] Return the cached Engine

[0141] * /

[0142] return flutterEngine;

[0143] }

[0144] Optionally, based on the target cross-platform engine instance, a first preset page corresponding to the target application is displayed.

[0145] In this embodiment, after the target cross-platform engine instance is constructed, the target cross-platform engine instance is initialized, and the first preset page corresponding to the target application is loaded using the initialized target cross-platform engine instance.

[0146] The first preset page is the home page corresponding to the target application, that is, the first page to be displayed after the startup page.

[0147] The code for obtaining the target cross-platform engine instance from the cache and using the target cross-platform engine instance to load the homepage is as follows:

[0148] / *

[0149] Get the Engine object from the cache

[0150] * /

[0151] self.flutterEngine=self.getFlutterEngine(;

[0152] / *

[0153] Initialize the application's homepage with a custom engine, the target cross-platform engine instance

[0154] * /

[0155] self.flutterController=FlutterViewController(engine:self.flutterEngine,nibName:nil,bundle:nil);

[0156] let image=UllmageView.init(image:Ullmage.init(named:"lanch._img));

[0157] image.frame=CGRect.init(origin:CGPoint.init(x:0,y:0),size:self.window.bounds.size);

[0158] image.contentMode=.scaleAspectFill;

[0159] self.flutterController! .view.addSubview(image);

[0160] / *

[0161] Start Home Page

[0162] * /

[0163] let navigationController=TaoWenLvNavigationController.init(rootViewController:self.flutterController!)

[0164] self.window.rootViewController=navigationController;

[0165] self.window.backgroundColor=UlColor.white;

[0166] self.flutterController?.fd prefersNavigationBarHidden=true;

[0167] BOERouter <anyobject>.shared().navigationController=navigationController;

[0168] Step 603: In response to a first trigger operation in the target application, a target cross-platform engine instance pre-built by a custom operation is obtained from the memory, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page.

[0169] In this embodiment, a global variable corresponding to the target cross-platform engine instance is obtained from the memory, and based on the global variable, the target cross-platform engine instance is determined from the memory, that is, the target cross-platform engine instance is obtained from the position pointed to by the global variable. The global variable is defined when the target cross-platform engine instance is constructed, so as to initialize a new cross-platform page, that is, the target cross-platform page, using the target cross-platform engine instance. The specific implementation is as follows:

[0170] / *

[0171] Cache pool obtains Engine

[0172] * /

[0173] AppDelegate*ad=(AppDelegate*)[UlApplicationsharedApplication].delegate;

[0174] FlutterEngine*engine=[ad getFlutterEngine];

[0175] engine.viewController=nil;

[0176] / *

[0177] Initialize a new Flutter page with the cached Engine, the target cross-platform engine instance

[0178] * /

[0179] FlutterViewController*flutterController=[[FlutterViewControlleralloc]initWithEngine:engine nibName:nil bundle:nil];

[0180] flutterController.fd prefersNavigationBarHidden=YES;

[0181] [self.navigationController pushViewController:flutterControlleranimated:YES];

[0182] Step 604: Load the target cross-platform page based on the target cross-platform engine instance.

[0183] In this embodiment, for existing native applications, since most pages are native pages, when developing new services based on Flutter requirements, the Flutter page needs to be embedded in the original page. Therefore, when users use the application, services involving jumping from native pages to Flutter pages, each time the native page jumps to the Flutter page (such as Figure 7 As shown in the figure, when jumping from page A to page B and from page C to page D), a Flutter engine needs to be started, resulting in the problem of multiple Flutter engines in memory, which greatly consumes system resources. Therefore, in order to avoid the existence of multiple Flutter engines in memory, this application abandons the system's default Flutter engine and instead adopts a custom controllable Flutter engine to store the Flutter engine in the cache pool. When it is necessary to jump from the native page to the Flutter page, the Flutter engine can be taken out of the cache pool to use the Flutter engine to load the Flutter page, so that during the operation of the application, there can be only one Flutter engine, which solves the problem of memory and resource loss on the basis of achieving cross-platform, and saves human development costs.

[0184] In this embodiment, when the target application is started, the system default cross-platform engine is not started. Instead, a cross-platform engine instance customization operation is performed to create an autonomous and controllable cross-platform engine instance, namely, a target cross-platform engine instance, so as to use the target cross-platform engine instance to load a cross-platform page. Therefore, in the scenario of jumping from a native page to a cross-platform page, the target cross-platform engine instance can be directly used to load the corresponding cross-platform page without creating a new cross-platform engine instance, so that there can be only one cross-platform engine instance in the memory, thereby reducing memory usage, reducing resource loss, and improving user experience on the basis of achieving cross-platform.

[0185] like Figure 8 As shown, Figure 8 This is a flow chart of another page display method according to an exemplary embodiment of this specification. In order to avoid the white screen problem, the corresponding page is inserted when the target cross-platform engine instance is initialized. The following will describe this process in detail in conjunction with a specific embodiment. Figure 8 As shown, the method comprises the following steps:

[0186] Step 801: When the second preset page corresponding to the target application is displayed and the first preset page corresponding to the target application is not displayed, a third preset page is displayed.

[0187] In this embodiment, since the target cross-platform engine instance is generated based on the relevant custom code, that is, the target cross-platform engine instance is a custom cross-platform engine instance, the time required to initialize the custom cross-platform engine instance is longer than the time required to initialize the default cross-platform engine instance. Therefore, when initializing the custom cross-platform engine instance, the startup page (such as Fig. 9 The second preset page has been displayed, but the first preset page loaded by the cross-platform engine instance (such as Fig. 9 The home page shown in (c), i.e. the login page, has not been rendered yet, and a blank page appears for a certain period of time (such as Fig. 9 The blank page shown in (b) in the figure greatly affects the user experience.

[0188] Optionally, the first preset page (i.e., home page), the second preset page (i.e., startup page) and the third preset page are all saved to the target application, and the corresponding positions in the installation package corresponding to the target application, that is, the display information corresponding to the first preset page (for example, display picture) is saved in the first preset position in the installation package, the display information corresponding to the second preset page is saved in the second preset position in the installation package, and the display information corresponding to the third preset page is saved in the third preset position in the installation package.

[0189] When the corresponding preset page needs to be loaded, that is, when the display information corresponding to the corresponding preset page needs to be loaded, it is obtained from the corresponding preset position based on the relevant loading method, that is, the function. For example, when the display information corresponding to the third page is loaded, the relevant loading method is called to obtain the display information from the third preset position and display it.

[0190] Among them, the first preset position, the second preset position and the third preset position can be set according to requirements and are not limited here.

[0191] In addition, optionally, after the target application is installed in the mobile terminal, the display information corresponding to the second preset page stored in the second preset location is saved to a specific location in the mobile terminal, so as to facilitate the subsequent acquisition of the display information from the specific location using the native layer.

[0192] In order to avoid a blank page due to a long initialization time of the target cross-platform engine instance, when the second preset page is displayed and the first preset page has not been displayed, that is, when the target cross-platform engine instance is initialized, the third preset page is inserted, so that the mobile terminal displays the third preset page and avoids displaying a blank page, thereby avoiding users' doubts about the white screen and ensuring user experience.

[0193] Optionally, the display content of the third preset page is the same as the display content of the second preset page.

[0194] Specifically, in order to ensure a seamless user experience, the display content of the third preset page can be the same as the display content of the second preset page. That is, when initializing the target cross-platform engine instance, the top window of the mobile terminal, that is, the topmost layer of the currently displayed page, can display the same picture as the startup page, so that the user sees the same content as the startup page and achieves seamless switching.

[0195] In this embodiment, in order to avoid affecting the display of the first preset page, the third preset page needs to be removed. Therefore, whether the third preset page can be removed can be determined based on the following two methods.

[0196] One way is to remove the third preset page in response to displaying the first preset page.

[0197] Specifically, when the first preset page needs to be displayed, it indicates that the target cross-platform engine instance has been initialized and the first preset page can be loaded using the target cross-platform engine instance. There is no need to continue displaying the third preset page, thereby removing the third preset page, that is, removing the picture displayed on the current page that is the same as the startup page, so as to avoid affecting the display of the first preset page.

[0198] Another way is to remove the third preset page in response to reaching the target display time corresponding to the third preset page, where the target display time represents the total duration of displaying the third preset page.

[0199] Specifically, the display time corresponding to the third preset page is obtained, and the timing is started from the display of the third preset page to obtain the current display time. When it is determined that the current display time is greater than or equal to the target display time corresponding to the third preset page, it indicates that the third preset page can be stopped from being displayed. The third preset page is then removed to avoid affecting the display of the first preset page.

[0200] The target display time can be set according to actual needs, for example, the target display time is 1.5 seconds. Accordingly, the target display time can be stored in a designated location corresponding to the target application, for example, the target display time exists in a loading method related to loading the third preset page.

[0201] Step 802: In response to a first trigger operation in a target application, a target cross-platform engine instance pre-built by a custom operation is obtained from a memory, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page.

[0202] Step 803: Based on the target cross-platform engine instance, load the target cross-platform page.

[0203] In this embodiment, when the target cross-platform engine instance is initialized, that is, when the second preset page has been displayed but the first preset page has not been rendered, a transition page, that is, a third preset page, is displayed to avoid the white screen problem. When the first preset page can be displayed, the third preset page is stopped from being displayed to achieve the normal display of the first preset page, so that the transition to the first preset page can be successfully achieved, ensuring the user's senseless experience and improving the user's satisfaction.

[0204] Corresponding to the embodiments of the aforementioned method, this specification also provides embodiments of a page display device and a terminal to which it is applied.

[0205] The embodiments of the device for displaying pages in this specification can be applied to mobile terminals, such as mobile phones, tablet computers, etc. The device embodiments can be implemented by software, hardware, or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them. From the hardware level, if Fig.10 As shown, it is a hardware structure diagram of a mobile terminal where the page display device of the embodiment of this specification is located, except Fig.10 In addition to the processor 1010, memory 1030, network interface 1020, and non-volatile memory 1040 shown, the mobile terminal where the page display device 1031 is located in the embodiment may also include other hardware according to the actual function of the mobile terminal, which will not be described in detail.

[0206] like Fig.11 As shown, Fig.11 1 is a block diagram of a page display device according to an exemplary embodiment of the present specification, the device comprising:

[0207] The instance acquisition module 1110 is used to obtain a target cross-platform engine instance pre-built through a custom operation from the memory in response to a first trigger operation in the target application, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page.

[0208] The page display module 1120 is used to load a target cross-platform page based on the target cross-platform engine instance.

[0209] Optionally, the target cross-platform engine instance includes a target Flutter engine instance.

[0210] In another embodiment of the present application, in the above Fig.11 Based on the embodiment, the page display device also includes an instance construction module.

[0211] The example building blocks are specifically used to:

[0212] Before obtaining the target cross-platform engine instance pre-built through the custom operation from the memory in response to the first trigger operation in the target application, the target cross-platform engine instance is built through the cross-platform engine instance custom operation in response to the start operation of the target application.

[0213] Store the target cross-platform engine instance into memory.

[0214] In any embodiment, optionally, the instance acquisition module 1110 is used to:

[0215] A global variable corresponding to the target cross-platform engine instance is obtained from the memory, and based on the global variable, the target cross-platform engine instance is determined from the memory, wherein the global variable is defined when the target cross-platform engine instance is constructed.

[0216] In this embodiment, optionally, the instance construction module is further used to:

[0217] After the target cross-platform engine instance is stored in the memory, a first preset page corresponding to the target application is displayed based on the target cross-platform engine instance, wherein the first preset page is a homepage corresponding to the target application.

[0218] In this embodiment, optionally, the instance construction module is further used to:

[0219] In response to the start-up operation of the target application, a second preset page corresponding to the target application is displayed, wherein the second preset page is a start-up page corresponding to the target application.

[0220] In this embodiment, optionally, the instance construction module is further used to:

[0221] After the target cross-platform engine instance is constructed through the cross-platform engine instance custom operation, the target cross-platform engine instance is initialized.

[0222] In another embodiment of the present application, in the above Fig.11 Based on the embodiment, the page display device also includes a page processing module.

[0223] The page processing module is specifically used for:

[0224] When the second preset page corresponding to the target application is displayed completely and the first preset page corresponding to the target application is not displayed, the third preset page is displayed.

[0225] In this embodiment, optionally, the page processing module is further used to:

[0226] In response to displaying the first preset page, the third preset page is removed.

[0227] Optionally, the display content of the third preset page is the same as the display content of the second preset page.

[0228] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0229] Accordingly, the present specification also provides a mobile terminal, the terminal comprising a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to:

[0230] In response to a first trigger operation in a target application, obtaining a target cross-platform engine instance pre-built through a custom operation from a memory, wherein the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page;

[0231] Based on the target cross-platform engine instance, the target cross-platform page is loaded.

[0232] An embodiment of the present application provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed by a processor, the above method steps are implemented.

[0233] An embodiment of the present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the above method steps are implemented.

[0234] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0235] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0236] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0237] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0238] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.< / anyobject>

Claims

1. A page display method, characterized in that: include: In response to a start operation of a target application, building a target cross-platform engine instance through a cross-platform engine instance custom operation; Storing the target cross-platform engine instance in memory; In response to a first trigger operation in a target application, a global variable corresponding to a target cross-platform engine instance is obtained from a memory, and based on the global variable, the target cross-platform engine instance is determined from the memory, wherein the global variable is defined when the target cross-platform engine instance is constructed, and the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page; Based on the target cross-platform engine instance, the target cross-platform page is loaded.

2. The method according to claim 1, characterized in that The method further comprises: Based on the target cross-platform engine instance, a first preset page corresponding to the target application is displayed; wherein the first preset page is a homepage corresponding to the target application.

3. The method according to claim 1, characterized in that The method further comprises: In response to the start-up operation of the target application, a second preset page corresponding to the target application is displayed; wherein the second preset page is a start-up page corresponding to the target application.

4. The method according to claim 1, characterized in that: The method further comprises: When the second preset page corresponding to the target application is displayed completely and the first preset page corresponding to the target application is not displayed, the third preset page is displayed.

5. The method according to claim 4, characterized in that The method further comprises: In response to displaying the first preset page, the third preset page is removed.

6. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Initialize the target cross-platform engine instance.

7. The method according to claim 4 or 5, characterized in that: The display content of the third preset page is the same as the display content of the second preset page.

8. The method according to any one of claims 1 to 5, characterized in that: The target cross-platform engine instance includes a target Flutter engine instance.

9. A page display device, characterized in that: The device comprises: An instance construction module, configured to respond to a start operation of a target application, construct a target cross-platform engine instance through a cross-platform engine instance custom operation, and store the target cross-platform engine instance in a memory; an instance acquisition module, configured to, in response to a first trigger operation in a target application, acquire a global variable corresponding to a target cross-platform engine instance from a memory, and determine the target cross-platform engine instance from the memory based on the global variable, wherein the global variable is defined when the target cross-platform engine instance is constructed, and the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page; The page display module is used to load the target cross-platform page based on the target cross-platform engine instance.

10. A mobile terminal, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the following method is implemented: In response to a start operation of a target application, construct a target cross-platform engine instance through a cross-platform engine instance custom operation, and store the target cross-platform engine instance in a memory; In response to a first trigger operation in a target application, a global variable corresponding to a target cross-platform engine instance is obtained from a memory, and based on the global variable, the target cross-platform engine instance is determined from the memory, wherein the global variable is defined when the target cross-platform engine instance is constructed, and the first trigger operation is used to request a jump from a native page of the target application to a target cross-platform page; Based on the target cross-platform engine instance, the target cross-platform page is loaded.