H5 page character and expression hybrid input system and method
The H5 page text and emoji hybrid input system, which combines hardware acceleration and software collaboration, solves the problems of main thread blocking, cross-platform rendering consistency, and multi-tab concurrency conflicts, achieving an efficient and stable emoji input experience with verifiability and industrial-grade stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-16
- Publication Date
- 2026-04-10
AI Technical Summary
Existing H5 pages suffer from several issues when handling mixed text and emoji input, including the risk of main thread blocking and crashing, lack of cross-platform rendering consistency, performance bottlenecks in software index structure, multi-tab concurrency conflicts, and unverifiable technical effects.
Deploy an H5 page text and emoji hybrid input system. The system includes a front-end intent acquisition module, a dual-model storage array module, an encrypted hash index module, a stress resource scheduling module, and a cross-platform rendering consistency verification module. Through hardware acceleration and software collaboration, it achieves efficient input event processing, cross-platform rendering consistency, and the merging of concurrent editing across multiple tabs.
Completely eliminates the risk of main thread blocking, achieves high-precision cursor positioning, improves cross-platform rendering consistency, resolves multi-tab concurrency conflicts, and achieves near-native response speed, significantly reduces memory usage and GC pressure, and is verifiable and has industrial-grade stability.
Smart Images

Figure CN121834079A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer data processing technology, and in particular to an H5 page text and emoticon mixed input system and method. Background Technology
[0002] Existing rich text editors for H5 pages have the following unresolved technical issues when handling mixed text and emoji input:
[0003] Main thread blocking and crash risk: When users insert emojis frequently and continuously, the JavaScript event loop is occupied by DOM update operations for a long time, causing the main thread to be blocked, which in turn triggers the browser's "unresponsive" warning. In extreme cases, it may even cause the tab to crash, seriously affecting the user experience.
[0004] Lack of cross-platform rendering consistency: Different browser engines exhibit systematic deviations in measuring the geometric properties of emoji nodes, leading to issues such as incorrect cursor positioning and overlapping or misaligned emojis. Existing CSS adaptation solutions can only address style differences and cannot eliminate rendering calculation deviations at the engine level.
[0005] Software index structure performance bottleneck: In large-scale scenarios with mixed text and emojis, the query latency of the character-DOM mapping table implemented by traditional JavaScript objects increases significantly, and the memory usage expands non-linearly with the increase of data volume, triggering frequent GC pauses, thus becoming a performance bottleneck.
[0006] Multi-tab concurrency conflicts: When multiple tabs from the same source are edited simultaneously, the JavaScript timer mechanism cannot accurately detect operation conflicts within a short window. Existing OT algorithms implemented purely in software have a low success rate in merging, resulting in significant content overwriting and loss issues.
[0007] The technical effects cannot be verified: Existing solutions only qualitatively describe system performance and lack standardized quantitative testing methods and authoritative certified experimental data, making it difficult to meet the strict requirements of patent examination for the reproducibility of technical effects. Summary of the Invention
[0008] The purpose of this invention is to provide an H5 page text and emoticon mixed input system and method, thereby solving the aforementioned problems existing in the prior art.
[0009] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0010] An H5 page text and emoticon hybrid input system, deployed within an independent rendering engine sandbox of the browser process, includes the following functional modules interconnected via a high-speed memory bus:
[0011] The front-end intent acquisition module consists of an event interruption capture unit, an event queue buffer management unit, and a lightweight neural network inference unit. The event interruption capture unit is directly connected to the browser's input event driving layer, converting user input actions into high-priority system interrupt signals. The event queue buffer management unit is a circular FIFO buffer structure with a depth of 128 event items, used to temporarily store the raw input events output by the event interruption capture unit. The lightweight neural network inference unit is a WebAssembly binary code solidification unit that directly reads the events to be processed in the event queue buffer management unit through a shared memory mapping area, performs neural network forward inference, and outputs the stress state flag to the system bus.
[0012] Dual-model storage array module: It includes a text character storage management unit and a DOM node storage management unit. The two storage units are physically isolated and selectively connected to the synchronization engine controller through a cross switch matrix. The text character storage management unit is a dual-port RAM structure. One port uses the character offset as the address line, and the other port uses the private Unicode encoding as the data retrieval line. The DOM node storage management unit is managed by an object pool allocator. Each emoji DOM node is pre-allocated a 16KB aligned memory block. The first byte of the memory block marks the rendering status flag.
[0013] Encrypted hash index module: It is configured to map character positions to encrypted index keys using the national cryptographic SM3 hash algorithm, and to manage the conflict chain using a content-addressed storage structure. Each index entry is associated with the text character model position and the DOM node position. At the same time, a version vector clock is maintained to detect conflicts in concurrent editing of multiple tabs.
[0014] The stress-driven resource scheduling module includes a priority encoding unit, a main thread monitoring unit, and a background resource preloading unit. The priority encoding unit receives stress status flags from the lightweight neural network inference unit, dynamically increasing the interrupt priority of keydown / input events to the highest level while decreasing the interrupt priority of scroll / resize events to the lowest level. The main thread monitoring unit is a hardware performance counter with a sampling period of 1ms. When a single task execution time > 50ms is detected, a forced task interruption signal is triggered. The background resource preloading unit communicates with the browser's Service Worker thread to implement priority loading of emoji resources.
[0015] The cross-platform rendering consistency verification module consists of a browser kernel feature acquisition unit, a platform compensation coefficient storage unit, and a three-stage state transition unit. The browser kernel feature acquisition unit includes WebKit, Blink, and Gecko kernel probes. Each probe is a throttling code segment injected into the browser kernel to collect the return value of getBoundingClientRect(). The platform compensation coefficient storage unit pre-stores the rendering deviation compensation table for each kernel version. The three-stage state transition unit controls the editing state transition sequence, executing the atomic operations of "serialization → transmission → verification" in sequence.
[0016] Preferably, the lightweight neural network inference unit is connected to the event queue buffer management unit via the AXI4-Stream bus, and its inference weight tensor is stored in an independent weight storage. The weight storage supports online update mode. When the user rejects the recommended emoji 10 times in the last 100 inputs, the lightweight neural network inference unit loads negative feedback samples from the IndexedDB non-volatile storage area and triggers a hot update of the weights. During the update, the inference unit enters bypass mode and directly outputs the default stress state flag.
[0017] Preferably, the cross-switch matrix of the dual-model storage array module is driven by the dual-model synchronization engine controller; the synchronization engine controller includes a delay measurement unit and a structure switching unit; the delay measurement unit is a timestamp counter that records the difference Δt between the write time of the text character storage management unit and the corresponding update time of the DOM node storage management unit; when Δt>15ms, the structure switching unit sends a configuration register update signal to switch the access granularity of the underlying storage structure of the encrypted hash index module from a single character to a 1KB data block, and enables the background buffer merging mode.
[0018] Preferably, each index entry of the encrypted hash index module contains a 128-bit extended field, which stores the 128-dimensional sentiment vector of the emoji. The sentiment vector is generated by the sentiment vector calculation submodule, which performs a cosine similarity operation. When the similarity is less than 0.3, the sentiment vector calculation submodule outputs an animation trigger signal to the DOM node storage management unit, driving the CSS animation controller to insert a 0.2-second transition animation at the corresponding emoji node.
[0019] Preferably, the background resource preloading unit of the stress resource scheduling module communicates with the browser Service Worker thread through the MessageChannel bidirectional channel; when the stress state flag output by the lightweight neural network inference unit is valid, the background resource preloading unit sends a preloading instruction to the Service Worker, which includes a list of emoji resource URLs and priority encoding; after receiving the instruction, the Service Worker calls the priority: 'high' option of the fetch() API to cache resources in advance.
[0020] Preferably, the three-stage state transition unit of the cross-platform rendering consistency verification unit includes a state register and a hash fingerprint comparator; the state register is a 4-bit Gray code register, and the state codes are: 0000, 0001, 0011, 0010; the hash fingerprint comparator is a hardware SHA256 unit, used to calculate the rendering fingerprint of the DOM node storage management unit; when the verification fails, the state register jumps to the "realignment state", triggering the pixel-level realignment engine, which is a GPU shader unit, to forcibly reset the transform matrix of all facial expression nodes.
[0021] This is an H5 page text and emoji mixed input method based on the same concept. The method is executed collaboratively by the system's hardware state machine and software callback functions, and includes the following steps:
[0022] Step S1: When the event interruption capture unit detects that the user has selected an emoji, it writes the original event item to the event queue buffer management unit. This item includes the timestamp, emoji ID, and current cursor character offset. The lightweight neural network inference unit reads the last 5 event items from the buffer management unit, extracts the cursor context features and emoji sequence features, and inputs them into the neural network inference. If the probability of outputting the Top 1 emoji is >0.7, the lightweight neural network inference unit sends a pre-placement signal to the DOM node storage management unit, inserts a transparent DIV placeholder node at the target position, and starts the emoji resource loading DMA transfer in parallel.
[0023] Step S2: When the main thread monitoring unit detects that the frequency of emoticon insertion is >3 times / second and lasts for >2 seconds, the priority encoding unit increases the arbitration priority of the emoticon event channel in the system bus; the synchronization engine controller suspends the real-time synchronization between the text character storage management unit and the DOM node storage management unit, and builds a queue of emoticons to be submitted in the append area at the end of the text character storage management unit; the queue is a circular linked list structure, and each node contains the emoticon Unicode encoding, insertion offset, and a physical pointer to the next node; when the queue length reaches 5 or the input interval is >1 second, the synchronization engine controller atomically submits the queue nodes to the DOM node storage management unit in batches, and generates a single variable-length private Unicode encoding to write to the text character storage management unit;
[0024] Step S3: When the encrypted hash index module receives the cursor movement instruction, its SM3 hash operation unit calculates the hash key of the target position, queries the underlying storage structure to obtain the pointer of the corresponding DOM node storage management unit; for ordinary characters, the pointer points to the text node object, and the cursor offset is accumulated by the value of the fixed-width font width register; for emoticons, the pointer points to the semantic unit object, queries the platform compensation coefficient storage unit to obtain the width compensation value of the current browser kernel, accumulates the result to generate sub-pixel level cursor coordinates, and writes them to the cursor position register;
[0025] Step S4: When the user triggers the submission operation, the serialization engine of the cross-platform rendering consistency verification module converts the content of the text character storage management unit into a TLV binary stream, where the Type field is 0x01 or 0x02, the Length field is a variable-length integer encoding, and the Value field is a UTF-8 text or emoji resource identifier; the engine also calculates the combined hash value of the current viewport width, DPR value, and font scaling factor to generate a cross-platform signature, which is appended to the end of the binary stream; after the binary stream is compressed by the Brotli compression coprocessor, it is sent to the server through the XMLHttpRequest hardware acceleration unit.
[0026] Preferably, the cursor context feature extraction in step S1 is performed by a feature extraction hardware unit, which is a 128-bit wide SIMD register group that loads the Unicode encoding of the characters before and after the cursor in parallel. The weight hot update of the lightweight neural network inference unit is managed by a weight update controller, which monitors the transaction completion signal of IndexedDB and performs a ping-pong switch when the weight storage is idle. During the switch, the inference unit accesses the spare weight storage to achieve zero-downtime update.
[0027] Preferably, in step S2, each node of the circular linked list structure contains an 8-bit status flag, defined as follows: Bit0, Bit1, Bit2, Bit3; when the synchronization engine controller performs an atomic commit, it updates the node status in batches using CAS atomic instructions. If any node status is not "to be inserted", the rollback mechanism is triggered to reset the status of the committed nodes and interrupt the commit signal.
[0028] Preferably, in step S3, when the cursor target position is inside the expression semantic unit, the cursor position register automatically performs boundary alignment, and the alignment signal triggers the micro-interaction controller; the micro-interaction controller is a GPIO extension unit that drives the browser UI thread to draw sentiment interpretation labels above the semantic unit. The label content is extracted by the sentiment vector decoder from the 128-dimensional vector of the encrypted hash index module entry and mapped to text.
[0029] The Brotli compression coprocessor in step S4 is a hardware compression engine. Its compression dictionary is statically constructed from emoji resource identifiers and commonly used text phrases. The combined hash value calculation of the cross-platform signature is performed by a hardware-accelerated hash unit, using the SM3 and SHA256 concatenation mode. The server verifies the signature through the signature verification FPGA. If the verification fails, it returns the HTTP 449 Retry With status code, triggering the client re-rendering process.
[0030] The reactive resource scheduling module includes a device memory awareness submodule. This submodule reads the memory capacity value through the navigator.deviceMemory API and maps it to the memory pressure level. When the memory is less than 4GB and the reactive state token lasts for more than 10 seconds, the emoji resource is automatically downgraded from PNG to WebP format, and the forced garbage collection scheduler is triggered. The scheduler monitors and releases unnecessary DOM references through performance.memory.
[0031] The beneficial effects of this invention are:
[0032] Completely eliminate the risk of main thread blocking: By decoupling input events from the JavaScript event loop through the multimodal intent recognition module, and combining the dynamic priority adjustment of the reactive resource scheduling module with the long task forced segmentation mechanism, the main thread achieves zero blocking in the expression burst mode, completely avoiding the browser "unresponsive" crash problem, and the system stability reaches industrial-grade standards.
[0033] Achieving high-precision cursor positioning: The cross-platform rendering consistency verification module collects real rendering data through kernel probes and builds a compensation coefficient mapping table. Combined with the fast positioning capability of the encrypted hash index module, the cursor coordinate accuracy reaches the sub-pixel level, and the cross-browser kernel positioning error is reduced to a negligible range, fundamentally solving user experience pain points such as cursor misalignment and overlapping expressions.
[0034] Significantly improve cross-platform rendering consistency: By pre-storing rendering deviation tables for each browser kernel and executing a lossless state migration protocol, it can maintain extremely high rendering consistency in various device and kernel combination environments, ensuring that users on multiple devices receive a completely consistent visual experience and eliminating the cross-platform adaptation problems that are common in traditional solutions.
[0035] Effectively resolves multi-tab concurrent conflicts: Utilizes version vector clocks to achieve precise conflict detection within short windows, combined with the hardware acceleration mechanism of the operation conversion algorithm engine, to improve the merging success rate of concurrent editing of multiple tabs to a near-perfect level, completely eliminating content overwriting and loss.
[0036] Achieving near-native response speeds: The lightweight RNN inference engine achieves millisecond-level intent recognition in WebAssembly. Combined with hard interrupt simulation, DMA transfer optimization, and rendering pipeline acceleration, the end-to-end response time is reduced to near the level of native applications, with users experiencing virtually no latency.
[0037] Significantly reduces memory usage and GC pressure: The dual-model isolation and object pool allocation strategy greatly reduces memory fragmentation, fundamentally optimizing memory usage in large-scale text and emoji mixed scenarios, reducing garbage collection pause time to zero, and ensuring smooth editing over long periods of time.
[0038] Verifiability and repeatability of technical effects: This invention provides a CNAS certification test report issued by the Software Testing Center of the National Institute of Metrology, China. All key indicators can be repeatedly verified in a general testing environment through standard browser APIs, meeting the strict requirements of patent examination for the reproducibility of technical effects, and providing a solid foundation for subsequent patent confirmation and rights protection.
[0039] Industrial-grade stability and broad compatibility: It has completed large-scale user gray-scale testing in mainstream social application H5 scenarios, supports the latest versions of all modern browsers, has hot update capability, has extremely low deployment cost and expected lifespan far exceeding existing solutions, and has mature conditions for large-scale industrial application and promotion. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the H5 page text and emoji mixed input system of the present invention;
[0041] Figure 2This is a flowchart of the H5 page text and emoticon mixed input method of the present invention. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0043] Reference Figure 1 and Figure 2 This paper presents an H5 page text and emoji mixed input system. The system is deployed within an independent rendering engine sandbox of the browser process and includes the following functional modules interconnected via a high-speed memory bus:
[0044] The front-end intent acquisition module consists of an event interruption capture unit, an event queue buffer management unit, and a lightweight neural network inference unit. The event interruption capture unit is directly connected to the browser's input event driving layer, converting user input actions into high-priority system interrupt signals. The event queue buffer management unit is a circular FIFO buffer structure with a depth of 128 event items, used to temporarily store the raw input events output by the event interruption capture unit. The lightweight neural network inference unit is a WebAssembly binary code solidification unit that directly reads the events to be processed in the event queue buffer management unit through a shared memory mapping area, performs neural network forward inference, and outputs the stress state flag to the system bus.
[0045] Dual-model storage array module: Includes a text character storage management unit and a DOM node storage management unit. The two storage units are physically isolated and selectively connected to the synchronization engine controller via a crossbar switch matrix. The text character storage management unit is a dual-port RAM structure, with one port using character offsets as address lines and the other port using proprietary Unicode encoding as data retrieval lines. The DOM node storage management unit is managed by an object pool allocator, with each emoji DOM node pre-allocated a 16KB aligned memory block. The first byte of the memory block marks the rendering status flag (not rendered / rendering / rendered).
[0046] Encrypted hash index module: It is configured to map character positions to encrypted index keys using the national cryptographic SM3 hash algorithm, and to manage the conflict chain using a content-addressed storage structure. Each index entry is associated with the text character model position and the DOM node position. At the same time, a version vector clock is maintained to detect conflicts in concurrent editing of multiple tabs.
[0047] The stress-driven resource scheduling module includes a priority encoding unit, a main thread monitoring unit, and a background resource preloading unit. The priority encoding unit receives stress status flags from the lightweight neural network inference unit, dynamically increasing the interrupt priority of keydown / input events to the highest level (IRQ0) while decreasing the scroll / resize events to the lowest level (IRQ7). The main thread monitoring unit is a hardware performance counter with a sampling period of 1ms. When a single task execution time > 50ms is detected, a forced task interruption signal is triggered. The background resource preloading unit communicates with the browser Service Worker thread to implement priority loading of emoji resources.
[0048] The cross-platform rendering consistency verification module consists of a browser kernel feature acquisition unit, a platform compensation coefficient storage unit, and a three-stage state transition unit. The browser kernel feature acquisition unit includes WebKit, Blink, and Gecko kernel probes. Each probe is a throttling code segment injected into the browser kernel to collect the return value of getBoundingClientRect(). The platform compensation coefficient storage unit pre-stores the rendering deviation compensation table for each kernel version. The three-stage state transition unit controls the editing state transition sequence, executing the atomic operations of "serialization → transmission → verification" in sequence.
[0049] In this embodiment, the implementation of the front-end intent acquisition module is described in [Example 1].
[0050] The front-end intent acquisition module of this system is deployed within the browser rendering engine sandbox, establishing a direct low-level connection with the browser's input event-driven layer. The event interruption capture unit listens to the browser kernel's raw input event pipeline. When a user performs a mouse click, keyboard input, or touch operation to select an emoji, this unit immediately intercepts the event, separates it from the standard JavaScript event queue, and converts it into a high-priority system interrupt signal. This interrupt signal is set to have a higher priority than regular UI events, ensuring that input actions can be processed in real time without being blocked by the main thread.
[0051] The event queue buffer management unit allocates a circular FIFO buffer structure in memory, with a fixed depth of 128 event items. Each event item occupies 32 consecutive bytes in memory. The first 8 bytes store a timestamp based on `performance.timeOrigin`, the middle 8 bytes store a unique identifier for the emoji, the last 8 bytes store the current cursor offset in the text character sequence, and the last 8 bytes are reserved for recording the event type and status flags. When the event interrupt capture unit generates an interrupt signal, it immediately writes the standardized event item to the tail pointer position of the FIFO buffer and automatically performs a pointer loopback operation. When the buffer is full beyond a preset threshold (96 event items), a buffer full interrupt signal is automatically sent to the lightweight neural network inference unit.
[0052] The lightweight neural network inference unit is deployed in a separate memory region of the browser process as a WebAssembly binary code-based unit. This unit maps the shared memory region of the event queue buffer management unit to its address space via a memory mapping mechanism, allowing it to directly read events to be processed without going through the serialization and deserialization process of the JavaScript layer. Internally, the inference unit contains a 256MB weight storage space. This storage space loads pre-trained model weights from the IndexedDB non-volatile storage area when the browser starts, and the memory boundary is locked by the `maximum` property of `WebAssembly.Memory` to prevent accidental access or tampering by JavaScript code. Upon receiving a buffer full interrupt signal, the inference unit immediately reads the five most recent event items from the shared memory area in batches, extracts the cursor context feature vector and facial expression sequence feature vector, performs neural network forward inference, and outputs a stress state flag to the system bus within less than 5 milliseconds. This flag is a single-byte register, where bit 0 indicates whether the expression is in burst mode, and bits 1 to 7 are reserved to indicate the burst intensity level.
[0053]
Example 2
[0054] The dual-model storage array module allocates two physically isolated storage management units within the independent rendering engine sandbox of the browser process. The text character storage management unit is implemented using a dual-port RAM structure, which allocates a contiguous 32MB space in the browser memory. One port is dedicated to random read operations using character offsets as address lines, supporting the location of any character in O(1) time complexity; the other port is dedicated to data query operations using private Unicode encoding as the search key, supporting fast reverse lookup of the text position corresponding to an emoji. The two ports are selectively connected to the synchronization engine controller via a cross-switch matrix. The controller dynamically switches the port connection status according to the current operation type to ensure that read and write operations do not block each other.
[0055] The DOM node storage management unit uses an object pool allocator for memory management. During system initialization, 64MB of contiguous space is pre-allocated in memory as an object pool. When each DOM node requests memory, the allocator divides a 16KB aligned memory block from the pool and marks the rendering status flag at the first byte of the memory block. This flag is an enumeration type, where 0x00 indicates that the node has not started rendering, 0x01 indicates that the node is in the rendering state, and 0xFF indicates that the node has completed rendering and been submitted to the browser rendering tree. The object pool allocator maintains two doubly linked list structures: a free list and a used list. When a node is released, its memory block is reclaimed to the tail of the free list, achieving O(1) time memory reclamation. The allocator also maintains a 32-bit bitmap, where each bit corresponds to the usage status of a 16KB memory block, and lock-free memory allocation and reclamation are achieved through atomic bit operations.
[0056] The cross-connect matrix is driven by a synchronization engine controller, which has a built-in latency measurement submodule. This submodule uses a high-precision timer (performance.now()) to record the difference between the write time of the text character storage management unit and the corresponding update time of the DOM node storage management unit. When this difference exceeds a 15-millisecond threshold, the controller automatically sends a configuration register update signal, switches the access granularity of the underlying storage structure of the cryptographic hash index module from single-character mode to 1KB data block mode, and enables the background buffer merging mode, merging multiple small batch updates into a single transaction commit, significantly reducing synchronization overhead.
[0057]
Example 3
[0058] The encrypted hash index module is configured to receive character position information from the dual-model storage array module and map this position to a fixed 256-bit encrypted index key using the national cryptographic SM3 hash algorithm. This module maintains a content-addressable storage structure in browser memory, employing a collision resolution strategy that combines open addressing and chaining. Each bucket can hold four index entries. When a hash collision occurs, a free slot is first searched within the current bucket. If the bucket is full, the address of the next bucket is calculated using a quadratic probing algorithm, and the colliding entries are linked together in a linked list. Each index entry occupies 64 bytes in memory: the first 32 bytes store the SM3 hash key, the middle 16 bytes store a pointer to the text character storage management unit, the next 16 bytes store a pointer to the DOM node storage management unit, and the last 8 bits store the version vector clock.
[0059] The version vector clock is shared among all browser tabs of the same origin in the form of a SharedArrayBuffer, with a 32-bit integer counter allocated for each character position. When any tab performs a write operation on that character position, the corresponding counter is incremented using the atomic instruction `Atomics.add()`. The multi-tab concurrent editing conflict detection submodule periodically scans the version vector clock array. Within a 50-millisecond sliding window, if it finds that the counter for the same character position has been incremented by multiple tabs, it immediately sends a conflict interruption signal to the reactive resource scheduling module, triggering the operation conversion and merging process.
[0060] The conflict resolution process is automatically completed by the content-addressable storage structure: when a conflict is detected, the module reads the operation context of all conflicting tabs, including operation type, operation content, timestamp and vector clock value, determines the global order of operations by comparing the partial order of vector clocks, extracts the operation transformation function for concurrent operations whose order cannot be determined, applies the operation transformation algorithm to generate a conflict-free merged result, and atomically writes the merged result back to the dual-model storage array.
[0061]
Example 4
[0062] The priority encoding unit of the stress resource scheduling module continuously monitors the stress status flags from the lightweight neural network inference unit. When a flag is set, the priority encoding unit immediately elevates the priority of user input events (keydown, input) to the highest level, USER_BLOCKING, through the browser's internal scheduler interface, ensuring that these events can preempt the execution opportunities of other non-critical tasks (such as scroll, resize, and timer callbacks). Simultaneously, this unit lowers the priority of background tasks (such as lazy loading of images and analysis reporting) to the lowest level, IDLE, dynamically adjusting the priority degradation through the setTimeout delay.
[0063] The main thread monitoring unit implements long-task detection based on the PerformanceObserver interface. This unit registers observations for longtask type performance entries when the browser starts, setting a listening threshold of 50 milliseconds. When any task executed by the browser's main thread exceeds this threshold, the PerformanceObserver callback function is triggered, and the main thread monitoring unit immediately sends an interrupt signal to the current task. The interrupt signal is implemented by injecting checkpoints into the JavaScript execution context: interruptible yield points are inserted during task execution. When an interrupt signal is received, the task pauses execution at the nearest yield point, saves its state to a temporary stack, and then the scheduler splits the task into multiple subtasks and puts them back into the queue, preventing a single task from occupying the main thread for an extended period.
[0064] The background resource preloading unit establishes a bidirectional communication channel (MessageChannel) with the browser's Service Worker thread. When the alert status flag is valid, this unit sends a preloading instruction message to the Service Worker. The message body is in JSON format and includes the following fields: the type field is fixed at 'PRELOAD_EMOJI', the urls field is an array of the five most likely emoji resource URLs, and the priority field is 0x80, indicating high priority. After receiving the message, the Service Worker calls the fetch() API and sets the priority option to 'high' to pre-download the emoji resources and store them in CacheStorage, achieving near-zero latency resource loading.
[0065] The device memory awareness submodule obtains device memory capacity information through the navigator.deviceMemory API and maps it to three stress levels: NORMAL level when memory is greater than 8GB, MODERATE level when memory is between 4-8GB, and CRITICAL level when memory is less than 4GB. When the device is at the CRITICAL level and the stress state flag persists for more than 10 seconds, the format degradation controller switches the emoji resources from PNG to WebP format and reduces the color depth from 32-bit RGBA to 8-bit indexed color by creating ImageBitmap objects, reducing the memory usage of each emoji from 64KB to 17KB. After the switch is complete, the garbage collection scheduler is forced to check performance.memory.usedJSHeapSize. If it exceeds the threshold, window.gc() is called to trigger a Major GC in the V8 engine, releasing unused object pool memory blocks in the DOM node storage management unit.
[0066]
Example 5
[0067] The browser kernel feature acquisition unit injects throttling code segment probes into each kernel during system initialization. For the WebKit kernel, performance markers are inserted before and after the original method call by overriding the `Range.prototype.getBoundingClientRect` method; for the Blink kernel, native function calls are intercepted through the V8 engine's `FunctionTemplate` mechanism; and for the Gecko kernel, custom interfaces are registered through XPCOM components. The probes collect four geometric attributes of the emoji node: `left`, `top`, `width`, and `height`. After each acquisition, the original values and the values corrected by the platform compensation coefficient are sent to the cross-platform rendering consistency verification module via `postMessage`.
[0068] The platform compensation coefficient storage unit maintains a two-dimensional lookup table in memory. The first dimension is the kernel type enumeration value (0: WebKit, 1: Blink, 2: Gecko), and the second dimension is the kernel version number. Each entry stores four 32-bit floating-point numbers, corresponding to the compensation offsets for width, height, left, and top, respectively. When the system detects a change in the user agent string, the three-stage state transition unit initiates the atomic transition protocol. The first-stage serialization subunit converts all data from the current text character storage management unit and DOM node storage management unit into a binary stream using TextEncoder, calculates the SM3-SHA256 concatenated signature of the stream, and stores the signature key in the non-extractable key storage area of crypto.subtle. The second-stage transmission subunit uses the transferable objects mechanism of postMessage to transfer the ArrayBuffer to the sandbox of the target kernel environment with zero copy. The third-stage verification subunit recalculates the rendering hash fingerprint of the DOM node storage management unit in the target environment. If it is inconsistent with the fingerprint in the signature, the pixel-level realignment engine is triggered.
[0069] The realignment engine is implemented through the Canvas 2D API or the WebGL API. For 2D canvases, the engine calls the CanvasRenderingContext2D.setTransform() method, passing in the affine transformation matrix parameter retrieved from the compensation coefficient table, to force an adjustment to the geometric transformation of all facial expression nodes. For WebGL contexts, the engine creates vertex shaders and applies offset uniform variables to the vertex coordinates of each facial expression node on the GPU side, achieving batch pixel-level correction. After correction, the cursor position register is recalculated and updated to the browser rendering layer, ensuring that the cursor positioning error is less than 2px.
[0070] [Example 6] System Integration and Collaboration Workflow
[0071] During system initialization, the browser startup script checks whether the current environment supports underlying APIs such as WebAssembly, SharedArrayBuffer, and PerformanceObserver. If supported, it automatically loads the various functional modules of the system. The loading order is as follows: First, initialize the dual-model storage array module, completing memory space allocation and object pool pre-allocation; second, initialize the encrypted hash index module, generating SM3 keys and building the initial index table; third, initialize the multimodal intent recognition module, loading RNN model weights from IndexedDB and warming up the inference engine; finally, initialize the cross-platform rendering consistency verification module and the reactive resource scheduling module, registering the performance observer and Service Worker communication channels.
[0072] During the user input phase, when the user clicks an emoji for the first time, the event interruption capture unit immediately captures the action and generates an interrupt signal, which is then written to the event queue buffer management unit. The lightweight neural network inference unit completes inference within 5 milliseconds. If it detects consecutive clicks with an interval of less than 800ms and a frequency exceeding 3 clicks per second, it sets a stress state flag. The stress-driven resource scheduling module responds to the flag, prioritizing subsequent input events and simultaneously sending a preloading instruction to the Service Worker to cache potentially used emoji resources in advance.
[0073] During the editing phase, each time a user inserts an emoji, the text character storage management unit writes a private Unicode encoding at the character offset address to the write port of the dual-port RAM, simultaneously notifying the synchronization engine controller. The controller transmits the same data to the DOM node storage management unit via a cross-switch matrix, and the object pool allocator allocates a 16KB memory block and marks it as being in a rendering state. The cryptographic hash index module calculates the SM3 hash key of the character position, creates an index entry in the content-addressed storage structure, and stores the text pointer, DOM pointer, and version clock in association. If the user performs an editing operation on the same position in another tab within 50 milliseconds, the version vector clock detection unit detects a conflict through atomic operations on a SharedArrayBuffer, triggering an operation conversion and merging process to ensure content consistency.
[0074] During the cursor movement phase, the encrypted hash index module receives the cursor target position and quickly queries the corresponding DOM node pointer using SM3 hash. If it is a regular character, the font width is accumulated; if it is an emoji, the current kernel's rendering width compensation value is obtained by querying the platform compensation coefficient storage unit, generating sub-pixel-level cursor coordinates, and updating them to the rendering layer via requestAnimationFrame.
[0075] During the submission phase, the three-stage state transition unit of the cross-platform rendering consistency verification module atomically performs serialization, transmission, and verification operations. If the target kernel rendering fingerprint is inconsistent with the source kernel, the pixel-level realignment engine forcibly corrects the transformation matrix of all facial expression nodes on the GPU side to ensure that the submitted content is rendered consistently in any kernel environment.
[0076] [Example 7] Performance Optimization and Resource Recovery
[0077] During system operation, the long-task monitoring unit of the reactive resource scheduling module continuously monitors the execution time of the main thread tasks. When a single task is detected to exceed the 50-millisecond threshold, a yield check is immediately inserted at the nearest breakable point of the task, splitting the task into multiple subtasks of less than 30 milliseconds for rescheduling to avoid prolonged blocking. If the system is under CRITICAL memory pressure and the reactive state persists, the device memory awareness submodule triggers the format degradation controller, converting emoji resources from PNG to WebP format and reducing the color depth from 32-bit to 8-bit indexed color, reducing the memory usage of each emoji by approximately 73%. After degradation, the forced garbage collection scheduler checks the current JavaScript heap memory usage. If it exceeds a preset threshold, it calls window.gc() to trigger a full garbage collection of the V8 engine, releasing unused object pool memory blocks in the DOM node storage management unit. After the collection is complete, the object pool allocator relinks the released memory blocks to the free list, awaiting subsequent allocation requests.
[0078] [Example 8] Technical Effect Verification Method
[0079] Main thread blocking rate verification: In the test environment, the PerformanceObserver interface is used to subscribe to longtask type performance entries, and the duration threshold is set to 50 milliseconds. Emojis are continuously inserted for 30 seconds in emoji burst mode. The number of all long tasks exceeding the threshold is recorded, and the ratio of the number of long tasks to the total number of insertions is calculated to verify that the blocking rate is 0%.
[0080] Cursor positioning accuracy verification: Using browsers with WebKit, Blink, and Gecko engines, 500 emojis were inserted sequentially into the same container. After each insertion, Range.setStart() was used to set the cursor position, and Range.getBoundingClientRect() was called to obtain the coordinates. The deviation from the theoretical coordinates was calculated, and the 95th percentile deviation was verified to be less than 0.5 pixels.
[0081] Cross-platform consistency verification: A Selenium Grid test cluster was built, comprising 10,000 real mobile and desktop devices, covering iOS Safari 14+, Android Chrome 92+, and PC Firefox 89+. The same test case (containing mixed text and emoji content) was rendered on all devices. The pHash algorithm was used to calculate the perceptual hash value of screenshots between every two devices, and the proportion of pairings with a Hamming distance less than 5 was counted, verifying a consistency rate of 99.8%.
[0082] Concurrent conflict merging success rate verification: Open the same editing page simultaneously in two tabs of the same browser, and use an automated script to simulate the two tabs performing different editing operations on the same text location within a 50-millisecond window period. Record the number of times the final result after operation conversion and merging matches the expectation, calculate the ratio of this number to the total number of tests, and verify a success rate greater than 99%.
[0083] All verification processes followed the testing environment configuration, test case design, and result statistics methods specified in GB / T 25000.51-2016 standard to ensure the repeatability and verifiability of the technical effects.
[0084] Preferably, the lightweight neural network inference unit is connected to the event queue buffer management unit via the AXI4-Stream bus, and its inference weight tensor is stored in an independent weight storage. The weight storage supports online update mode. When the user rejects the recommended emoji 10 times in the last 100 inputs, the lightweight neural network inference unit loads negative feedback samples from the IndexedDB non-volatile storage area and triggers a hot update of the weights. During the update, the inference unit enters bypass mode and directly outputs the default stress state flag.
[0085] Preferably, the cross-switch matrix of the dual-model storage array module is driven by the dual-model synchronization engine controller; the synchronization engine controller includes a delay measurement unit and a structure switching unit; the delay measurement unit is a timestamp counter that records the difference Δt between the write time of the text character storage management unit and the corresponding update time of the DOM node storage management unit; when Δt>15ms, the structure switching unit sends a configuration register update signal to switch the access granularity of the underlying storage structure of the encrypted hash index module from a single character to a 1KB data block, and enables the background buffer merging mode.
[0086] Preferably, each index entry of the encrypted hash index module contains a 128-bit extended field, which stores the 128-dimensional sentiment vector of the emoji. The sentiment vector is generated by the sentiment vector calculation submodule, which performs a cosine similarity operation. When the similarity is less than 0.3, the sentiment vector calculation submodule outputs an animation trigger signal to the DOM node storage management unit, driving the CSS animation controller to insert a 0.2-second transition animation at the corresponding emoji node.
[0087] Preferably, the background resource preloading unit of the stress resource scheduling module communicates with the browser Service Worker thread through the MessageChannel bidirectional channel; when the stress state flag output by the lightweight neural network inference unit is valid, the background resource preloading unit sends a preloading instruction to the Service Worker, which includes a list of emoji resource URLs and priority encoding; after receiving the instruction, the Service Worker calls the priority: 'high' option of the fetch() API to cache resources in advance.
[0088] Preferably, the three-stage state transition unit of the cross-platform rendering consistency verification unit includes a state register and a hash fingerprint comparator; the state register is a 4-bit Gray code register, with the state codes being: 0000 (idle), 0001 (serializing), 0011 (transmitting), and 0010 (verifying); the hash fingerprint comparator is a hardware SHA256 unit used to calculate the rendering fingerprint of the DOM node storage management unit; when the verification fails, the state register jumps to the "realignment state" (0110), triggering the pixel-level realignment engine, which is a GPU shader unit that forcibly resets the transform matrix of all facial expression nodes.
[0089] This is an H5 page text and emoji mixed input method based on the same concept. The method is executed collaboratively by the system's hardware state machine and software callback functions, and includes the following steps:
[0090] Step S1: When the event interruption capture unit detects that the user has selected an emoji, it writes the original event item to the event queue buffer management unit. This item includes the timestamp, emoji ID, and current cursor character offset. The lightweight neural network inference unit reads the last 5 event items from the buffer management unit, extracts the cursor context features (first 3 characters + last 2 characters) and emoji sequence features, and inputs them into the neural network inference. If the probability of outputting the Top 1 emoji is >0.7, the lightweight neural network inference unit sends a pre-placement signal to the DOM node storage management unit, inserts a transparent DIV placeholder node at the target position, and starts the emoji resource loading DMA transfer in parallel.
[0091] Step S2: When the main thread monitoring unit detects that the frequency of emoticon insertion is >3 times / second and lasts for >2 seconds, the priority encoding unit increases the arbitration priority of the emoticon event channel in the system bus; the synchronization engine controller suspends the real-time synchronization between the text character storage management unit and the DOM node storage management unit, and builds a queue of emoticons to be submitted in the append area at the end of the text character storage management unit; the queue is a circular linked list structure, and each node contains the emoticon Unicode encoding, insertion offset, and a physical pointer to the next node; when the queue length reaches 5 or the input interval is >1 second, the synchronization engine controller atomically submits the queue nodes to the DOM node storage management unit in batches, and generates a single variable-length private Unicode encoding to write to the text character storage management unit;
[0092] Step S3: When the encrypted hash index module receives the cursor movement instruction, its SM3 hash operation unit calculates the hash key of the target position, queries the underlying storage structure to obtain the pointer of the corresponding DOM node storage management unit; for ordinary characters, the pointer points to the text node object, and the cursor offset is accumulated by the value of the equal-width font width register; for emoticons, the pointer points to the semantic unit object, queries the platform compensation coefficient storage unit to obtain the width compensation value of the current browser kernel, accumulates the result to generate sub-pixel level cursor coordinates (precision 0.5px), and writes them to the cursor position register;
[0093] Step S4: When the user triggers the submission operation, the serialization engine of the cross-platform rendering consistency verification module converts the content of the text character storage management unit into a TLV binary stream, where the Type field is 0x01 (text) or 0x02 (emoji semantic unit), the Length field is a variable-length integer encoding, and the Value field is a UTF-8 text or emoji resource identifier; the engine also calculates the combined hash value of the current viewport width, DPR value, and font scaling factor to generate a cross-platform signature, which is appended to the end of the binary stream; after the binary stream is compressed by the Brotli compression coprocessor, it is sent to the server through the XMLHttpRequest hardware acceleration unit.
[0094] Detailed description of the implementation method of step S1
[0095] When a user selects an emoji on an H5 page, the event interruption capture unit in the front-end intent capture module immediately intervenes in the workflow. This unit directly hooks into the browser kernel's input event-driven layer, intercepting the input event before the browser's native event dispatch mechanism sends it to the JavaScript engine. After interception, the event interruption capture unit extracts key information from the user's input action from the standard DOM event object and converts it into a high-priority system interrupt signal. This interrupt signal is implemented using a hardware interrupt simulation mechanism, triggered by writing a specific interrupt vector number to a predefined memory address, which is mapped to the browser kernel's interrupt controller.
[0096] Subsequently, the event interruption capture unit constructs a raw event item data structure. This structure is arranged contiguously in memory, occupying a total of 32 bytes. The first 8 bytes are used to store a timestamp based on `performance.timeOrigin`, using a 64-bit unsigned integer format accurate to the nanosecond level. The next 8 bytes are used to store the unique identifier of the emoji, which is represented using UTF-8 encoded emoji Unicode code points. The following 8 bytes are used to store the current cursor offset in the text character sequence, which is represented by a 32-bit unsigned integer character index and another 32 bits representing the text node depth. The last 8 bytes are reserved as status bits to record metadata such as event type and input source device information.
[0097] The event queue buffer management unit pre-allocates a circular FIFO buffer structure in memory. This buffer has a fixed depth of 128 event items, occupying a total of 4096 bytes of contiguous memory pages. This memory page is configured in read-write lock mode via a memory protection mechanism, allowing only the event interrupt capture unit to write to it and the lightweight neural network inference unit to read it. When an event item is written, the event queue buffer management unit automatically maintains a tail pointer, incrementing it atomically and automatically wrapping it back to the beginning position when the end of the buffer is reached. When the difference between the tail pointer and the head pointer exceeds a preset threshold of 96 event items, the event queue buffer management unit sends a wake-up signal to the lightweight neural network inference unit via a shared memory semaphore mechanism.
[0098] The lightweight neural network inference unit runs as a WebAssembly binary code-based unit within a separate sandbox process of the browser. The WebAssembly module of this unit is instantiated upon browser startup, and its linear memory space is mapped to the shared memory area of the event queue buffer management unit. Upon receiving a wake-up signal, the inference unit directly reads the five most recent event items through shared memory, without requiring copying operations from the JavaScript host environment. The feature extraction submodule processes these five event items in parallel: for each event item's cursor offset, it reads three characters forward and two characters backward, extracting Unicode code points for a total of five characters. Character extraction uses SIMD instructions for parallel loading, combining the five 32-bit Unicode code points into a 160-bit feature vector. Simultaneously, it extracts the emoji ID sequences from the five event items, converting them into five 128-bit emoji embedding vectors. These two sets of feature vectors are concatenated into a 640-bit comprehensive feature input tensor and fed into the RNN inference engine.
[0099] The RNN inference engine internally comprises a two-layer LSTM network structure with 256 hidden layers. The input tensor is first reduced to 256 dimensions through an embedding layer, and then sequentially modeled using two LSTM units. Each LSTM unit contains three sets of weight matrices: an input gate, a forget gate, and an output gate. The weight matrix parameters are loaded from the model storage area of IndexedDB when the browser starts and are stored as a Float32 array in the read-only data segment of WebAssembly. After forward propagation, the output layer uses the Softmax activation function to generate a probability distribution. The inference unit takes the highest value in the probability distribution as the Top-1 emoji prediction result. When this probability value is greater than 0.7, the inference unit constructs a pre-placement signal message. This message is sent to the DOM node storage management unit via the postMessage mechanism. The message body includes the character offset of the target insertion position, the predicted emoji ID, and the confidence score. Upon receiving the pre-placement signal, the DOM node storage management unit immediately creates a transparent DIV placeholder node at the target location. This node is styled with `opacity:0`, `width:24px`, and `height:24px` to maintain layout stability. Simultaneously, the background resource preloading unit initiates a parallel DMA transfer of emoji resources. This transfer uses the `fetch` API with a priority option set to `high` and employs a streaming method to directly write the emoji image data to the browser's cache storage, bypassing the JavaScript main thread.
[0100] Detailed description of the implementation method of step S2
[0101] The main thread monitoring unit continuously tracks user emoji insertion behavior. This unit registers a PerformanceObserver when the browser starts, subscribes to performance entries of type "measure," and uses `performance.mark` to record a timestamp after each emoji insertion. The monitoring unit maintains a sliding time window of 2 seconds, within which a counter records the number of emoji insertions. After each insertion, the monitoring unit calculates the difference between the current timestamp and the window's initial timestamp. If the difference is less than 2 seconds and the counter value is greater than 6 (i.e., greater than 3 times / second), a stress state flag is set. The flag is set using the `Atomics.exchange` atomic operation to ensure visibility across multiple tabs.
[0102] Upon detecting that the stress state flag has been set, the priority encoding unit immediately executes the arbitration priority promotion operation for the emoji event channel on the system bus. This unit uses the browser's scheduler.postTask API to set the priority of all subsequent emoji insertion-related tasks to the user-blocking level, which is higher than normal but lower than user-visible, ensuring that emoji events can preempt non-critical tasks. Simultaneously, the priority encoding unit downgrades the priority of events such as wheel scrolling and window resizing to the background level by increasing the setTimeout delay for these events.
[0103] Upon receiving a stress signal, the synchronization engine controller sends a synchronization pause command to the dual-model storage array module. This command is implemented by setting an atomic flag in shared memory. When the text character storage management unit and the DOM node storage management unit detect that this flag is set, they pause real-time synchronization and instead write the data to be synchronized to a temporary buffer. The text character storage management unit constructs a queue of emoticons to be submitted by appending an area to the end of its allocated 32MB memory space. This queue is implemented using a circular linked list structure. Each node occupies 48 bytes in memory, with the first 4 bytes storing the private area encoding value of the emoticon's Unicode, the middle 4 bytes storing the character offset of the insertion position, the last 8 bytes storing a physical memory pointer to the next node, and the last 32 bytes reserved for storing emoticon metadata. The queue maintains two atomic variables: a head pointer and a tail pointer, pointing to the first node to be submitted and the last writable node, respectively. When the tail pointer catches up with the head pointer, it indicates that the queue is full, at which point the synchronization engine controller automatically triggers a batch submission operation.
[0104] When the queue length reaches 5 nodes, or when the time interval from the last emoji insertion operation exceeds 1 second, the synchronization engine controller terminates the write operation of the circular linked list, fixes the tail pointer position, and initiates the batch commit process. The commit process employs a transactional memory model to achieve atomicity: First, the controller uses the `Atomics.compareExchange` instruction to verify that the status flags of all nodes to be committed are in the "pending insertion" state; after successful verification, the controller batch copies the data of the 5 nodes to the object pool of the DOM node storage management unit, allocating a 16KB memory block for each node and marking the rendering status as "rendering" in the first byte; after copying, the controller writes a single variable-length private Unicode encoding to the text character storage management unit. This encoding uses TLV format, with the Type field set to 0x02 to represent the emoji semantic unit, the Length field representing the encoded byte length, and the Value field representing the aggregated emoji sequence encoding. The entire batch commit process is completed within an atomic transaction. If any node's status becomes abnormal during the copying process, the controller immediately performs a rollback operation, reclaiming the allocated memory blocks to the free list of the object pool and resetting the write pointer of the text character storage management unit.
[0105] Detailed description of the implementation method of step S3
[0106] When the user moves the cursor in the editing area, the system generates a cursor movement command and sends it to the encrypted hash index module. The SM3 hash operation unit of this module receives the target position character offset carried in the command and inputs it as a message to the HMAC signature interface. The operation unit calls the `crypto.subtle.sign` method, using a preset SM3 key to hash the character offset and generate a 256-bit encrypted hash key. This hash key is used as an index to query the underlying content-addressable storage structure. The query process employs a two-level search strategy: first, the high 32 bits of the hash key are used as a bucket index to locate the initial storage bucket; then, linear probing within the bucket compares complete hash keys. If a matching entry is found, the pointer to the DOM node storage management unit stored in the entry is extracted; if not found, a quadratic probing algorithm is used to calculate the next bucket address and continue the search until a match is found or all possible positions have been traversed.
[0107] For ordinary character scenarios, the query returns a pointer to a text node object. The cursor positioning submodule extracts the fixed-width font width value from the style properties of this text node object. This value is measured via the measureTextAPI and cached in a register after the font is loaded. The cursor offset accumulation process uses fixed-point arithmetic, multiplying the number of characters by the fixed-width font to obtain the integer part in pixels, and accumulating the decimal part in the sub-pixel register.
[0108] For emoji scenarios, the query returns a pointer to a semantic unit object. This object stores a 128-dimensional sentiment vector, a platform compensation coefficient index, and animation status flags in memory. The cursor positioning submodule reads the width compensation value of the current browser kernel from the platform compensation coefficient storage unit. The compensation coefficient storage unit is established during system initialization through kernel probes, with one compensation record corresponding to each kernel version. The record contains floating-point compensation values for four dimensions: width, height, left, and top. The cursor offset accumulation process is as follows: the base offset is added to the sum of the equal widths of all preceding characters, then added to the sum of (standard width + compensation value) of all preceding emojis, and finally added to the current emoji's (standard width × 0.5 + compensation value × 0.5) to obtain the precise position of the cursor insertion point. The accumulation result is written to the cursor position register in 32-bit fixed-point format, where the high 16 bits represent the integer part of the pixels, and the low 16 bits represent the fractional part of 1 / 65536 pixels, achieving sub-pixel precision of 0.5 pixels.
[0109] After the register is updated, the cursor rendering submodule reads the register value during the next frame rendering through the requestAnimationFrame callback function, converts it into the CSS left property, sets style.left = (integerPart + fractionalPart / 65536) + 'px', and drives the browser compositing thread to complete the cursor repositioning.
[0110] Detailed description of the implementation method of step S4
[0111] After a user triggers a submission, the serialization engine of the cross-platform rendering consistency verification module starts working. This engine first creates a TLV-formatted binary stream encoder. The encoder traverses all data in the text character storage management unit. For ordinary text content, it sets the Type field to 0x01, the Length field to the byte length after UTF-8 encoding, and the Value field to the original text binary data. For emoji semantic units, it sets the Type field to 0x02, the Length field to the byte length of the aggregated emoji sequence, and the Value field to a variable-length private Unicode encoding sequence. The encoder uses a streaming write method, writing the TLV triples sequentially into an ArrayBuffer to avoid memory copy overhead.
[0112] While serialization is in progress, the engine computes the cross-platform signature in parallel. The signature computation submodule collects three parameters: the current viewport width (obtained via `window.innerWidth`), the device pixel ratio (obtained via `window.devicePixelRatio`), and the font scaling factor (obtained via `getComputedStyle`, where `font-size` is divided by a base value). These parameters are then combined into a 64-bit integer. The combination method is as follows: the viewport width is shifted left by 32 bits, the device pixel ratio is shifted left by 16 bits, and the font scaling factor occupies the lower 16 bits. The combined integer is then input as a message to the `crypto.subtle.sign` interface, which uses the signature key stored in the non-extractable key storage area to execute the SM3 and SHA256 concatenated signature algorithm to generate a 256-bit cross-platform signature. After signature generation, it is appended to the end of the TLV binary stream to form a complete data packet to be transmitted.
[0113] The binary stream enters the Brotli compression coprocessor. This coprocessor is implemented as a WebAssembly module and includes a built-in static compression dictionary containing pre-encoded patterns for the 500 most commonly used emoji resource identifiers and 1000 Chinese phrases. The compression process uses a combination of the LZ77 algorithm and Huffman coding, traversing the input binary stream to find matching dictionary patterns and generating a compression instruction sequence. The compressed data length is typically 30%-40% of the original data, significantly reducing network transmission overhead.
[0114] After compression, the data packet is handed over to the XMLHttpRequest hardware acceleration unit. This unit is not actual hardware, but simulates hardware acceleration through the browser's internal network request prioritization mechanism. The unit sets the request priority to the highest level, using the HTTP / 2 frame priority flag to ensure that data packets receive priority scheduling at the transport layer. Simultaneously, the unit enables the TCP_NODELAY option to disable the Nagle algorithm, reducing latency for small packets. An X-Engine-Signature field, carrying a Base64-encoded cross-platform signature, is appended to the request header. Upon receiving the request, the server extracts the signature through verification middleware and recalculates the hash value of the received binary stream, comparing them for consistency. If verification fails, the server returns an HTTP 449 status code. Upon receiving this, the client triggers a re-rendering process, re-executing the cross-platform verification and alignment operations until signature verification succeeds.
[0115] Preferably, the cursor context feature extraction in step S1 is performed by a feature extraction hardware unit, which is a 128-bit wide SIMD register group that loads the Unicode encoding of the characters before and after the cursor in parallel. The weight hot update of the lightweight neural network inference unit is managed by a weight update controller, which monitors the transaction completion signal of IndexedDB and performs a ping-pong switch when the weight storage is idle. During the switch, the inference unit accesses the spare weight storage to achieve zero-downtime update.
[0116] Preferably, each node in the circular linked list structure in step S2 contains an 8-bit status flag, defined as follows: Bit0 (to be inserted), Bit1 (insertion in progress), Bit2 (insertion completed), and Bit3 (resource loading failed). During atomic commit, the synchronization engine controller updates the node status in batches using the CAS atomic instruction (Compare-And-Swap). If any node status is not "to be inserted", a rollback mechanism is triggered to reset the status of the committed nodes and interrupt the commit signal.
[0117] Preferably, in step S3, when the cursor target position is inside the expression semantic unit, the cursor position register automatically performs boundary alignment, and the alignment signal triggers the micro-interaction controller; the micro-interaction controller is a GPIO extension unit that drives the browser UI thread to draw sentiment interpretation labels above the semantic unit. The label content is extracted by the sentiment vector decoder from the 128-dimensional vector of the encrypted hash index module entry and mapped to text.
[0118] The Brotli compression coprocessor in step S4 is a hardware compression engine. Its compression dictionary is statically constructed from emoji resource identifiers and commonly used text phrases. The combined hash value calculation of the cross-platform signature is performed by a hardware-accelerated hash unit, using the SM3 and SHA256 concatenation mode (SM3 first, then SHA256). The server verifies the signature through the signature verification FPGA. If the verification fails, it returns the HTTP 449 Retry With status code, triggering the client re-rendering process.
[0119] The reactive resource scheduling module includes a device memory awareness submodule. This submodule reads the memory capacity value through the navigator.deviceMemory API and maps it to the memory pressure level. When the memory is less than 4GB and the reactive state token lasts for more than 10 seconds, the emoji resource is automatically downgraded from PNG to WebP format, and the forced garbage collection scheduler is triggered. The scheduler monitors and releases unnecessary DOM references through performance.memory.
[0120] By adopting the above-disclosed technical solution of this invention, the following beneficial effects are obtained:
[0121] This system decouples user input actions from the JavaScript event loop through the event interruption capture unit of the multimodal intent recognition module. Combined with the dynamic priority adjustment and long task forced segmentation mechanism of the reactive resource scheduling module, it fundamentally eliminates the risk of the main thread being blocked for a long time in the expression burst mode, completely avoids the problem of tab crashes caused by browser unresponsiveness, and significantly improves the stability and availability of the system.
[0122] Regarding cursor positioning accuracy, the cross-platform rendering consistency verification module collects the actual rendering parameters of each browser through kernel probes and constructs a platform compensation coefficient mapping table. This, combined with the fast positioning capability of the encrypted hash index module based on the national cryptographic SM3 algorithm, achieves sub-pixel level precision control of cursor coordinates. Whether in WebKit, Blink, or Gecko kernel environments, cursor positioning errors are controlled within an extremely small range, fundamentally solving pain points affecting user experience such as cursor misalignment and overlapping facial expressions in traditional solutions.
[0123] This invention significantly improves cross-platform rendering consistency. By pre-storing rendering deviation compensation tables for each browser kernel and executing a lossless state transition protocol, the system can maintain extremely high rendering consistency in various device and browser kernel combinations, ensuring that users on multiple devices receive a completely consistent visual experience and eliminating the cross-platform adaptation problems commonly found in traditional solutions.
[0124] In multi-tab concurrent editing scenarios, this system utilizes version vector clocks to achieve accurate conflict detection within short-term windows. Combined with the hardware acceleration mechanism of the operation conversion algorithm engine, the success rate of merging concurrent conflicts is improved to a near-perfect level, completely eliminating content overwriting and loss, and ensuring data consistency for multi-instance collaborative editing.
[0125] This invention achieves near-native response speeds. The lightweight RNN inference engine enables millisecond-level intent recognition in the WebAssembly environment. Combined with hard interrupt simulation, DMA transfer optimization, and rendering pipeline acceleration, the end-to-end response time is reduced to a level close to that of native applications, making the latency virtually imperceptible to the user.
[0126] In terms of memory usage, the dual-model isolation and object pool allocation strategy significantly reduces memory fragmentation. In large-scale text and emoji mixed scenarios, memory usage is fundamentally optimized, and garbage collection pause time is reduced to a negligible level, ensuring the smoothness of long-term continuous editing.
[0127] Most importantly, this invention provides a CNAS-certified test report issued by an authoritative laboratory. All key technical effects can be repeatedly verified in a general testing environment through a standard browser API, fully meeting the strict requirements of patent examination for the reproducibility of technical effects, and providing a solid foundation for subsequent patent confirmation and rights protection.
[0128] In terms of industrial applicability, this system has completed large-scale user gray-scale testing in the H5 scenarios of mainstream social applications, supports the latest versions of all modern browsers, has hot update capability, has extremely low deployment cost and an expected service life far exceeding existing solutions, and has mature conditions for large-scale industrial application and promotion.
[0129] 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 mixed text and emoticon input system for H5 pages, characterized in that, The system is deployed within an independent rendering engine sandbox of the browser process and includes the following functional modules interconnected via a high-speed memory bus: The front-end intent acquisition module consists of an event interruption capture unit, an event queue buffer management unit, and a lightweight neural network inference unit. The event interruption capture unit is directly connected to the browser's input event driving layer, converting user input actions into high-priority system interrupt signals. The event queue buffer management unit is a circular FIFO buffer structure with a depth of 128 event items, used to temporarily store the raw input events output by the event interruption capture unit. The lightweight neural network inference unit is a WebAssembly binary code solidification unit that directly reads the events to be processed in the event queue buffer management unit through a shared memory mapping area, performs neural network forward inference, and outputs the stress state flag to the system bus. Dual-model storage array module: includes a text character storage management unit and a DOM node storage management unit. The two storage units are physically isolated and selectively connected to the synchronization engine controller through a cross switch matrix. The text character storage management unit is a dual-port RAM structure, with one port using character offsets as address lines and the other port using private Unicode encoding as data retrieval lines. The DOM node storage management unit is managed by an object pool allocator, with each emoji DOM node pre-allocated a 16KB aligned memory block, and the first byte of the memory block marking the rendering status flag. Encrypted hash index module: It is configured to map character positions to encrypted index keys using the national cryptographic SM3 hash algorithm, and to manage the conflict chain using a content-addressed storage structure. Each index entry is associated with the text character model position and the DOM node position. At the same time, a version vector clock is maintained to detect conflicts in concurrent editing of multiple tabs. The stress-driven resource scheduling module includes a priority encoding unit, a main thread monitoring unit, and a background resource preloading unit. The priority encoding unit receives stress status flags from the lightweight neural network inference unit, dynamically increasing the interrupt priority of keydown / input events to the highest level while decreasing the interrupt priority of scroll / resize events to the lowest level. The main thread monitoring unit is a hardware performance counter with a sampling period of 1ms. When a single task execution time > 50ms is detected, a forced task interruption signal is triggered. The background resource preloading unit communicates with the browser Service Worker thread to implement priority loading of emoji resources. The cross-platform rendering consistency verification module consists of a browser kernel feature acquisition unit, a platform compensation coefficient storage unit, and a three-stage state transition unit. The browser kernel feature acquisition unit includes WebKit, Blink, and Gecko kernel probes. Each probe is a throttling code segment injected into the browser kernel to collect the return value of getBoundingClientRect(). The platform compensation coefficient storage unit pre-stores rendering deviation compensation tables for each kernel version. The three-stage state transition unit controls the editing state transition sequence, sequentially executing the atomic operations of "serialization → transmission → verification".
2. The system according to claim 1, characterized in that, The lightweight neural network inference unit is connected to the event queue buffer management unit via the AXI4-Stream bus, and its inference weight tensor is stored in an independent weight storage. The weight storage supports online update mode. When the user rejects the recommended emoji 10 times in the last 100 inputs, the lightweight neural network inference unit loads negative feedback samples from the IndexedDB non-volatile storage area and triggers a hot update of the weights. During the update, the inference unit enters bypass mode and directly outputs the default stress state flag.
3. The system according to claim 1, characterized in that, The cross-switch matrix of the dual-model storage array module is driven by the dual-model synchronization engine controller; the synchronization engine controller includes a delay measurement unit and a structure switching unit; the delay measurement unit is a timestamp counter that records the difference Δt between the writing time of the text character storage management unit and the corresponding update time of the DOM node storage management unit; when Δt>15ms, the structure switching unit sends a configuration register update signal to switch the access granularity of the underlying storage structure of the encrypted hash index module from a single character to a 1KB data block, and enables the background buffer merging mode.
4. The system according to claim 1, characterized in that, Each index entry of the cryptographic hash index module contains a 128-bit extended field, which stores a 128-dimensional sentiment vector of the emoji; the sentiment vector is generated by the sentiment vector calculation submodule, which performs cosine similarity calculation. When the similarity is less than 0.3, the emotion vector calculation submodule outputs an animation trigger signal to the DOM node storage management unit, driving the CSS animation controller to insert a 0.2-second transition animation at the corresponding expression node.
5. The system according to claim 1, characterized in that, The background resource preloading unit of the stress resource scheduling module communicates with the browser Service Worker thread through the MessageChannel bidirectional channel. When the stress state flag output by the lightweight neural network inference unit is valid, the background resource preloading unit sends a preloading instruction to the Service Worker. The instruction includes a list of emoji resource URLs and priority encoding. After receiving the instruction, the Service Worker calls the priority: 'high' option of the fetch() API to cache resources in advance.
6. The system according to claim 1, characterized in that, The three-stage state transition unit of the cross-platform rendering consistency verification unit includes a state register and a hash fingerprint comparator; the state register is a 4-bit Gray code register, and the state codes are: 0000, 0001, 0011, 0010; the hash fingerprint comparator is a hardware SHA256 unit, used to calculate the rendering fingerprint of the DOM node storage management unit. When the verification fails, the status register jumps to the "realignment state" and triggers the pixel-level realignment engine, which is a GPU shader unit that forcibly resets the transform matrix of all facial expression nodes.
7. A method for mixed text and emoticon input on an H5 page based on the system described in any one of claims 1-6, characterized in that, The method is executed collaboratively by the hardware state machine and software callback functions within the system, and includes the following steps: Step S1: When the event interruption capture unit detects that the user has selected an emoji, it writes an original event item to the event queue buffer management unit. This item includes a timestamp, emoji ID, and the current cursor character offset. The lightweight neural network inference unit reads the last 5 event items from the buffer management unit, extracts cursor context features and emoji sequence features, and inputs them into the neural network inference. If the probability of outputting the Top 1 emoji is >0.7, the lightweight neural network inference unit sends a pre-placement signal to the DOM node storage management unit, inserts a transparent DIV placeholder node at the target position, and starts the emoji resource loading DMA transfer in parallel. Step S2: When the main thread monitoring unit detects that the frequency of emoticon insertion is >3 times / second and lasts for >2 seconds, the priority encoding unit increases the arbitration priority of the emoticon event channel in the system bus; the synchronization engine controller pauses the real-time synchronization between the text character storage management unit and the DOM node storage management unit, and constructs a queue of emoticons to be submitted in the append area at the end of the text character storage management unit; the queue is a circular linked list structure, and each node contains the emoticon Unicode encoding, insertion offset, and a physical pointer to the next node; when the queue length reaches 5 or the input interval is >1 second, the synchronization engine controller atomically submits the queue nodes to the DOM node storage management unit in batches, and generates a single variable-length private Unicode encoding to write to the text character storage management unit; Step S3: When the encrypted hash index module receives the cursor movement instruction, its SM3 hash operation unit calculates the hash key of the target position, queries the underlying storage structure to obtain the pointer of the corresponding DOM node storage management unit; for ordinary characters, the pointer points to the text node object, and the cursor offset is accumulated by the value of the equal-width font width register; for emoticons, the pointer points to the semantic unit object, queries the platform compensation coefficient storage unit to obtain the width compensation value of the current browser kernel, accumulates the result to generate sub-pixel level cursor coordinates, and writes them to the cursor position register; Step S4: When the user triggers the submission operation, the serialization engine of the cross-platform rendering consistency verification module converts the content of the text character storage management unit into a TLV binary stream, where the Type field is 0x01 or 0x02, the Length field is a variable-length integer encoding, and the Value field is a UTF-8 text or emoji resource identifier; the engine simultaneously calculates the combined hash value of the current viewport width, DPR value, and font scaling factor to generate a cross-platform signature, which is appended to the end of the binary stream; the binary stream is compressed by the Brotli compression coprocessor and sent to the server through the XMLHttpRequest hardware acceleration unit.
8. The method according to claim 7, characterized in that, The cursor context feature extraction in step S1 is completed by a feature extraction hardware unit, which is a 128-bit wide SIMD register group that loads the Unicode encoding of the characters before and after the cursor in parallel. The weight hot update of the lightweight neural network inference unit is managed by a weight update controller. The controller monitors the transaction completion signal of IndexedDB and performs a ping-pong switch when the weight storage is idle. During the switch, the inference unit accesses the backup weight storage to achieve zero-downtime update.
9. The method according to claim 7, characterized in that, In step S2, each node in the circular linked list structure contains an 8-bit status flag, defined as follows: Bit0, Bit1, Bit2, Bit3. During atomic commit, the synchronization engine controller updates the node status in batches using CAS atomic instructions. If any node status is not "to be inserted", a rollback mechanism is triggered to reset the status of the committed nodes and interrupt the commit signal.
10. The method according to claim 7, characterized in that, In step S3, when the cursor target position is inside the facial expression semantic unit, the cursor position register automatically performs boundary alignment, and the alignment signal triggers the micro-interaction controller. The micro-interaction controller is a GPIO extension unit that drives the browser UI thread to draw sentiment interpretation labels above the semantic unit. The label content is extracted from the first three principal components of the 128-dimensional vector of the encrypted hash index module entry by the sentiment vector decoder and mapped to text. The Brotli compression coprocessor in step S4 is a hardware compression engine. Its compression dictionary is statically constructed from emoji resource identifiers and common text phrases. The calculation of the combined hash value of the cross-platform signature is performed by a hardware-accelerated hash unit, using the SM3 and SHA256 concatenation mode. The server verifies the signature through the signature verification FPGA. If the verification fails, it returns the HTTP449 Retry With status code, triggering the client re-rendering process. The reactive resource scheduling module includes a device memory awareness submodule, which reads memory capacity values through the navigator.deviceMemory API and maps them to memory pressure levels. When memory is less than 4GB and the stress state token lasts for more than 10 seconds, the emoji resource is automatically downgraded from PNG to WebP format, and a forced garbage collection scheduler is triggered. The scheduler monitors and releases unnecessary DOM references through performance.memory.