WO2023245367A1 - Hybrid application rendering system, rendering method, electronic device, and storage medium - Google Patents
Hybrid application rendering system, rendering method, electronic device, and storage medium Download PDFInfo
- Publication number
- WO2023245367A1 WO2023245367A1 PCT/CN2022/099931 CN2022099931W WO2023245367A1 WO 2023245367 A1 WO2023245367 A1 WO 2023245367A1 CN 2022099931 W CN2022099931 W CN 2022099931W WO 2023245367 A1 WO2023245367 A1 WO 2023245367A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- tree
- layout
- node
- framework
- dom
- Prior art date
Links
- 238000009877 rendering Methods 0.000 title claims abstract description 86
- 238000000034 method Methods 0.000 title claims abstract description 25
- 230000006870 function Effects 0.000 claims abstract description 50
- 238000012545 processing Methods 0.000 claims abstract description 37
- 230000004044 response Effects 0.000 claims abstract description 27
- 230000003993 interaction Effects 0.000 claims abstract description 20
- 238000010276 construction Methods 0.000 claims abstract description 7
- 238000013507 mapping Methods 0.000 claims description 42
- 230000002452 interceptive effect Effects 0.000 claims description 33
- 238000004590 computer program Methods 0.000 claims description 9
- 230000006978 adaptation Effects 0.000 claims description 8
- 230000003247 decreasing effect Effects 0.000 abstract 1
- 238000007726 management method Methods 0.000 description 12
- 238000004891 communication Methods 0.000 description 11
- 238000010586 diagram Methods 0.000 description 10
- 239000008186 active pharmaceutical agent Substances 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 9
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 230000001133 acceleration Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000007792 addition Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 201000001098 delayed sleep phase syndrome Diseases 0.000 description 1
- 208000033921 delayed sleep phase type circadian rhythm sleep disease Diseases 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 235000019800 disodium phosphate Nutrition 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 239000007788 liquid Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000007789 sealing Methods 0.000 description 1
- 239000004984 smart glass Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
- 239000010409 thin film Substances 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Definitions
- the present disclosure relates to the field of control technology, and in particular, to a hybrid rendering application system, a rendering method, an electronic device and a storage medium.
- the inventor found that existing hybrid rendering application frameworks are divided into JS frameworks and native frameworks.
- the JS framework has management functions such as UI tree construction and update, etc.
- UI tree i.e. DOM tree
- the above-mentioned JS framework usually uses the V8 engine, and the VS engine usually also occupies a large amount of memory.
- the hybrid rendering application framework cannot be applied to electronic devices with small memory.
- the present disclosure provides a hybrid rendering application system, rendering method, electronic device and storage medium to solve the deficiencies of related technologies.
- the native framework includes a construction interface API for creating and/or updating the DOM tree, Widget tree and Layout tree in the UI tree in response to a request from the JS framework; and in response to detecting an interactive operation on the user interface Send interactive operation events to the JS framework;
- the JS framework includes a callback request interface API for updating the UI tree in response to interactive operation events detected by the native framework;
- the native framework creates a UI tree, including:
- the initial DOM tree includes multiple DOM nodes
- the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;
- the Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
- the DOM node When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree according to the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
- the parent node of the layout node When the parent node of the layout node does not participate in the web page layout, obtain the size of the element corresponding to the parent node; the size of the element corresponding to the parent node is a preset size; perform layout processing on the layout node according to the preset size ;or,
- the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
- the native framework updates the UI tree, including:
- the native framework creates and/or updates a UI tree in response to a request from the JS framework, the UI tree including a DOM tree, a Widget tree, and a Layout tree; and in response to detecting an interaction with the user interface, the JS framework Send interaction events;
- the JS framework outputs an update notification in response to the interaction event detected by the native framework to update the UI tree;
- the rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
- the native framework creates a UI tree, including:
- the initial DOM tree includes a plurality of DOM nodes
- the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;
- the Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
- create a Widget mapping for each DOM node of the initial DOM tree including:
- the DOM node When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree according to the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
- an electronic device including:
- the memory is used to store computer programs executable by the processor
- the DOM tree function is adjusted to be processed within the native framework. Since the memory occupied by the DOM tree using the native language is much smaller than the memory occupied by the DOM tree implemented in the JS language, the size of the memory occupied by the hybrid rendering application system can be reduced. Reduce memory usage and improve memory usage.
- Figure 5 is a schematic diagram of a Widget tree according to an exemplary embodiment.
- Figure 6 is a schematic diagram of a layout node according to an exemplary embodiment.
- FIG. 8 is a block diagram of an electronic device according to an exemplary embodiment.
- the JS framework sends interactive operation events.
- the JS framework includes a callback request interface API for updating the UI tree in response to interaction events detected by the native framework.
- the rendering engine is used to perform rendering and generate user interfaces based on the Widget tree output by the native framework, such as LVGL engine, IMGUI engine, QT engine, etc., which are not limited here.
- the node Doc in the initial DOM tree corresponds to the Widget object scene in the Widget tree.
- the above-mentioned Widget tree also has a mapping relationship between nodes in the DOM tree, so the above-mentioned Widget mapping includes a mapping relationship between the DOM node and the Widget object and a mapping relationship between the Widget object and the Widget object.
- the creation of the Widget tree in this step can be performed by the Widget module in the native framework.
- the native framework can create a Layout tree corresponding to the Widget tree.
- the layout node ie, layout node
- the layout node can be created synchronously.
- the layout node Layout node div includes three child nodes Layout node Text.
- the native framework may synchronize the layout result to the style attribute of the Widget tree.
- the synchronized layout results in this step can be executed by the Widget module in the native framework.
- the native framework can update the UI tree, see Figure 7, including:
- step 72 when an interactive operation that triggers the user interface is detected, the target DOM node corresponding to the interactive operation is notified.
- the native framework can detect user interface interactions, generate an event when detecting an interaction that triggers the user interface, and send the above event to the JS engine. Detection of interactive operations and notifications in this step can be performed by the Widget module in the native framework.
- the native framework may obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification.
- the callback function handle search in this step can be performed by the DOM module in the native framework.
- the hybrid rendering application system provided in this embodiment further includes an engine adaptation layer JSI.
- the engine adaptation layer JSI communicates with the JS engine and is used to adapt to different types of JS engines.
- the JS engine can be V8 engine, QuickJS engine, Duktape engine, JerryScript engine, etc.
- the engine adaptation layer JSI can seamlessly switch between the above multiple JS engines by sealing the JS API into a unified format, so as to replace it with a light engine. The effect of the magnitude engine.
- the embodiment of the present disclosure also provides a hybrid rendering method, which is applied to an electronic device.
- the electronic device is provided with a hybrid rendering application system, and the system includes JS framework, native framework and rendering engine; the methods include:
- the rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
- the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;
- the Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
- creating a Widget mapping for each DOM node of the initial DOM tree includes:
- the DOM node When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree according to the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
- traversing the layout nodes in the Layout tree and performing layout processing on the layout nodes includes:
- the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
- the native framework updates the UI tree, including:
- FIG. 8 is a block diagram of an electronic device according to an exemplary embodiment.
- the electronic device 800 may be a smartphone, a computer, a digital broadcast terminal, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
- Processing component 802 generally controls the overall operations of electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations.
- Processing component 802 may include one or more processors 820 to execute computer programs. Additionally, processing component 802 may include one or more modules that facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
- Power supply component 806 provides power to various components of electronic device 800 .
- Power supply components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 800 .
- the power supply component 806 may include a power supply chip, and the controller can communicate with the power supply chip to control the power supply chip to turn on or off the switching device, so that the battery supplies power to the motherboard circuit or not.
- Multimedia component 808 includes a screen that provides an output interface between electronic device 800 and the target object.
- the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input information from the target object.
- the touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. A touch sensor can not only sense the boundaries of a touch or swipe action, but also detect the duration and pressure associated with the touch or swipe action.
- Audio component 810 is configured to output and/or input audio file information.
- audio component 810 includes a microphone (MIC) configured to receive external audio file information when electronic device 800 is in operating modes, such as call mode, recording mode, and voice recognition mode. The received audio file information may be further stored in memory 804 or sent via communication component 816 .
- audio component 810 also includes a speaker for outputting audio file information.
- the I/O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which may be a keyboard, a click wheel, a button, etc.
- Sensor component 814 includes one or more sensors for providing various aspects of status assessment for electronic device 800 .
- the sensor component 814 can detect the open/closed state of the electronic device 800, the relative positioning of components, such as the display screen and keypad of the electronic device 800, and the sensor component 814 can also detect the position change of the electronic device 800 or a component. , the presence or absence of the target object in contact with the electronic device 800 , the orientation or acceleration/deceleration of the electronic device 800 and the temperature change of the electronic device 800 .
- the sensor component 814 may include a magnetic sensor, a gyroscope, and a magnetic field sensor, where the magnetic field sensor includes at least one of the following: a Hall sensor, a thin film magnetoresistive sensor, and a magnetic liquid acceleration sensor.
- Communication component 816 is configured to facilitate wired or wireless communication between electronic device 800 and other devices.
- the electronic device 800 can access a wireless network based on communication standards, such as WiFi, 2G, 3G, 4G, 5G, or a combination thereof.
- communication component 816 receives broadcast information or broadcast-related information from an external broadcast management system via a broadcast channel.
- communications component 816 also includes a near field communications (NFC) module to facilitate short-range communications.
- NFC near field communications
- the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
- RFID radio frequency identification
- IrDA infrared data association
- UWB ultra-wideband
- Bluetooth Bluetooth
- electronic device 800 may be configured by one or more application specific integrated circuits (ASICs), digital information processors (DSPs), digital information processing devices (DSPDs), programmable logic devices (PLDs), field programmable Programmed gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation.
- ASICs application specific integrated circuits
- DSPs digital information processors
- DSPDs digital information processing devices
- PLDs programmable logic devices
- FPGA field programmable Programmed gate array
- controller microcontroller, microprocessor or other electronic component implementation.
- a non-transitory computer-readable storage medium such as a memory 804 including instructions, and the above-mentioned executable computer program can be executed by a processor.
- the readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
The present disclosure relates to a hybrid application rendering system, a rendering method, an electronic device, and a storage medium. The system comprises a JS framework, a native framework and a rendering engine; the JS framework has an application lifecycle management function and an application logic processing function; the native framework has a UI tree management function; a UI tree comprises a DOM tree, a widget tree, and a layout tree; the native framework comprises an interface construction API, and is used for creating and/or updating the DOM tree, the widget tree and the layout tree in the UI tree in response to a request of the JS framework, and sending an interaction operation event to the JS framework in response to detecting an interaction operation on the user interface; the JS framework comprises a callback request interface API, and is used for updating the UI tree in response to the interaction operation event detected by the native framework; and the rendering engine is used to execute rendering and generating a user interface according to the widget tree output by the native framework. The present embodiment can reduce the amount of memory occupied by the hybrid application rendering system, decreasing overall memory usage.
Description
本公开涉及控制技术领域,尤其涉及一种混合渲染应用系统、渲染方法、电子设备和存储介质。The present disclosure relates to the field of control technology, and in particular, to a hybrid rendering application system, a rendering method, an electronic device and a storage medium.
目前,现有的混合渲染应用框架是为智能手机或者笔记本等内存较大的设备而设计,上述混合渲染应用框架为每个应用程序渲染时,通常单个应用需要消耗数十及到上百兆字节大小的内存。当电子设备的内存只有数十兆字节时通常无法使用上述混合渲染应用框架。Currently, existing hybrid rendering application frameworks are designed for devices with large memory such as smartphones or laptops. When the above hybrid rendering application framework renders each application, a single application usually consumes tens to hundreds of megabytes. section size of memory. The above hybrid rendering application framework is generally not available when the memory of the electronic device is only tens of megabytes.
在实现本公开方案的过程中,发明人发现:现有的混合渲染应用框架中分为JS框架和原生框架,JS框架具有UI树构建与更新等管理功能等。在JS框架创建UI树(即DOM树)时,需要占用较大的内存。加之,上述JS框架通常使用V8引擎,该VS引擎通常也会占据较大的内存。最终,混合渲染应用框架无法应用到内存较小的电子设备。In the process of implementing the disclosed solution, the inventor found that existing hybrid rendering application frameworks are divided into JS frameworks and native frameworks. The JS framework has management functions such as UI tree construction and update, etc. When the JS framework creates a UI tree (i.e. DOM tree), it requires a large amount of memory. In addition, the above-mentioned JS framework usually uses the V8 engine, and the VS engine usually also occupies a large amount of memory. Ultimately, the hybrid rendering application framework cannot be applied to electronic devices with small memory.
发明内容Contents of the invention
本公开提供一种混合渲染应用系统、渲染方法、电子设备和存储介质,以解决相关技术的不足。The present disclosure provides a hybrid rendering application system, rendering method, electronic device and storage medium to solve the deficiencies of related technologies.
根据本公开实施例的第一方面,提供一种混合渲染应用系统,所述系统包括JS框架、原生框架和渲染引擎;所述JS框架具有应用生命周期管理功能和应用逻辑处理功能;所述原生框架具有UI树管理功能;其中,所述UI树包括DOM树、Widget树和Layout树;According to a first aspect of an embodiment of the present disclosure, a hybrid rendering application system is provided. The system includes a JS framework, a native framework and a rendering engine; the JS framework has an application life cycle management function and an application logic processing function; the native The framework has a UI tree management function; wherein the UI tree includes a DOM tree, a Widget tree and a Layout tree;
所述原生框架包括构建接口API,用于响应于所述JS框架的请求创建和/或更新所述UI树中的DOM树、Widget树和Layout树;以及响应于检测到对用户界面的交互操作向所述JS框架发送交互操作事件;The native framework includes a construction interface API for creating and/or updating the DOM tree, Widget tree and Layout tree in the UI tree in response to a request from the JS framework; and in response to detecting an interactive operation on the user interface Send interactive operation events to the JS framework;
所述JS框架包括回调请求接口API,用于响应于所述原生框架检测到的交互操作事件,以更新所述UI树;The JS framework includes a callback request interface API for updating the UI tree in response to interactive operation events detected by the native framework;
所述渲染引擎用于根据所述原生框架输出的Widget树执行渲染并生成用户界面。The rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
可选地,所述原生框架创建UI树,包括:Optionally, the native framework creates a UI tree, including:
创建初始DOM树;所述初始DOM树包括多个DOM节点;Create an initial DOM tree; the initial DOM tree includes multiple DOM nodes;
为所述初始DOM树的每个DOM节点创建Widget映射,获得Widget树;所述Widget映射包括所述DOM节点与所述Widget对象之间的映射关系以及所述Widget对象与所述Widget对象之间的映射关系;Create a Widget mapping for each DOM node of the initial DOM tree to obtain a Widget tree; the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;
创建所述Widget树对应的Layout树;Create a Layout tree corresponding to the Widget tree;
遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,得到布局结果;Traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes to obtain a layout result;
将所述布局结果同步到所述Widget树的样式属性;Synchronize the layout result to the style attribute of the Widget tree;
将所述Widget树发送给所述原生框架内的渲染引擎,以使所述渲染引擎执行渲染操作。The Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
可选地,为所述初始DOM树的每个DOM节点创建Widget映射,包括:Optionally, create a Widget mapping for each DOM node of the initial DOM tree, including:
当所述DOM节点为动态节点时,从JS引擎的观察者获取新值;根据所述新值创建DOM子树;为所述DOM子树的DOM节点创建Widget映射;重复从JS引擎的观察者获取新值的步骤,直至不满足所述动态节点的条件为止。When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree according to the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
可选地,遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,包括:Optionally, traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes, including:
当所述布局节点的父节点不参加网页布局时,获取所述父节点对应元素的尺寸;所述父节点对应元素的尺寸为预设尺寸;根据所述预设尺寸对所述布局节点进行布局处理;或者,When the parent node of the layout node does not participate in the web page layout, obtain the size of the element corresponding to the parent node; the size of the element corresponding to the parent node is a preset size; perform layout processing on the layout node according to the preset size ;or,
当所述布局节点的父节点参与网页布局时,对所述父节点进行标记处理;当所述父节点外部布局完成后获得所述父节点对应元素的尺寸时,对所述布局节点进行布局处理。When the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
可选地,所述原生框架更新所述UI树,包括:Optionally, the native framework updates the UI tree, including:
当创建用户界面时,在所述UI树的DOM节点上进行交互回调注册,得到所述DOM节点对应的回调函数句柄;When creating a user interface, perform interactive callback registration on the DOM node of the UI tree to obtain the callback function handle corresponding to the DOM node;
当检测到触发所述用户界面的交互操作时,通知所述交互操作对应的目标DOM节点;When an interactive operation that triggers the user interface is detected, notify the target DOM node corresponding to the interactive operation;
根据所述交互操作对应的操作类型查找回调函数句柄;当检测到回调函数句柄时,触发JS框架执行具体的回调函数;Search the callback function handle according to the operation type corresponding to the interactive operation; when the callback function handle is detected, trigger the JS framework to execute the specific callback function;
获取所述JS框架发送的更新通知,并根据所述更新通知更新所述UI树的结构和/或内容。Obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification.
可选地,所述系统还包括引擎适配层;所述引擎适配层与所述JS引擎通信,用于适配不同类型的JS引擎。Optionally, the system further includes an engine adaptation layer; the engine adaptation layer communicates with the JS engine and is used to adapt to different types of JS engines.
根据本公开实施例的第二方面,提供一种混合渲染方法,应用于电子设备,所述电子设备设置有混合渲染应用系统,所述系统包括JS框架、原生框架和渲染引擎;所述方法包括:According to a second aspect of the embodiment of the present disclosure, a hybrid rendering method is provided, which is applied to an electronic device. The electronic device is provided with a hybrid rendering application system. The system includes a JS framework, a native framework and a rendering engine; the method includes :
所述原生框架响应于所述JS框架的请求创建和/或更新UI树,所述UI树包括DOM树、Widget树和Layout树;以及响应于检测到对用户界面的交互操作向所述JS框架发送交互操作事件;The native framework creates and/or updates a UI tree in response to a request from the JS framework, the UI tree including a DOM tree, a Widget tree, and a Layout tree; and in response to detecting an interaction with the user interface, the JS framework Send interaction events;
所述JS框架响应于所述原生框架检测到的交互操作事件输出更新通知,以更新所述UI树;The JS framework outputs an update notification in response to the interaction event detected by the native framework to update the UI tree;
所述渲染引擎用于根据所述原生框架输出的Widget树执行渲染并生成用户界面。The rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
可选地,所述原生框架创建UI树,包括:Optionally, the native framework creates a UI tree, including:
响应于来自所述JS引擎的创建请求创建初始DOM树;所述初始DOM树包括多个DOM节点;Create an initial DOM tree in response to a creation request from the JS engine; the initial DOM tree includes a plurality of DOM nodes;
为所述初始DOM树的每个DOM节点创建Widget映射,获得Widget树;所述Widget映射包括所述DOM节点与所述Widget对象之间的映射关系以及所述Widget对象与所述Widget对象之间的映射关系;Create a Widget mapping for each DOM node of the initial DOM tree to obtain a Widget tree; the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;
创建所述Widget树对应的Layout树;Create a Layout tree corresponding to the Widget tree;
遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,得到布局结果;Traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes to obtain a layout result;
将所述布局结果同步到所述Widget树的样式属性;Synchronize the layout result to the style attribute of the Widget tree;
将所述Widget树发送给所述原生框架内的渲染引擎,以使所述渲染引擎执行渲染操作。The Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
可选地,为所述初始DOM树的每个DOM节点创建Widget映射,包括:Optionally, create a Widget mapping for each DOM node of the initial DOM tree, including:
当所述DOM节点为动态节点时,从JS引擎的观察者获取新值;根据所述新值创建DOM子树;为所述DOM子树的DOM节点创建Widget映射;重复从JS引擎的观察者 获取新值的步骤,直至不满足所述动态节点的条件为止。When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree according to the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
可选地,遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,包括:Optionally, traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes, including:
当所述布局节点的父节点不参加网页布局时,获取所述父节点对应元素的尺寸;所述父节点对应元素的尺寸为预设尺寸;根据所述预设尺寸对所述布局节点进行布局处理;或者,When the parent node of the layout node does not participate in the web page layout, obtain the size of the element corresponding to the parent node; the size of the element corresponding to the parent node is a preset size; perform layout processing on the layout node according to the preset size ;or,
当所述布局节点的父节点参与网页布局时,对所述父节点进行标记处理;当所述父节点外部布局完成后获得所述父节点对应元素的尺寸时,对所述布局节点进行布局处理。When the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
可选地,所述原生框架更新所述UI树,包括:Optionally, the native framework updates the UI tree, including:
当创建用户界面时,在所述UI树的DOM节点上进行交互回调注册,得到所述DOM节点对应的回调函数句柄;When creating a user interface, perform interactive callback registration on the DOM node of the UI tree to obtain the callback function handle corresponding to the DOM node;
当检测到触发所述用户界面的交互操作时,通知所述交互操作对应的目标DOM节点;When an interactive operation that triggers the user interface is detected, notify the target DOM node corresponding to the interactive operation;
根据所述交互操作对应的操作类型查找回调函数句柄;当检测到回调函数句柄时,触发JS框架执行具体的回调函数;Search the callback function handle according to the operation type corresponding to the interactive operation; when the callback function handle is detected, trigger the JS framework to execute the specific callback function;
获取所述JS框架发送的更新通知,并根据所述更新通知更新所述UI树的结构和/或内容。Obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification.
根据本公开实施例的第三方面,提供一种电子设备,包括:According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including:
存储器与处理器;memory and processor;
所述存储器用于存储所述处理器可执行的计算机程序;The memory is used to store computer programs executable by the processor;
所述处理器用于执行所述存储器中的计算机程序,以实现如上述的方法。The processor is used to execute the computer program in the memory to implement the above method.
根据本公开实施例的第四方面,提供一种非暂态计算机可读存储介质,当所述存储介质中的可执行的计算机程序由处理器执行时,能够实现如上述的方法。According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium is provided, which can implement the above method when an executable computer program in the storage medium is executed by a processor.
本公开的实施例提供的技术方案可以包括以下有益效果:The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:
由上述实施例可知,本公开实施例提供的混合渲染应用系统,包括JS框架、原生框架和渲染引擎;所述JS框架具有应用生命周期管理功能和应用逻辑处理功能;所述原生框架具有UI树管理功能;其中,所述UI树包括DOM树、Widget树和Layout树;所述原生框架包括构建接口API,用于响应于所述JS框架的请求创建和/或更新所述UI 树中的DOM树、Widget树和Layout树;以及响应于检测到对用户界面的交互操作向所述JS框架发送交互操作事件;所述JS框架包括回调请求接口API,用于响应于所述原生框架检测到的交互操作事件,以更新所述UI树;所述渲染引擎用于根据所述原生框架输出的Widget树执行渲染并生成用户界面。这样,本实施例中将DOM树功能调整到原生框架内处理,因DOM树采用原生语言所占用内存远小于JS语言实现DOM树所占用内存,从而可以降低混合渲染应用系统所占用内存的大小,降低对内存的占用量,提升内存的使用率。As can be seen from the above embodiments, the hybrid rendering application system provided by the embodiments of the present disclosure includes a JS framework, a native framework and a rendering engine; the JS framework has an application life cycle management function and an application logic processing function; the native framework has a UI tree Management function; wherein the UI tree includes a DOM tree, a Widget tree and a Layout tree; the native framework includes a construction interface API for creating and/or updating the DOM in the UI tree in response to a request from the JS framework tree, Widget tree and Layout tree; and in response to detecting the interaction operation on the user interface, sending an interaction event to the JS framework; the JS framework includes a callback request interface API for responding to the detection of the native framework. Interactively operate events to update the UI tree; the rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework. In this way, in this embodiment, the DOM tree function is adjusted to be processed within the native framework. Since the memory occupied by the DOM tree using the native language is much smaller than the memory occupied by the DOM tree implemented in the JS language, the size of the memory occupied by the hybrid rendering application system can be reduced. Reduce memory usage and improve memory usage.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only, and do not limit the present disclosure.
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
图1是根据一示例性实施例示出的一种混合渲染应用系统的结构示意图。Figure 1 is a schematic structural diagram of a hybrid rendering application system according to an exemplary embodiment.
图2是根据一示例性实施例示出的一种混合渲染应用系统构建UI树的信号流程示意图。FIG. 2 is a schematic signal flow diagram of a hybrid rendering application system for building a UI tree according to an exemplary embodiment.
图3是根据一示例性实施例示出的一种混合渲染应用系统构建UI树的流程图。Figure 3 is a flowchart of a hybrid rendering application system for building a UI tree according to an exemplary embodiment.
图4是根据一示例性实施例示出的一种初始DOM树的示意图。Figure 4 is a schematic diagram of an initial DOM tree according to an exemplary embodiment.
图5是根据一示例性实施例示出的一种Widget树的示意图。Figure 5 is a schematic diagram of a Widget tree according to an exemplary embodiment.
图6是根据一示例性实施例示出的一种布局节点的示意图。Figure 6 is a schematic diagram of a layout node according to an exemplary embodiment.
图7是根据一示例性实施例示出的一种更新UI树的流程图。Figure 7 is a flowchart of updating a UI tree according to an exemplary embodiment.
图8是根据一示例性实施例示出的一种电子设备的框图。FIG. 8 is a block diagram of an electronic device according to an exemplary embodiment.
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性所描述的实施例并不代表与本公开相一致的所有实施例。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置例子。需要说明的是,在不冲突的情况 下,下述的实施例及实施方式中的特征可以相互组合。Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings refer to the same or similar elements unless otherwise indicated. The illustrative embodiments described below do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of devices consistent with aspects of the disclosure as detailed in the appended claims. It should be noted that, as long as there is no conflict, the features in the following embodiments and implementation modes can be combined with each other.
目前,现有的混合渲染应用框架是为智能手机或者笔记本等内存较大的设备而设计,上述混合渲染应用框架为每个应用程序渲染时,通常单个应用需要消耗数十及到上百兆字节大小的内存。当电子设备的内存只有数十兆字节时通常无法使用上述混合渲染应用框架。Currently, existing hybrid rendering application frameworks are designed for devices with large memory such as smartphones or laptops. When the above hybrid rendering application framework renders each application, a single application usually consumes tens to hundreds of megabytes. section size of memory. The above hybrid rendering application framework is generally not available when the memory of the electronic device is only tens of megabytes.
在实现本公开方案的过程中,发明人发现:现有的混合渲染应用框架中分为JS框架和原生框架,JS框架具有UI树构建与更新等管理功能等。在JS框架创建UI树(即DOM树)时,需要占用较大的内存。加之,上述JS框架通常使用V8引擎,该VS引擎通常也会占据较大的内存。最终,混合渲染应用框架无法应用到内存较小的电子设备。In the process of implementing the disclosed solution, the inventor found that existing hybrid rendering application frameworks are divided into JS frameworks and native frameworks. The JS framework has management functions such as UI tree construction and update, etc. When the JS framework creates a UI tree (i.e. DOM tree), it requires a large amount of memory. In addition, the above-mentioned JS framework usually uses the V8 engine, and the VS engine usually also occupies a large amount of memory. Ultimately, the hybrid rendering application framework cannot be applied to electronic devices with small memory.
为解决上述技术问题,本公开实施例提供了一种混合渲染应用系统、渲染方法、电子设备和存储介质,图1是根据一示例性实施例示出的一种混合渲染应用系统的结构示意图。参见图1,一种混合渲染应用系统,包括:JS框架、原生框架和渲染引擎;JS框架具有应用生命周期管理功能和应用逻辑处理功能;原生框架具有UI树管理功能;UI树包括DOM树、Widget树和Layout树。原生框架包括构建接口API,用于响应于JS框架的请求创建和/或更新UI树中的DOM树、Widget树和Layout树;以及响应于检测到对用户界面(即UI界面)的交互操作向JS框架发送交互操作事件。JS框架包括回调请求接口API,用于响应于原生框架检测到的交互操作事件,以更新UI树。渲染引擎用于根据原生框架输出的Widget树执行渲染并生成用户界面,例如LVGL引擎、IMGUI引擎和QT引擎等,在此不作限定。In order to solve the above technical problems, embodiments of the present disclosure provide a hybrid rendering application system, a rendering method, an electronic device, and a storage medium. FIG. 1 is a schematic structural diagram of a hybrid rendering application system according to an exemplary embodiment. Referring to Figure 1, a hybrid rendering application system includes: JS framework, native framework and rendering engine; JS framework has application life cycle management function and application logic processing function; native framework has UI tree management function; UI tree includes DOM tree, Widget tree and Layout tree. The native framework includes building interface APIs for creating and/or updating the DOM tree, Widget tree and Layout tree in the UI tree in response to requests from the JS framework; and in response to detecting interaction with the user interface (i.e. UI interface). The JS framework sends interactive operation events. The JS framework includes a callback request interface API for updating the UI tree in response to interaction events detected by the native framework. The rendering engine is used to perform rendering and generate user interfaces based on the Widget tree output by the native framework, such as LVGL engine, IMGUI engine, QT engine, etc., which are not limited here.
本实施例中,原生框架实现DOM树时,原生框架和JS框架之间应用逻辑和DOM树之间的双向通信,即原始框架提供一组构建接口API和JS框架提供一组回调请求接口API。继续参见图1,原生框架包括应用容器APP Container,该应用容器内设置有Module模块、DOM模块和Widget模块,其中Module模块用于提供应用逻辑处理功能。DOM模块与JS引擎进行双向通信。上述JS引擎提供JS运行环境且JS框架运行在JS引擎之上。In this embodiment, when the native framework implements the DOM tree, there is two-way communication between the application logic and the DOM tree between the native framework and the JS framework. That is, the original framework provides a set of construction interface APIs and the JS framework provides a set of callback request interface APIs. Continuing to refer to Figure 1, the native framework includes an application container APP Container. The application container is equipped with a Module module, a DOM module and a Widget module. The Module module is used to provide application logic processing functions. The DOM module communicates bidirectionally with the JS engine. The above-mentioned JS engine provides a JS running environment and the JS framework runs on the JS engine.
本实施例提供的混合渲染应用系统构建UI树的过程,图2是根据一示例性实施例示出的一种混合渲染应用系统构建UI树的信号流程示意图,图3是根据一示例性实施例示出的一种混合渲染应用系统构建UI树的流程图。参见图2和3,构建UI树包括:The process of constructing a UI tree by the hybrid rendering application system provided by this embodiment. Figure 2 is a schematic signal flow diagram of a hybrid rendering application system constructing a UI tree according to an exemplary embodiment. Figure 3 is a schematic diagram of the signal flow of constructing a UI tree by a hybrid rendering application system according to an exemplary embodiment. A flow chart of building a UI tree using a hybrid rendering application system. Referring to Figures 2 and 3, building the UI tree includes:
在步骤31中,原生框架可以响应于接收到JS框架中JS引擎的创建请求,创建初始 DOM树,该初始DOM树包括多个DOM节点。参见图4,在一示例中,初始DOM树包括节点Doc、节点Div、(动态)节点for和节点button,并且节点Div的父节点为节点Doc,其子节点分别为节点for和节点button。需要说明的是,上述初始DOM树仅用于示例性说明,并不构成对本公开方案的限定。本步骤中创建初始DOM树可以由原生框架中DOM模块来执行。In step 31, the native framework may create an initial DOM tree in response to receiving a creation request from the JS engine in the JS framework, where the initial DOM tree includes a plurality of DOM nodes. Referring to Figure 4, in an example, the initial DOM tree includes node Doc, node Div, (dynamic) node for and node button, and the parent node of node Div is node Doc, and its child nodes are node for and node button respectively. It should be noted that the above initial DOM tree is only for illustrative purposes and does not constitute a limitation on the disclosed solution. The creation of the initial DOM tree in this step can be performed by the DOM module in the native framework.
在步骤32中,原生框架可以为所述初始DOM树的每个DOM节点创建Widget映射,获得Widget树。In step 32, the native framework may create a Widget mapping for each DOM node of the initial DOM tree to obtain a Widget tree.
参见图5,在一示例中,初始DOM树中节点Doc对应Widget树中Widget对象场景(scene)。Referring to Figure 5, in an example, the node Doc in the initial DOM tree corresponds to the Widget object scene in the Widget tree.
初始DOM树中节点div对应的Widget树中Widget对象div。由于初始DOM树中节点for是一个动态节点,包括2个文本节点,因此,Widget树中存在2个文本对象与之对应。当初始DOM树中节点为动态节点时,原生框架可以从JS引擎的观察者(负责监听应用数据变化,如增加、删除,修改等,并触发关联的DOM树节点)获取新值,然后根据上述新值创建DOM子树。之后,为DOM子树的DOM节点创建Widget映射;重复从JS引擎的观察者获取新值的步骤,直至不满足所述动态节点的条件为止,如超出节点for中循环的最大值。The Widget object div in the Widget tree corresponding to the node div in the initial DOM tree. Since the node for in the initial DOM tree is a dynamic node, including two text nodes, there are two corresponding text objects in the Widget tree. When the node in the initial DOM tree is a dynamic node, the native framework can obtain the new value from the observer of the JS engine (responsible for monitoring application data changes, such as addition, deletion, modification, etc., and triggering the associated DOM tree node), and then according to the above The new value creates a DOM subtree. After that, create a Widget mapping for the DOM node of the DOM subtree; repeat the steps of getting new values from the observer of the JS engine until the conditions of the dynamic node are not met, such as exceeding the maximum value of the loop in the node for.
初始DOM树中节点button对应的Widget树中Widget对象button。并且,上述Widget树同时具有DOM树中节点间的映射关系,因此上述Widget映射包括所述DOM节点与所述Widget对象之间的映射关系以及所述Widget对象与所述Widget对象之间的映射关系。本步骤中创建Widget树可以由原生框架中Widget模块来执行。The Widget object button in the Widget tree corresponding to the node button in the initial DOM tree. Moreover, the above-mentioned Widget tree also has a mapping relationship between nodes in the DOM tree, so the above-mentioned Widget mapping includes a mapping relationship between the DOM node and the Widget object and a mapping relationship between the Widget object and the Widget object. . The creation of the Widget tree in this step can be performed by the Widget module in the native framework.
在步骤33中,原生框架可以创建所述Widget树对应的Layout树。其中,创建Layout树和创建Widget树的原理类似,在Widget树的某一个Widget对象创建完成后可以同步创建布局节点(即layout节点)。参见图6,在一示例中创建widget对象div后,可以创建该widget对象div对应的布局节点Layout node div,该布局节点Layout node div包括三个子节点Layout node Text。当所有widget对象div对应的布局节点均创建布局节点后,结合Widget树中widget对象的映射关系可以生成Layout树。本步骤中创建Layout树可以由原生框架中Widget模块来执行。In step 33, the native framework can create a Layout tree corresponding to the Widget tree. Among them, the principle of creating a Layout tree is similar to that of creating a Widget tree. After a certain Widget object in the Widget tree is created, the layout node (ie, layout node) can be created synchronously. Referring to Figure 6, after creating the widget object div in an example, you can create a layout node Layout node div corresponding to the widget object div. The layout node Layout node div includes three child nodes Layout node Text. After the layout nodes corresponding to all widget object divs are created, a Layout tree can be generated based on the mapping relationship of the widget objects in the Widget tree. The Layout tree created in this step can be executed by the Widget module in the native framework.
在步骤34中,原生框架可以遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,得到布局结果。上述布局结果包括节点的尺寸和位置,如节点的宽度、高 度和左上角的位置。In step 34, the native framework may traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes to obtain a layout result. The above layout results include the size and position of the node, such as the width, height and position of the upper left corner of the node.
当布局节点的父节点不参加网页布局(Flex布局)时,原生框架可以获取父节点对应元素(如文本、图片、控件等等)的尺寸;其中,父节点对应元素的尺寸为预设尺寸,包括屏幕尺寸和预设尺寸(小于屏幕尺寸),然后根据所述预设尺寸对所述布局节点进行布局处理。或者,当布局节点的父节点参与网页布局时,此时父节点对应元素的尺寸是未知的,因此对父节点进行标记处理;当所述父节点外部布局完成后获得所述父节点对应元素的尺寸时,再根据父节点对应元素的尺寸对布局节点进行布局处理。本步骤中布局处理可以由原生框架中Widget模块来执行。When the parent node of a layout node does not participate in web page layout (Flex layout), the native framework can obtain the size of the element corresponding to the parent node (such as text, picture, control, etc.); among them, the size of the element corresponding to the parent node is the preset size, including The screen size and the preset size (smaller than the screen size), and then perform layout processing on the layout node according to the preset size. Or, when the parent node of the layout node participates in the web page layout, the size of the element corresponding to the parent node is unknown at this time, so the parent node is marked; when the external layout of the parent node is completed, the size of the element corresponding to the parent node is obtained. When changing the size, the layout node is laid out according to the size of the corresponding element of the parent node. The layout processing in this step can be performed by the Widget module in the native framework.
在步骤35中,原生框架可以将所述布局结果同步到所述Widget树的样式属性。本步骤中同步布局结果可以由原生框架中Widget模块来执行。In step 35, the native framework may synchronize the layout result to the style attribute of the Widget tree. The synchronized layout results in this step can be executed by the Widget module in the native framework.
在步骤36中,原生框架可以将所述Widget树发送给所述原生框架内的渲染引擎,以使所述渲染引擎执行渲染操作。本步骤中发送Widget树可以由原生框架中Widget模块来执行。In step 36, the native framework may send the Widget tree to the rendering engine within the native framework, so that the rendering engine performs a rendering operation. Sending the Widget tree in this step can be performed by the Widget module in the native framework.
在一实施例中,原生框架可以更新UI树,参见图7,包括:In one embodiment, the native framework can update the UI tree, see Figure 7, including:
在步骤71中,当创建用户界面时,原生框架可以在UI树的DOM节点上进行交互回调注册,得到所述DOM节点对应的回调函数句柄。例如,DOM节点为一个图像节点(image节点),此时可以注册一个点击(click)回调函数句柄。本步骤中回调注册可以由原生框架中DOM模块来执行。In step 71, when creating the user interface, the native framework can register an interactive callback on the DOM node of the UI tree to obtain the callback function handle corresponding to the DOM node. For example, if the DOM node is an image node, you can register a click callback function handle. The callback registration in this step can be performed by the DOM module in the native framework.
在步骤72中,当检测到触发所述用户界面的交互操作时,通知所述交互操作对应的目标DOM节点。原生框架可以检测用户界面的交互操作,当检测到触发用户界面的交互操作时可以生成一个事件,并将上述事件发送给JS引擎。本步骤中检测交互操作和通知可以由原生框架中Widget模块来执行。In step 72, when an interactive operation that triggers the user interface is detected, the target DOM node corresponding to the interactive operation is notified. The native framework can detect user interface interactions, generate an event when detecting an interaction that triggers the user interface, and send the above event to the JS engine. Detection of interactive operations and notifications in this step can be performed by the Widget module in the native framework.
在步骤73中,原生框架可以根据所述交互操作对应的操作类型查找回调函数句柄;当检测到回调函数句柄时,触发JS框架执行具体的回调函数。本步骤中查找回调函数句柄可以由原生框架中DOM模块来执行。In step 73, the native framework can search for the callback function handle according to the operation type corresponding to the interactive operation; when the callback function handle is detected, the JS framework is triggered to execute the specific callback function. The callback function handle search in this step can be performed by the DOM module in the native framework.
在步骤74中,原生框架可以获取所述JS框架发送的更新通知,并根据所述更新通知更新所述UI树的结构和/或内容。本步骤中查找回调函数句柄可以由原生框架中DOM模块来执行。In step 74, the native framework may obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification. The callback function handle search in this step can be performed by the DOM module in the native framework.
在一实施例中,JS引擎可以配合原生框架更新UI树,包括:当接收到原生框架发 送的交互操作的事件时,查询上述事件的操作类型,并根据上述操作类型来回调函数。当查询到回调函数后可以调用上述回调函数,从而对DOM树进行更新操作,如增加节点、删除节点、更新节点属性等,这些更新操作会带来数据变化,因此JS引擎可以生成更新通知并发送给原生框架。原生框架根据上述更新通知更新DOM树,并且更新Widget树和Layout树。In one embodiment, the JS engine can cooperate with the native framework to update the UI tree, including: when receiving an interactive operation event sent by the native framework, query the operation type of the above event, and call back the function according to the above operation type. When the callback function is queried, the above callback function can be called to perform update operations on the DOM tree, such as adding nodes, deleting nodes, updating node attributes, etc. These update operations will bring about data changes, so the JS engine can generate update notifications and send To native framework. The native framework updates the DOM tree according to the above update notification, and updates the Widget tree and Layout tree.
在一实施例中,继续参见图1,本实施例提供的混合渲染应用系统还包括引擎适配层JSI。该引擎适配层JSI与JS引擎通信,用于适配不同类型的JS引擎。例如,JS引擎可以为V8引擎、QuickJS引擎、Duktape引擎和JerryScript引擎等,引擎适配层JSI通过将JS API封闭为统一格式,可以在上述多种JS引擎之间无缝切换,达到替换为轻量级引擎的效果。In one embodiment, continuing to refer to FIG. 1 , the hybrid rendering application system provided in this embodiment further includes an engine adaptation layer JSI. The engine adaptation layer JSI communicates with the JS engine and is used to adapt to different types of JS engines. For example, the JS engine can be V8 engine, QuickJS engine, Duktape engine, JerryScript engine, etc. The engine adaptation layer JSI can seamlessly switch between the above multiple JS engines by sealing the JS API into a unified format, so as to replace it with a light engine. The effect of the magnitude engine.
这样,与相关技术中JS框架设置DOM树管理相比较,本实施例中原生框架设置DOM树管理功能时DOM树可采用原生语言实现,此时DOM树所占用内存量会极大降低,从相关技术中的数十兆字节降至几数兆字节,有利于提升内存的使用率。或者说,本实施例提供的混合渲染应用系统因占用内存较小,可以适用于内存资源较少的电子设备,如智能手表、智能手环、智能眼镜等设备,从而扩大混合渲染应用系统的适用范围。In this way, compared with the DOM tree management set up by the JS framework in related technologies, in this embodiment, when the native framework sets up the DOM tree management function, the DOM tree can be implemented using the native language. At this time, the amount of memory occupied by the DOM tree will be greatly reduced. From the related The tens of megabytes in technology are reduced to a few megabytes, which is beneficial to improving memory usage. In other words, since the hybrid rendering application system provided in this embodiment occupies less memory, it can be applied to electronic devices with less memory resources, such as smart watches, smart bracelets, smart glasses, etc., thereby expanding the applicability of the hybrid rendering application system. scope.
在本公开实施例提供的一种混合渲染应用系统的基础上,本公开实施例还提供了一种混合渲染方法,应用于电子设备,所述电子设备设置有混合渲染应用系统,所述系统包括JS框架、原生框架和渲染引擎;所述方法包括:Based on the hybrid rendering application system provided by the embodiment of the present disclosure, the embodiment of the present disclosure also provides a hybrid rendering method, which is applied to an electronic device. The electronic device is provided with a hybrid rendering application system, and the system includes JS framework, native framework and rendering engine; the methods include:
所述原生框架响应于所述JS框架的请求创建和/或更新UI树,所述UI树包括DOM树、Widget树和Layout树;以及响应于检测到对用户界面的交互操作向所述JS框架发送交互操作事件;The native framework creates and/or updates a UI tree in response to a request from the JS framework, the UI tree including a DOM tree, a Widget tree, and a Layout tree; and in response to detecting an interaction with the user interface, the JS framework Send interaction events;
所述JS框架响应于所述原生框架检测到的交互操作事件输出更新通知,以更新所述UI树;The JS framework outputs an update notification in response to the interaction event detected by the native framework to update the UI tree;
所述渲染引擎用于根据所述原生框架输出的Widget树执行渲染并生成用户界面。The rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
在一实施例中,所述原生框架创建UI树,包括:In one embodiment, the native framework creates a UI tree, including:
响应于来自所述JS引擎的创建请求创建初始DOM树;所述初始DOM树包括多个DOM节点;Create an initial DOM tree in response to a creation request from the JS engine; the initial DOM tree includes a plurality of DOM nodes;
为所述初始DOM树的每个DOM节点创建Widget映射,获得Widget树;所述Widget映射包括所述DOM节点与所述Widget对象之间的映射关系以及所述Widget对象与所 述Widget对象之间的映射关系;Create a Widget mapping for each DOM node of the initial DOM tree to obtain a Widget tree; the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;
创建所述Widget树对应的Layout树;Create a Layout tree corresponding to the Widget tree;
遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,得到布局结果;Traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes to obtain a layout result;
将所述布局结果同步到所述Widget树的样式属性;Synchronize the layout result to the style attribute of the Widget tree;
将所述Widget树发送给所述原生框架内的渲染引擎,以使所述渲染引擎执行渲染操作。The Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
在一实施例中,为所述初始DOM树的每个DOM节点创建Widget映射,包括:In one embodiment, creating a Widget mapping for each DOM node of the initial DOM tree includes:
当所述DOM节点为动态节点时,从JS引擎的观察者获取新值;根据所述新值创建DOM子树;为所述DOM子树的DOM节点创建Widget映射;重复从JS引擎的观察者获取新值的步骤,直至不满足所述动态节点的条件为止。When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree according to the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
在一实施例中,遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,包括:In one embodiment, traversing the layout nodes in the Layout tree and performing layout processing on the layout nodes includes:
当所述布局节点的父节点不参加网页布局时,获取所述父节点对应元素的尺寸;所述父节点对应元素的尺寸为预设尺寸;根据所述预设尺寸对所述布局节点进行布局处理;或者,When the parent node of the layout node does not participate in the web page layout, obtain the size of the element corresponding to the parent node; the size of the element corresponding to the parent node is a preset size; perform layout processing on the layout node according to the preset size ;or,
当所述布局节点的父节点参与网页布局时,对所述父节点进行标记处理;当所述父节点外部布局完成后获得所述父节点对应元素的尺寸时,对所述布局节点进行布局处理。When the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
在一实施例中,所述原生框架更新所述UI树,包括:In one embodiment, the native framework updates the UI tree, including:
当创建用户界面时,在所述UI树的DOM节点上进行交互回调注册,得到所述DOM节点对应的回调函数句柄;When creating a user interface, perform interactive callback registration on the DOM node of the UI tree to obtain the callback function handle corresponding to the DOM node;
当检测到触发所述用户界面的交互操作时,通知所述交互操作对应的目标DOM节点;When an interactive operation that triggers the user interface is detected, notify the target DOM node corresponding to the interactive operation;
根据所述交互操作对应的操作类型查找回调函数句柄;当检测到回调函数句柄时,触发JS框架执行具体的回调函数;Search the callback function handle according to the operation type corresponding to the interactive operation; when the callback function handle is detected, trigger the JS framework to execute the specific callback function;
获取所述JS框架发送的更新通知,并根据所述更新通知更新所述UI树的结构和/或内容。Obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification.
需要说明的是,本实施例中示出的方法与系统实施例的内容相匹配,可以参考上述系统实施例的内容,在此不再赘述。It should be noted that the method shown in this embodiment matches the content of the system embodiment, and reference may be made to the content of the above system embodiment, which will not be described again here.
图8是根据一示例性实施例示出的一种电子设备的框图。例如,电子设备800可以是智能手机,计算机,数字广播终端,平板设备,医疗设备,健身设备,个人数字助理等。FIG. 8 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 800 may be a smartphone, a computer, a digital broadcast terminal, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
参照图8,电子设备800可以包括以下一个或多个组件:处理组件802,存储器804,电源组件806,多媒体组件808,音频组件810,输入/输出(I/O)的接口812,传感器组件814,通信组件816,图像采集组件818。Referring to FIG. 8 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power supply component 806 , a multimedia component 808 , an audio component 810 , an input/output (I/O) interface 812 , and a sensor component 814 , communication component 816, image acquisition component 818.
处理组件802通常控制电子设备800的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件802可以包括一个或多个处理器820来执行计算机程序。此外,处理组件802可以包括一个或多个模块,便于处理组件802和其他组件之间的交互。例如,处理组件802可以包括多媒体模块,以方便多媒体组件808和处理组件802之间的交互。 Processing component 802 generally controls the overall operations of electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. Processing component 802 may include one or more processors 820 to execute computer programs. Additionally, processing component 802 may include one or more modules that facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
存储器804被配置为存储各种类型的数据以支持在电子设备800的操作。这些数据的示例包括用于在电子设备800上操作的任何应用程序或方法的计算机程序,联系人数据,电话簿数据,消息,图片,视频等。存储器804可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。 Memory 804 is configured to store various types of data to support operations at electronic device 800 . Examples of such data include computer programs for any application or method operating on electronic device 800, contact data, phonebook data, messages, pictures, videos, etc. Memory 804 may be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EEPROM), Programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
电源组件806为电子设备800的各种组件提供电力。电源组件806可以包括电源管理系统,一个或多个电源,及其他与为电子设备800生成、管理和分配电力相关联的组件。电源组件806可以包括电源芯片,控制器可以电源芯片通信,从而控制电源芯片导通或者断开开关器件,使电池向主板电路供电或者不供电。 Power supply component 806 provides power to various components of electronic device 800 . Power supply components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 800 . The power supply component 806 may include a power supply chip, and the controller can communicate with the power supply chip to control the power supply chip to turn on or off the switching device, so that the battery supplies power to the motherboard circuit or not.
多媒体组件808包括在电子设备800和目标对象之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示屏(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自目标对象的输入信息。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与触摸或滑动操作相关的持续时间和压力。 Multimedia component 808 includes a screen that provides an output interface between electronic device 800 and the target object. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input information from the target object. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. A touch sensor can not only sense the boundaries of a touch or swipe action, but also detect the duration and pressure associated with the touch or swipe action.
音频组件810被配置为输出和/或输入音频文件信息。例如,音频组件810包括 一个麦克风(MIC),当电子设备800处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频文件信息。所接收的音频文件信息可以被进一步存储在存储器804或经由通信组件816发送。在一些实施例中,音频组件810还包括一个扬声器,用于输出音频文件信息。 Audio component 810 is configured to output and/or input audio file information. For example, audio component 810 includes a microphone (MIC) configured to receive external audio file information when electronic device 800 is in operating modes, such as call mode, recording mode, and voice recognition mode. The received audio file information may be further stored in memory 804 or sent via communication component 816 . In some embodiments, audio component 810 also includes a speaker for outputting audio file information.
I/O接口812为处理组件802和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。The I/O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which may be a keyboard, a click wheel, a button, etc.
传感器组件814包括一个或多个传感器,用于为电子设备800提供各个方面的状态评估。例如,传感器组件814可以检测到电子设备800的打开/关闭状态,组件的相对定位,例如组件为电子设备800的显示屏和小键盘,传感器组件814还可以检测电子设备800或一个组件的位置改变,目标对象与电子设备800接触的存在或不存在,电子设备800方位或加速/减速和电子设备800的温度变化。本示例中,传感器组件814可以包括磁力传感器、陀螺仪和磁场传感器,其中磁场传感器包括以下至少一种:霍尔传感器、薄膜磁致电阻传感器、磁性液体加速度传感器。 Sensor component 814 includes one or more sensors for providing various aspects of status assessment for electronic device 800 . For example, the sensor component 814 can detect the open/closed state of the electronic device 800, the relative positioning of components, such as the display screen and keypad of the electronic device 800, and the sensor component 814 can also detect the position change of the electronic device 800 or a component. , the presence or absence of the target object in contact with the electronic device 800 , the orientation or acceleration/deceleration of the electronic device 800 and the temperature change of the electronic device 800 . In this example, the sensor component 814 may include a magnetic sensor, a gyroscope, and a magnetic field sensor, where the magnetic field sensor includes at least one of the following: a Hall sensor, a thin film magnetoresistive sensor, and a magnetic liquid acceleration sensor.
通信组件816被配置为便于电子设备800和其他设备之间有线或无线方式的通信。电子设备800可以接入基于通信标准的无线网络,如WiFi,2G、3G、4G、5G,或它们的组合。在一个示例性实施例中,通信组件816经由广播信道接收来自外部广播管理系统的广播信息或广播相关信息。在一个示例性实施例中,通信组件816还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。 Communication component 816 is configured to facilitate wired or wireless communication between electronic device 800 and other devices. The electronic device 800 can access a wireless network based on communication standards, such as WiFi, 2G, 3G, 4G, 5G, or a combination thereof. In one exemplary embodiment, communication component 816 receives broadcast information or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communications component 816 also includes a near field communications (NFC) module to facilitate short-range communications. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
在示例性实施例中,电子设备800可以被一个或多个应用专用集成电路(ASIC)、数字信息处理器(DSP)、数字信息处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现。In an exemplary embodiment, electronic device 800 may be configured by one or more application specific integrated circuits (ASICs), digital information processors (DSPs), digital information processing devices (DSPDs), programmable logic devices (PLDs), field programmable Programmed gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation.
在示例性实施例中,还提供了一种非暂态计算机可读存储介质,例如包括指令的存储器804,上述可执行的计算机程序可由处理器执行。其中,可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, such as a memory 804 including instructions, and the above-mentioned executable computer program can be executed by a processor. Among them, the readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
本领域技术人员在考虑说明书及实践这里公开的公开后,将容易想到本公开的其它实施方案。本公开旨在涵盖任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识 或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Other embodiments of the disclosure will be readily apparent to those skilled in the art from consideration of the specification and practice of the disclosure herein. The present disclosure is intended to cover any modifications, uses, or adaptations that follow the general principles of the disclosure and include common knowledge or customary technical means in the technical field that are not disclosed in the disclosure. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It is to be understood that the present disclosure is not limited to the precise structures described above and illustrated in the accompanying drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the disclosure is limited only by the appended claims.
Claims (13)
- 一种混合渲染应用系统,其特征在于,所述系统包括JS框架、原生框架和渲染引擎;所述JS框架具有应用生命周期管理功能和应用逻辑处理功能;所述原生框架具有UI树管理功能;其中,所述UI树包括DOM树、Widget树和Layout树;A hybrid rendering application system, characterized in that the system includes a JS framework, a native framework and a rendering engine; the JS framework has an application life cycle management function and an application logic processing function; the native framework has a UI tree management function; Wherein, the UI tree includes DOM tree, Widget tree and Layout tree;所述原生框架包括构建接口API,用于响应于所述JS框架的请求创建和/或更新所述UI树中的DOM树、Widget树和Layout树;以及响应于检测到对用户界面的交互操作向所述JS框架发送交互操作事件;The native framework includes a construction interface API for creating and/or updating the DOM tree, Widget tree and Layout tree in the UI tree in response to a request from the JS framework; and in response to detecting an interactive operation on the user interface Send interactive operation events to the JS framework;所述JS框架包括回调请求接口API,用于响应于所述原生框架检测到的交互操作事件,以更新所述UI树;The JS framework includes a callback request interface API for updating the UI tree in response to interactive operation events detected by the native framework;所述渲染引擎用于根据所述原生框架输出的Widget树执行渲染并生成用户界面。The rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
- 根据权利要求1所述的系统,其特征在于,所述原生框架创建UI树,包括:The system according to claim 1, characterized in that the native framework creates a UI tree, including:创建初始DOM树;所述初始DOM树包括多个DOM节点;Create an initial DOM tree; the initial DOM tree includes multiple DOM nodes;为所述初始DOM树的每个DOM节点创建Widget映射,获得Widget树;所述Widget映射包括所述DOM节点与所述Widget对象之间的映射关系以及所述Widget对象与所述Widget对象之间的映射关系;Create a Widget mapping for each DOM node of the initial DOM tree to obtain a Widget tree; the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;创建所述Widget树对应的Layout树;Create a Layout tree corresponding to the Widget tree;遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,得到布局结果;Traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes to obtain a layout result;将所述布局结果同步到所述Widget树的样式属性;Synchronize the layout result to the style attribute of the Widget tree;将所述Widget树发送给所述原生框架内的渲染引擎,以使所述渲染引擎执行渲染操作。The Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
- 根据权利要求2所述的系统,其特征在于,为所述初始DOM树的每个DOM节点创建Widget映射,包括:The system according to claim 2, characterized in that creating a Widget mapping for each DOM node of the initial DOM tree includes:当所述DOM节点为动态节点时,从JS引擎的观察者获取新值;根据所述新值创建DOM子树;为所述DOM子树的DOM节点创建Widget映射;重复从JS引擎的观察者获取新值的步骤,直至不满足所述动态节点的条件为止。When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree based on the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
- 根据权利要求1所述的系统,其特征在于,遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,包括:The system according to claim 1, characterized in that traversing the layout nodes in the Layout tree and performing layout processing on the layout nodes includes:当所述布局节点的父节点不参加网页布局时,获取所述父节点对应元素的尺寸;所述父节点对应元素的尺寸为预设尺寸;根据所述预设尺寸对所述布局节点进行布局处理;或者,When the parent node of the layout node does not participate in the web page layout, obtain the size of the element corresponding to the parent node; the size of the element corresponding to the parent node is a preset size; perform layout processing on the layout node according to the preset size ;or,当所述布局节点的父节点参与网页布局时,对所述父节点进行标记处理;当所述父 节点外部布局完成后获得所述父节点对应元素的尺寸时,对所述布局节点进行布局处理。When the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
- 根据权利要求1所述的系统,其特征在于,所述原生框架更新所述UI树,包括:The system according to claim 1, characterized in that the native framework updates the UI tree, including:当创建用户界面时,在所述UI树的DOM节点上进行交互回调注册,得到所述DOM节点对应的回调函数句柄;When creating a user interface, perform interactive callback registration on the DOM node of the UI tree to obtain the callback function handle corresponding to the DOM node;当检测到触发所述用户界面的交互操作时,通知所述交互操作对应的目标DOM节点;When an interactive operation that triggers the user interface is detected, notify the target DOM node corresponding to the interactive operation;根据所述交互操作对应的操作类型查找回调函数句柄;当检测到回调函数句柄时,触发JS框架执行具体的回调函数;Search the callback function handle according to the operation type corresponding to the interactive operation; when the callback function handle is detected, trigger the JS framework to execute the specific callback function;获取所述JS框架发送的更新通知,并根据所述更新通知更新所述UI树的结构和/或内容。Obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification.
- 根据权利要求1所述的系统,其特征在于,所述系统还包括引擎适配层;所述引擎适配层与所述JS引擎通信,用于适配不同类型的JS引擎。The system according to claim 1, characterized in that the system further includes an engine adaptation layer; the engine adaptation layer communicates with the JS engine and is used to adapt to different types of JS engines.
- 一种混合渲染方法,其特征在于,应用于电子设备,所述电子设备设置有混合渲染应用系统,所述系统包括JS框架、原生框架和渲染引擎;所述方法包括:A hybrid rendering method, characterized in that it is applied to electronic equipment, and the electronic equipment is equipped with a hybrid rendering application system. The system includes a JS framework, a native framework and a rendering engine; the method includes:所述原生框架响应于所述JS框架的请求创建和/或更新UI树,所述UI树包括DOM树、Widget树和Layout树;以及响应于检测到对用户界面的交互操作向所述JS框架发送交互操作事件;The native framework creates and/or updates a UI tree in response to a request from the JS framework, the UI tree including a DOM tree, a Widget tree, and a Layout tree; and in response to detecting an interaction with the user interface, the JS framework Send interaction events;所述JS框架响应于所述原生框架检测到的交互操作事件输出更新通知,以更新所述UI树;The JS framework outputs an update notification in response to the interaction event detected by the native framework to update the UI tree;所述渲染引擎用于根据所述原生框架输出的Widget树执行渲染并生成用户界面。The rendering engine is used to perform rendering and generate a user interface according to the Widget tree output by the native framework.
- 根据权利要求7所述的方法,其特征在于,所述原生框架创建UI树,包括:The method according to claim 7, characterized in that the native framework creates a UI tree, including:响应于来自所述JS引擎的创建请求创建初始DOM树;所述初始DOM树包括多个DOM节点;Create an initial DOM tree in response to a creation request from the JS engine; the initial DOM tree includes a plurality of DOM nodes;为所述初始DOM树的每个DOM节点创建Widget映射,获得Widget树;所述Widget映射包括所述DOM节点与所述Widget对象之间的映射关系以及所述Widget对象与所述Widget对象之间的映射关系;Create a Widget mapping for each DOM node of the initial DOM tree to obtain a Widget tree; the Widget mapping includes the mapping relationship between the DOM node and the Widget object and the mapping relationship between the Widget object and the Widget object mapping relationship;创建所述Widget树对应的Layout树;Create a Layout tree corresponding to the Widget tree;遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,得到布局结果;Traverse the layout nodes in the Layout tree and perform layout processing on the layout nodes to obtain a layout result;将所述布局结果同步到所述Widget树的样式属性;Synchronize the layout result to the style attribute of the Widget tree;将所述Widget树发送给所述原生框架内的渲染引擎,以使所述渲染引擎执行渲染操作。The Widget tree is sent to the rendering engine in the native frame, so that the rendering engine performs a rendering operation.
- 根据权利要求8所述的方法,其特征在于,为所述初始DOM树的每个DOM节点创建Widget映射,包括:The method according to claim 8, characterized in that creating a Widget mapping for each DOM node of the initial DOM tree includes:当所述DOM节点为动态节点时,从JS引擎的观察者获取新值;根据所述新值创建DOM子树;为所述DOM子树的DOM节点创建Widget映射;重复从JS引擎的观察者获取新值的步骤,直至不满足所述动态节点的条件为止。When the DOM node is a dynamic node, obtain the new value from the observer of the JS engine; create a DOM subtree based on the new value; create a Widget mapping for the DOM node of the DOM subtree; repeatedly obtain the new value from the observer of the JS engine. Steps to get new values until the condition of said dynamic node is not met.
- 根据权利要求7所述的方法,其特征在于,遍历所述Layout树中的布局节点并对所述布局节点进行布局处理,包括:The method according to claim 7, characterized in that traversing layout nodes in the Layout tree and performing layout processing on the layout nodes includes:当所述布局节点的父节点不参加网页布局时,获取所述父节点对应元素的尺寸;所述父节点对应元素的尺寸为预设尺寸;根据所述预设尺寸对所述布局节点进行布局处理;或者,When the parent node of the layout node does not participate in the web page layout, obtain the size of the element corresponding to the parent node; the size of the element corresponding to the parent node is a preset size; perform layout processing on the layout node according to the preset size ;or,当所述布局节点的父节点参与网页布局时,对所述父节点进行标记处理;当所述父节点外部布局完成后获得所述父节点对应元素的尺寸时,对所述布局节点进行布局处理。When the parent node of the layout node participates in the web page layout, the parent node is marked; when the size of the corresponding element of the parent node is obtained after the external layout of the parent node is completed, the layout node is subjected to layout processing .
- 根据权利要求7所述的方法,其特征在于,所述原生框架更新所述UI树,包括:The method according to claim 7, characterized in that the native framework updates the UI tree, including:当创建用户界面时,在所述UI树的DOM节点上进行交互回调注册,得到所述DOM节点对应的回调函数句柄;When creating a user interface, perform interactive callback registration on the DOM node of the UI tree to obtain the callback function handle corresponding to the DOM node;当检测到触发所述用户界面的交互操作时,通知所述交互操作对应的目标DOM节点;When an interactive operation that triggers the user interface is detected, notify the target DOM node corresponding to the interactive operation;根据所述交互操作对应的操作类型查找回调函数句柄;当检测到回调函数句柄时,触发JS框架执行具体的回调函数;Search the callback function handle according to the operation type corresponding to the interactive operation; when the callback function handle is detected, trigger the JS framework to execute the specific callback function;获取所述JS框架发送的更新通知,并根据所述更新通知更新所述UI树的结构和/或内容。Obtain the update notification sent by the JS framework, and update the structure and/or content of the UI tree according to the update notification.
- 一种电子设备,其特征在于,包括:An electronic device, characterized by including:存储器与处理器;memory and processor;所述存储器用于存储所述处理器可执行的计算机程序;The memory is used to store computer programs executable by the processor;所述处理器用于执行所述存储器中的计算机程序,以实现如权利要求7~11任一项所述的方法。The processor is configured to execute the computer program in the memory to implement the method according to any one of claims 7 to 11.
- 一种非暂态计算机可读存储介质,其特征在于,当所述存储介质中的可执行的计算机程序由处理器执行时,能够实现如权利要求7~11任一项所述的方法。A non-transitory computer-readable storage medium, characterized in that when the executable computer program in the storage medium is executed by a processor, the method according to any one of claims 7 to 11 can be implemented.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202280004152.1A CN117616394A (en) | 2022-06-20 | 2022-06-20 | Hybrid rendering application system, rendering method, electronic device and storage medium |
PCT/CN2022/099931 WO2023245367A1 (en) | 2022-06-20 | 2022-06-20 | Hybrid application rendering system, rendering method, electronic device, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2022/099931 WO2023245367A1 (en) | 2022-06-20 | 2022-06-20 | Hybrid application rendering system, rendering method, electronic device, and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023245367A1 true WO2023245367A1 (en) | 2023-12-28 |
Family
ID=89379001
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/099931 WO2023245367A1 (en) | 2022-06-20 | 2022-06-20 | Hybrid application rendering system, rendering method, electronic device, and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN117616394A (en) |
WO (1) | WO2023245367A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117539491A (en) * | 2024-01-09 | 2024-02-09 | 腾讯科技(深圳)有限公司 | Page layout method, page layout device, electronic device, storage medium and program product |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090091563A1 (en) * | 2006-05-05 | 2009-04-09 | Electronics Arts Inc. | Character animation framework |
CN111158818A (en) * | 2019-12-24 | 2020-05-15 | 中国建设银行股份有限公司 | Page rendering method and device |
US20210064739A1 (en) * | 2018-10-23 | 2021-03-04 | Citrix Systems, Inc. | Local secure rendering of web content |
CN113742014A (en) * | 2021-08-11 | 2021-12-03 | 深圳Tcl新技术有限公司 | Interface rendering method and device, electronic equipment and storage medium |
CN114510231A (en) * | 2020-11-17 | 2022-05-17 | 腾讯科技(深圳)有限公司 | Application construction method, device, equipment and computer readable storage medium |
-
2022
- 2022-06-20 WO PCT/CN2022/099931 patent/WO2023245367A1/en active Application Filing
- 2022-06-20 CN CN202280004152.1A patent/CN117616394A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090091563A1 (en) * | 2006-05-05 | 2009-04-09 | Electronics Arts Inc. | Character animation framework |
US20210064739A1 (en) * | 2018-10-23 | 2021-03-04 | Citrix Systems, Inc. | Local secure rendering of web content |
CN111158818A (en) * | 2019-12-24 | 2020-05-15 | 中国建设银行股份有限公司 | Page rendering method and device |
CN114510231A (en) * | 2020-11-17 | 2022-05-17 | 腾讯科技(深圳)有限公司 | Application construction method, device, equipment and computer readable storage medium |
CN113742014A (en) * | 2021-08-11 | 2021-12-03 | 深圳Tcl新技术有限公司 | Interface rendering method and device, electronic equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117539491A (en) * | 2024-01-09 | 2024-02-09 | 腾讯科技(深圳)有限公司 | Page layout method, page layout device, electronic device, storage medium and program product |
CN117539491B (en) * | 2024-01-09 | 2024-04-26 | 腾讯科技(深圳)有限公司 | Page layout method, page layout device, electronic device, storage medium and program product |
Also Published As
Publication number | Publication date |
---|---|
CN117616394A (en) | 2024-02-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019174469A1 (en) | Message notification method, apparatus, device and storage medium | |
JP6884870B2 (en) | Blockchain-based data processing methods and equipment | |
WO2018188289A1 (en) | Information display method, apparatus, and terminal | |
WO2018068657A1 (en) | Interface moving method, device, intelligent terminal, server and operating system | |
US20190172403A1 (en) | Method for controlling screen display and device using the same | |
WO2016082586A1 (en) | Webpage update method and apparatus | |
WO2021110133A1 (en) | Control operation method and electronic device | |
EP3232323B1 (en) | Method and apparatus for displaying status information of application | |
US20200159789A1 (en) | Method and device for page display, and storage medium | |
US20210165670A1 (en) | Method, apparatus for adding shortcut plug-in, and intelligent device | |
WO2017028450A1 (en) | Shutdown prompt method and device | |
CN104407865B (en) | The display methods and device of window | |
WO2023245367A1 (en) | Hybrid application rendering system, rendering method, electronic device, and storage medium | |
WO2016065814A1 (en) | Information selection method and device | |
US20230004620A1 (en) | Page display method | |
US11210449B2 (en) | Page display method and device and storage medium | |
WO2023001163A1 (en) | Screen refreshing method and device capable of improving dynamic effect performance | |
CN111667199A (en) | Workflow construction method and device, computer equipment and storage medium | |
WO2023046101A1 (en) | Icon display method and apparatus, and electronic device | |
US20170308397A1 (en) | Method and apparatus for managing task of instant messaging application | |
US20190012299A1 (en) | Displaying page | |
WO2018010326A1 (en) | Screen display method and device | |
CN114546992A (en) | Database migration method and device, storage medium and electronic equipment | |
CN114298000A (en) | Application-based note generation method, device, storage medium and program product | |
CN112306702B (en) | Data sharing method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
WWE | Wipo information: entry into national phase |
Ref document number: 202280004152.1 Country of ref document: CN |
|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22947148 Country of ref document: EP Kind code of ref document: A1 |