A running method and running kernel based on the V8 high-performance mini-game running kernel

By adopting a three-layer architecture and optimization strategy based on the V8 high-performance mini-game runtime kernel, the problem of unsmooth mini-game operation has been solved, achieving fast startup and efficient operation, thus meeting the performance requirements of the mini-game market.

CN120123120BActive Publication Date: 2025-11-144399 NETWORK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510217871.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-11-14
Estimated Expiration
2045-02-26

AI Technical Summary

Technical Problem

The existing mini-game runtime kernel relies on the browser's WebView, resulting in sluggish and laggy gameplay, which cannot meet the rapidly growing market demand for mini-games.

Method used

It adopts a high-performance mini-game runtime kernel based on V8. Through a three-layer architecture of API interface layer, bridge layer and native layer, it uses the combination of V8 kernel module, C++ module and Android module to realize an independent game runtime kernel. It uses command cache pool and task thread pool to optimize rendering and task processing.

Benefits of technology

It enables quick startup, smooth operation, and low performance loss of mini-games, solves the lag problem in traditional browser mode, and improves resource loading speed and hardware utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120123120B_ABST
    Figure CN120123120B_ABST
Patent Text Reader

Abstract

This invention provides a running method and kernel based on the V8 high-performance mini-game runtime kernel, comprising an API interface layer, a bridging layer, and a native layer. The native layer includes a V8 kernel module, a C++ module, and an Android module. The V8 kernel module is bound to the C++ module using object binding technology, and the V8 kernel module is associated with the corresponding type of API interface of the Android module through JNI mapping technology. This invention provides a running method and kernel based on the V8 high-performance mini-game runtime kernel, which is completely independent of the browser WebView implementation. It has advantages such as openness, lightweight power, high efficiency, smooth operation, smooth rendering, fast startup speed, and stable operation, meeting the requirements of mini-game operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mini-game kernel runtime environment technology, specifically to a running method and kernel based on the V8 high-performance mini-game runtime kernel. Background Technology

[0002] The rapid growth of the mini-game market has posed new challenges to the performance of the mini-game runtime environment. It is particularly important to provide a kernel environment that can start up quickly, run games smoothly, and have low performance overhead.

[0003] Currently, the core of mini-games relies on the browser's WebView. Due to the complexity and numerous limitations of the WebView design, mini-games often experience sluggish gameplay and severe lag, hindering their widespread adoption. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a running method and kernel based on the V8 high-performance mini-game running kernel, which can effectively solve the above problems.

[0005] The technical solution adopted in this invention is as follows:

[0006] This invention provides a running method based on the V8 high-performance mini-game kernel, comprising the following steps:

[0007] Step S1: When the mini-game needs to be launched, the bus management module creates a main game process for the mini-game and launches a mini-game kernel in the main game process;

[0008] Step S2: During the operation of the mini-game, when the API interface layer of the mini-game runtime kernel receives a call instruction for the target API interface from the mini-game runtime engine, the API interface layer sends the call instruction for the target API interface to the bridge layer.

[0009] Step S3: The bridging layer determines whether the target API interface to be called is a rendering type API interface. If it is, then proceed to step S4; otherwise, proceed to step S5.

[0010] Step S4: The bridging layer encapsulates the call instructions of the target API interface and stores them in the command cache pool located in the bridging layer. When the data stored in the command cache pool reaches the threshold, it triggers the sending of the call instructions of the rendering type API interface to the native layer, and then executes step S6.

[0011] Step S5: The bridging layer directly sends the call instruction to the target API interface to the native layer, and then executes step S6.

[0012] Step S6: The V8 kernel module of the native layer receives the call instruction for the target API interface from the bridge layer, parses the call instruction for the target API interface, and if it is a call instruction for a rendering type API interface, or an API interface implemented by a C++ module, then execute step S7; if it is an API interface implemented by an Android module, then execute step S8.

[0013] In step S7, the V8 kernel module is bound to a C++ module using object binding technology. Therefore, the V8 kernel module sends the call instruction for the target API interface to the C++ module; the C++ module sends the call instruction for the target API interface to the task management module; the task management module treats the call to the target API interface as a task and adds it to the task thread pool; the task thread pool executes the tasks sequentially to complete the call to the target API interface.

[0014] In step S8, the V8 kernel module uses JNI mapping technology to find the corresponding type of API interface associated with the Android module and completes the call to the found corresponding type of API interface.

[0015] Preferably, the API interface layer is an external interface implemented using the JS language.

[0016] Preferably, the task management module further subdivides tasks into IO tasks, network tasks, UI rendering tasks, and regular tasks; the task management module distinguishes the types of received call instructions to the target API interface, determines the task type, and allocates the corresponding tasks to the task thread pool according to different task types.

[0017] Preferably, the task management module is connected to a rendering module, a file module, a network module, and an audio module, and executes tasks of corresponding types through the rendering module, the file module, the network module, and the audio module.

[0018] Preferably, the rendering module executes the rendering task by calling the API interface of the rendering type, specifically in the following manner:

[0019] The rendering module includes a rendering API interface and a statistics module;

[0020] The Android module provides a SurfaceView as a container for game screen rendering; the rendering API interface calls and executes the context in the EGL graphics library and outputs it to the SurfaceView, uses eglSwapBuffers to submit the buffer for drawing, realizes interface refresh, and completes the rendering and display of the game interface on the screen;

[0021] The statistics module records and summarizes the calls to the rendering API interface by the API interface layer, including CPU, memory usage, vertex data usage, texture usage, DrawCall, and frame rate information. This information is then provided to the API interface layer to analyze API call statistics and presented to the game layer.

[0022] Preferably, the file module is associated with an API interface for file types, used to perform calls to the file.

[0023] Preferably, the network module is associated with a network API interface.

[0024] Preferably, the audio module, associated with the audio API interface, adopts a multi-track mixing and single-track output mode, uses a multi-threaded decoding and lock-free design scheme to process audio decoding and mixing, and adds an intermediate buffer to implement the audio interface called by the API interface layer.

[0025] Preferably, the bus management module adopts a bus scheme to manage the multiple mini-game processes. When each mini-game is running, it sends an event flag to the bus management module through its main game process to report the status of the mini-game's running kernel.

[0026] The present invention also provides a V8 high-performance mini-game runtime kernel, wherein the V8 high-performance mini-game runtime kernel is run according to the aforementioned running method.

[0027] The present invention provides a running method and a running kernel based on the V8 high-performance mini-game running kernel, which have the following advantages:

[0028] This invention provides a running method and a running kernel based on the V8 high-performance mini-game running kernel. It is completely independent of the browser WebView and has the advantages of being open, lightweight and powerful, efficient, smooth running, smooth rendering, fast startup speed and stable operation, thus meeting the running requirements of mini-games. Attached Figure Description

[0029] Figure 1 The overall architecture diagram of the V8 high-performance mini-game runtime kernel provided by this invention;

[0030] Figure 2 A schematic diagram of the native layer based on the V8 high-performance mini-game runtime kernel provided for this invention;

[0031] Figure 3 A structural diagram of the command cache pool provided by the present invention;

[0032] Figure 4Another structural diagram of the command cache pool provided by the present invention;

[0033] Figure 5 A detailed diagram illustrating the API call principles for the rendering types provided in this invention;

[0034] Figure 6 A schematic diagram illustrating the calling principle of the rendering module provided by this invention;

[0035] Figure 7 A schematic diagram illustrating the calling principle of the network module provided by this invention;

[0036] Figure 8 The diagram illustrates the calling principle of the audio module provided by this invention. Detailed Implementation

[0037] To make the technical problems solved, the technical solutions, and the beneficial effects of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the invention.

[0038] This invention provides a running method and a running kernel based on the V8 high-performance mini-game running kernel. It is completely independent of the browser WebView and has the advantages of being open, lightweight and powerful, efficient, smooth running, smooth rendering, fast startup speed and stable operation, thus meeting the running requirements of mini-games.

[0039] This invention provides a high-performance mini-game runtime kernel based on V8, whose functionality mainly includes three layers: API interface layer, bridging layer, and native layer.

[0040] The API interface layer connects to the mini-game runtime engine and receives call instructions from the engine for target API interfaces. The mini-game runtime engine is compatible with Cocos Creator, Erget, Layabox, and Unity engines, making it widely applicable. The API interface layer is an external interface implemented using JavaScript.

[0041] The bridging layer, connecting the API interface layer and the native layer, acts as a glue layer connecting them. Since the API interface layer provides the external interface in JavaScript, while the native layer provides the native functionality in Java and C++, the bridging layer serves as a bridge for cross-language calls. The bridging layer also features a command cache pool.

[0042] The native layer primarily includes the V8 kernel module, Android module, C++ module, task management module, and rendering, file, network, audio, and other modules connected to the task management module. The native layer binds the API interfaces implemented by the Android module and the C++ module to the context of the V8 kernel module, enabling the invocation and execution of the corresponding API interfaces. Specifically, the Android module is bound to the V8 kernel module using JNI (Java Native Interface) technology as a mapping to find the corresponding API interface implemented by the Android module. The API interfaces implemented by the C++ module are mainly bound to the V8 kernel module using object binding technology. Furthermore, the C++ module is connected to the task management module, encapsulating the invocation tasks and dispatching them to the task thread pool connected to the task management module. This layer mainly contains the rendering, file, network, audio, and other modules.

[0043] The V8 kernel module is a core module. Utilizing JIT (Just-in-Time) capabilities improves execution efficiency, making games run more smoothly within the kernel. In this invention, C++ module objects are bound to the V8 kernel context to enable calls to the API interfaces associated with the C++ module. The V8 kernel module, through JNI (Java Native Interface) technology as a mapping, enables calls to the API interfaces implemented by the Android module. Therefore, this invention achieves comprehensive access to the API interfaces implemented by both the C++ module and the Android module.

[0044] In addition to assisting with rendering, the Android module also provides basic API interfaces for obtaining system information, Bluetooth, and keyboard operations.

[0045] Combination Figures 1-2 This invention provides a running method based on the V8 high-performance mini-game kernel, comprising the following steps:

[0046] Step S1: When the mini-game needs to be launched, the bus management module creates a main game process for the mini-game and launches a mini-game kernel in the main game process;

[0047] Step S2: During the operation of the mini-game, when the API interface layer of the mini-game runtime kernel receives a call instruction for the target API interface from the mini-game runtime engine, the API interface layer sends the call instruction for the target API interface to the bridge layer.

[0048] Step S3: The bridging layer determines whether the target API interface to be called is a rendering type API interface. If it is, then proceed to step S4; otherwise, proceed to step S5.

[0049] Step S4: The bridging layer encapsulates the call instructions of the target API interface and stores them in the command cache pool located in the bridging layer. When the data stored in the command cache pool reaches the threshold, it triggers the sending of the call instructions of the rendering type API interface to the native layer, and then executes step S6.

[0050] refer to Figure 3 and Figure 4 This is a structure diagram of the command cache pool. In the bridge layer, DataView is used to write commands to the command cache pool. The command cache pool encapsulates and caches commands in binary form. Specifically, the first two bytes of each command store the command type, and each command has a corresponding encapsulation method, such as the glEnable(unit type) interface. The format of the data cached in the command cache pool is as follows: Figure 3 As shown. When another command, glMask(bool r, bool g, bool a), is added, the command cache pool cache data format changes to... Figure 4 This process of encapsulation and caching is repeated to achieve data encapsulation.

[0051] When the data cached in the command cache pool reaches the trigger threshold (refresh command or screen vertical synchronization command), the cached data is sent to the native layer. The native layer then parses and executes the command using a pointer movement mechanism. Specifically, the pointer initially points to the beginning of the command cache pool. As the cached data is parsed, the pointer moves forward until a termination command is encountered, completing the parsing and execution of the cached data.

[0052] Step S5: The bridging layer directly sends the call instruction to the target API interface to the native layer, and then executes step S6.

[0053] Step S6: The V8 kernel module of the native layer receives the call instruction for the target API interface from the bridge layer, parses the call instruction for the target API interface, and if it is a call instruction for a rendering type API interface, or an API interface implemented by a C++ module, then execute step S7; if it is an API interface implemented by an Android module, then execute step S8.

[0054] In step S7, the V8 kernel module is bound to a C++ module using object binding technology. Therefore, the V8 kernel module sends the call instruction for the target API interface to the C++ module; the C++ module sends the call instruction for the target API interface to the task management module; the task management module treats the call to the target API interface as a task and adds it to the task thread pool; the task thread pool executes the tasks sequentially to complete the call to the target API interface.

[0055] In step S8, the V8 kernel module uses JNI mapping technology to find the corresponding type of API interface associated with the Android module and completes the call to the found corresponding type of API interface.

[0056] In this invention, the task management module subdivides tasks into IO tasks, network tasks, UI rendering tasks, and regular tasks; the task management module distinguishes the types of received call instructions to the target API interface, determines the task type, and allocates them to the task thread pool according to different task types to execute the corresponding tasks.

[0057] The task management module creates a task manager, which is connected to a rendering module, a file module, a network module, and an audio module. Through the rendering module, the file module, the network module, and the audio module, tasks of corresponding types are executed.

[0058] (1) Rendering module

[0059] The rendering module executes rendering tasks and completes the calls to the API interfaces of the rendering type, specifically in the following way:

[0060] The rendering module includes a rendering API interface and a statistics module;

[0061] Combination Figure 5 and Figure 6 The Android module provides a SurfaceView as a container for game screen rendering, and achieves ANativeWindow binding by setting the EGL rendering environment; the rendering API interface calls and executes the Context in the EGL graphics library and outputs it to the SurfaceView, uses eglSwapBuffers to submit the buffer for drawing, realizes interface refresh, and completes the rendering and display of the game interface on the screen;

[0062] The statistics module records and summarizes the calls to the rendering API interface by the API interface layer, including CPU, memory usage, vertex data usage, texture usage, DrawCall, and frame rate information. This information is then provided to the API interface layer to analyze API call statistics and presented to the game layer.

[0063] As an example, the rendering module adopts a single-screen design pattern, reducing the overhead of multi-screen rendering context management and switching. Off-screen capabilities are directly provided by the graphics API interface, simplifying the entire rendering chain. In the bridging layer, calls to rendering type API interfaces from the API interface layer are converted into command instructions and stored in a command cache pool, with the data stored in binary form. When the command cache pool reaches a set trigger threshold, the command is sent to the native layer. The native layer parses the command and calls the rendering module through the UI rendering task to implement the rendering function. Specifically, the rendering API interface uses the OpenGL native graphics API to implement all WebGL 1.0 and WebGL 2.0 API methods, and uses the SKIA open-source 2D graphics library to implement all Canvas2D APIs, providing them to the API interface layer for calls.

[0064] In this invention, calls to rendering type API interfaces are first stored in the command cache pool of the bridging layer. Only when the command cache pool reaches the set trigger threshold will the rendering task be executed through the native layer. The advantage of this design is that it avoids the overhead of frequent interaction between the bridging layer and the native layer and improves the running stability of the kernel.

[0065] (2) File Module

[0066] The file module, associated with the API interface for file types, is used to perform calls to files. The file module provides all the file interfaces required by the API interface layer.

[0067] (3) Network module

[0068] The network module is associated with a network API interface.

[0069] Combination Figure 7 This diagram illustrates the calling principle of the network module. Specifically, the network module provides XMLHttpRequest and WebSocket network interfaces corresponding to the HTTP / 2.0 protocol. XMLHttpRequest utilizes the Cronet open-source library, which supports modern protocols such as HTTP / 2.0 and QUIC. Extension plugins are added to ensure compatibility with the standard XMLHttpRequest interface. CronetEngine manages network requests, encapsulates data for each request (represented by UrlRequest), and leverages callback mechanisms to manage the request lifecycle, caching mechanisms to accelerate data requests, and avoid duplicate requests.

[0070] (4) Audio module

[0071] The audio module, associated with the audio API interface, adopts a multi-track mixing and single-track output mode, uses a multi-threaded decoding and lock-free design to handle audio decoding and mixing, and adds an intermediate buffer to implement the audio interface called by the API interface layer.

[0072] Combination Figure 8 This is a schematic diagram illustrating the calling principle of the audio module. Multi-track mixing and single-track output involve using multiple audio inputs as raw data in the Input Buffer, then combining the multiple tracks using the Mixer, and finally outputting the multiple audio tracks into the Output Buffer. The codec processes the data in between.

[0073] In this invention, the bus management module adopts a bus scheme to manage multiple mini-game processes. When each mini-game is running, it sends an event flag to the bus management module through its main game process to report the status of the mini-game's running kernel.

[0074] Specifically, the present invention uses a bus management module to manage the processes of multiple mini-games. Each mini-game starts a main game process, manages the threads running in the mini-game, and sends event flags to the bus management module through its main game process to report the status of the mini-game's running kernel.

[0075] The present invention also provides a V8 high-performance mini-game runtime kernel, which runs according to the aforementioned running method based on the V8 high-performance mini-game runtime kernel.

[0076] This invention provides a running method and a running kernel based on the V8 high-performance mini-game running kernel, which has the following advantages:

[0077] 1) This invention uses an independent mini-game runtime kernel to run mini-games, which does not rely on the browser WebView. It is decoupled, has stronger adaptability, and improves resource loading speed and game running smoothness, solving the problems of slow resource loading and game lag in traditional browser mode.

[0078] 2) This invention reduces complex system design and costs, and improves hardware utilization;

[0079] 3) The rendering module of this invention uses a command caching pool strategy to encapsulate data and call the underlying API through binary data, which reduces the overhead of environment switching and improves the smoothness of the game;

[0080] 4) This invention optimizes the algorithms and design patterns of the rendering module, file module, network module, and audio module to improve performance.

[0081] Therefore, this invention is based on the design and implementation of the V8 high-performance mini-game runtime kernel. It uses JIT efficiency to optimize game smoothness, uses the native graphics library OpenGL combined with a command caching pool strategy to optimize rendering stuttering, uses the native file read and write capabilities provided by C++ to improve game loading speed, and utilizes bus technology to reduce memory consumption when switching between multiple mini-game instances, thereby comprehensively improving the performance of mini-games.

[0082] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A running method based on the V8 high-performance mini-game runtime kernel, characterized in that, Includes the following steps: Step S1: When the mini-game needs to be launched, the bus management module creates a main game process for the mini-game and launches a mini-game kernel in the main game process; Step S2: During the operation of the mini-game, when the API interface layer of the mini-game runtime kernel receives a call instruction for the target API interface from the mini-game runtime engine, the API interface layer sends the call instruction for the target API interface to the bridge layer. Step S3: The bridging layer determines whether the target API interface to be called is a rendering type API interface. If it is, then proceed to step S4; otherwise, proceed to step S5. Step S4: The bridging layer encapsulates the call instructions of the target API interface and stores them in the command cache pool located in the bridging layer. When the data stored in the command cache pool reaches the threshold, it triggers the sending of the call instructions of the API interface of the rendering type to the native layer, and then executes step S6. Step S5: The bridging layer directly sends the call instruction to the target API interface to the native layer, and then executes step S6. Step S6: The V8 kernel module of the native layer receives the call instruction for the target API interface from the bridge layer, parses the call instruction for the target API interface, and if it is a call instruction for a rendering type API interface, or an API interface implemented by a C++ module, then execute step S7; if it is an API interface implemented by an Android module, then execute step S8. In step S7, the V8 kernel module is bound to a C++ module using object binding technology. Therefore, the V8 kernel module sends the call instruction for the target API interface to the C++ module; the C++ module sends the call instruction for the target API interface to the task management module; the task management module treats the call to the target API interface as a task and adds it to the task thread pool; the task thread pool executes the tasks sequentially to complete the call to the target API interface. In step S8, the V8 kernel module uses JNI mapping technology to find the corresponding type of API interface associated with the Android module and completes the call to the found corresponding type of API interface.

2. The running method based on the V8 high-performance mini-game kernel according to claim 1, characterized in that, The API interface layer is an external interface implemented using the JavaScript language.

3. The running method based on the V8 high-performance mini-game kernel according to claim 1, characterized in that, The task management module subdivides tasks into IO tasks, network tasks, UI rendering tasks, and regular tasks. The task management module distinguishes the types of received call instructions to the target API interface, determines the task type, and allocates the corresponding task to the task thread pool according to the different task types to execute the corresponding tasks.

4. The running method based on the V8 high-performance mini-game kernel according to claim 1, characterized in that, The task management module is connected to a rendering module, a file module, a network module, and an audio module. Through the rendering module, the file module, the network module, and the audio module, tasks of corresponding types are executed.

5. The running method based on the V8 high-performance mini-game kernel according to claim 4, characterized in that, The rendering module executes rendering tasks and completes the calls to the API interfaces of the rendering type, specifically in the following way: The rendering module includes a rendering API interface and a statistics module; The Android module provides a SurfaceView as a container for rendering game graphics; The rendering API interface calls and executes the context output in the EGL graphics library to the surface view SurfaceView, and uses eglSwapBuffers to submit the buffer for drawing, thereby refreshing the interface and completing the rendering and display of the game interface on the screen. The statistics module records and summarizes the calls to the rendering API interface by the API interface layer, including CPU, memory usage, vertex data usage, texture usage, DrawCall, and frame rate information. This information is then provided to the API interface layer to analyze API call statistics and presented to the game layer.

6. The running method based on the V8 high-performance mini-game kernel according to claim 4, characterized in that, The file module is associated with the API interface for file types, and is used to perform calls to files.

7. The running method based on the V8 high-performance mini-game kernel according to claim 4, characterized in that, The network module is associated with a network API interface.

8. The running method based on the V8 high-performance mini-game kernel according to claim 4, characterized in that, The audio module, associated with the audio API interface, adopts a multi-track mixing and single-track output mode, uses a multi-threaded decoding and lock-free design to handle audio decoding and mixing, and adds an intermediate buffer to implement the audio interface called by the API interface layer.

9. The running method based on the V8 high-performance mini-game kernel according to claim 1, characterized in that, The bus management module uses a bus scheme to manage the processes of multiple mini-games. When each mini-game is running, it sends an event flag to the bus management module through its main game process to report the status of the mini-game's running kernel.

10. A high-performance mini-game runtime kernel based on V8, characterized in that, The V8 high-performance mini-game runtime kernel is run according to any one of claims 1-9.

Citation Information

Patent Citations

  • Rendering method and device based on game engine and electronic equipment

    CN111408138A

  • Small program engine running on own App

    CN117348948A