Hybrid mode mobile application debugging method and system

Through the hybrid mode mobile application debugging system, using desktop client, node server and emulator, the combination of WKWebview kernel and Safari developer tools is realized, solving the problem of low remote debugging of Hybrid pages in the existing technology and improving debugging efficiency And maintain the effect of real machine debugging.

CN113641582BActive Publication Date: 2024-11-12SHANGHAI BILIBILI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110920816.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-11
Publication Date
2024-11-12
Estimated Expiration
2041-08-11

AI Technical Summary

Technical Problem

The existing iOS App Hybrid page remote debugging methods are inefficient and lack automated processes, resulting in low debugging efficiency.

Method used

Provides a hybrid mode mobile application debugging system, including debugging equipment, node server and emulator, upload page code to node server through desktop client, deploy to static resource services, and install applications in the emulator, using the WKWebview kernel and Safari Developer tools implement complete remote debugging functions.

Benefits of technology

Through automation engineering, a relatively complete Hybrid page remote debugging function is realized, which improves debugging efficiency and makes the debugging effect consistent with the real Hybrid page debugging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113641582B_ABST
    Figure CN113641582B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a hybrid mode mobile application debugging system, including: a desktop client, used to upload the page code of the hybrid mode mobile application to the node server; the node server, used to deploy the received page code to the static resource service, and return the network address of the static resource service to the desktop client; the desktop client is also used to start the simulator, and after the simulator is started, install the hybrid mode mobile application in the simulator; the desktop client is also used to open the network address in the simulator, so that when the hybrid mode mobile application detects that the simulator opens the network address, it calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged; the desktop client is also used to open the debugging tool in the browser; the debugging tool is used to establish a connection channel with the WKWebview kernel, and debug the page to be debugged through the connection channel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a hybrid mode mobile application debugging method and system. Background Art

[0002] Hybrid applications have emerged due to the update of computer application technology and the needs of the market. Hybrid applications are hybrid mobile applications between native applications (Native App) and network applications (Web App). After the Hybrid application is developed, in order to discover the problems in the development process, the Hybrid application needs to be remotely debugged. However, the inventor found that when the current iOS App Hybrid page is remotely debugged, it is necessary to use the Charles real machine agent to let Webview load local resources, use the Safari WebInspector tool to debug the Hybrid page on a limited test real machine, and use the Weinre tool to inject the client into the Hybrid page to implement an incomplete remote debugging function. Although these methods can meet certain conditions or even strict conditions for Hybrid remote debugging, due to the separation of the devices during the debugging process and the need for users to combine and use them by themselves, there is a lack of effective automation processes, resulting in low debugging efficiency. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a hybrid mode mobile application debugging system to solve the problem of low efficiency of existing debugging methods.

[0004] One aspect of an embodiment of the present application provides a hybrid mode mobile application debugging system, the debugging system comprising a debugging device, a node server and a simulator, wherein a browser and a desktop client are installed in the debugging device, wherein:

[0005] The desktop client is used to upload the page code of the hybrid mode mobile application to be debugged to the node server;

[0006] The node server is used to deploy the received page code to the static resource service, and return the network address of the static resource service to the desktop client;

[0007] The desktop client is further used to start the simulator and install the hybrid mode mobile application in the simulator after the simulator is started;

[0008] The desktop client is further used to open the network address in the simulator, so that when the hybrid mode mobile application detects that the simulator opens the network address, it calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged;

[0009] The desktop client is also used to open the debugging tool in the browser;

[0010] The debugging tool is used to establish a connection channel with the WKWebview kernel and debug the page to be debugged through the connection channel.

[0011] Optionally, the desktop client is an Electron desktop client, the simulator is an iOS simulator, the browser is a Safari browser, and the debugging tool is a Safari developer tool integrated in the Safari browser, wherein:

[0012] The Electron desktop client is used to create AppleScript automation services and iOS simulator automation services;

[0013] The Electron desktop client is further used to open the iOS simulator through the iOS simulator automation service, and after the iOS simulator is opened, install the hybrid mode mobile application through the iOS simulator automation service, and after the hybrid mode mobile application is installed, open the network address in the iOS simulator through the iOS simulator automation service;

[0014] The Electron desktop client is further used to open the Safari developer tool from the Safari browser via the AppleScript automation service;

[0015] The Safari developer tool is used to establish a connection channel with the WKWebview kernel through the Safari debugging protocol, and debug the Hybrid page to be debugged through the connection channel.

[0016] Optionally, the Electron desktop client is further used to request the node server to obtain session credential information;

[0017] The node server is used to generate session credential information when receiving a session credential information acquisition request sent by the Electron desktop client, and send the session credential information to the Electron desktop client, so that the Electron desktop client establishes a connection with the node server according to the session credential information.

[0018] Optionally, the node server is further configured to create a directory named after the session credential information is generated in the static resource service.

[0019] Optionally, the Electron desktop client is further used to package the page code and upload the packaged file package to the node server;

[0020] The node server is further used to decompress the file package and deploy the page code obtained after decompression to a directory named after the session credential information in the static resource service.

[0021] Optionally, the Electron desktop client is also used to simulate a click on the Safari developer tool in the Safari browser through the AppleScript automation service to open the Safari developer tool.

[0022] Optionally, the Electron desktop client is also used to close all currently opened iOS simulators through the iOS simulator automation service, and reopen the selected iOS simulator after all iOS simulators are closed.

[0023] Optionally, the Electron desktop client is also used to install a test environment certificate through the iOS simulator automation service.

[0024] Optionally, the Electron desktop client is also used to open the network address in the iOS simulator through the iOS simulator automation service, and then open the hybrid mode mobile application through the URL Schema, so that the hybrid mode mobile application calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged.

[0025] The present application also provides a hybrid mode mobile application debugging method, which is applied to a debugging system including a debugging device, a node server and a simulator, wherein a browser and a desktop client are installed in the debugging device, and the method includes:

[0026] Uploading the page code of the hybrid mode mobile application to be debugged to the node server through the desktop client;

[0027] Deploy the received page code to the static resource service through the node server, and return the network address of the static resource service to the desktop client;

[0028] Opening the simulator through the desktop client, and after the simulator is opened, installing the hybrid mode mobile application in the simulator;

[0029] The network address is opened in the simulator through the desktop client, so that when the hybrid mode mobile application detects that the simulator opens the network address, it calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged;

[0030] Open the debugging tool in the browser through the desktop client;

[0031] A connection channel is established between the debugging tool and the WKWebview kernel, and the page to be debugged is debugged through the connection channel.

[0032] The hybrid mode mobile application debugging system provided in the embodiment of the present application, by relying on a series of system underlying tool chains, overcomes Apple's restrictions on real machine debugging, and implements a relatively complete Hybrid page remote debugging function through automated engineering, thereby improving debugging efficiency, and the effect is consistent with real machine Hybrid page debugging. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 A schematic diagram of an application environment of a hybrid mode mobile application debugging system is shown schematically;

[0034] Figure 2 A block diagram schematically shows a hybrid mode mobile application debugging system according to an embodiment of the present application;

[0035] Figure 3 The flowchart of the hybrid mode mobile application debugging method according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0036] The advantages of the present application are further described below in conjunction with the accompanying drawings and specific embodiments.

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

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

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

[0040] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.

[0041] Figure 1 The schematic diagram of the application environment of the hybrid mode mobile application debugging system according to the embodiment of the present application is schematically shown. In an exemplary embodiment, the system of the application environment may include a terminal device 10, a device 20 installed with a hybrid mode mobile application to be debugged, and a server 30. Among them, a wireless or wired connection is formed between the terminal device 10, the device 20 installed with the hybrid mode mobile application to be debugged, and the server 30. The terminal device 10 can be a tablet computer, a computer, etc., which is not specifically limited here. The device 20 installed with the hybrid mode mobile application to be debugged can be an Android phone, an Android tablet, or an iOS simulator, etc. The server 30 can be a server cluster or a cloud computing center composed of one server or multiple servers. The server 30 is used to store the page code of the hybrid mode mobile application to be debugged.

[0042] See also Figure 2 , which is a block diagram of a hybrid mode mobile application debugging system according to an embodiment of the present application. As can be seen from the figure, the hybrid mode mobile application debugging system provided in this embodiment includes a debugging device 200, a device to be debugged 201 and a node server 202, wherein the debugging device 200 is installed with a browser and a desktop client, wherein:

[0043] In an exemplary embodiment, the device to be debugged 201 is an iOS simulator, and a browser is installed in the debugging device 200, and the browser is a debugging tool for debugging the device to be debugged 201. The debugging tool is preferably a Safari developer tool integrated in the Safari browser, and the desktop client is preferably an Electron desktop client, wherein:

[0044] The Electron desktop client is also used to upload the page code of the mixed mode mobile application to be debugged to the node server 202.

[0045] Among them, the Electron desktop client is a desktop client for MacOS and Windows based on the Electron open source framework. It can realize the debugging coupling middle layer between PC (computer), node server 202, real machine (Android phone) or simulator (iOS simulator). It is the UI access layer for desktop client users, which aggregates multiple functions such as PC underlying system, WebSocket communication, Chromium kernel control, etc. Specifically, the Electron desktop client can realize AppleScript automation service and node-simctl iOS simulator automation service, and realize the automation process of all relevant links of page HMR (hotmodule replacement, module hot replacement), including injection configuration, bridging middle layer, etc.

[0046] Before uploading the page code to the node server, the page code may be packaged to generate a tar package.

[0047] In one embodiment, in order to prevent all clients from uploading files to the node server, the Electron desktop client is also used to request the node server 202 to obtain session credential information; the node server 202 is used to generate session credential information when receiving the session credential information acquisition request sent by the Electron desktop client, and send the session credential information to the Electron desktop client 200, so that the Electron desktop client establishes a connection with the node server 202 based on the session credential information.

[0048] In this embodiment, session credential information is generated for the Electron desktop client so that only the Electron desktop client with the session credential information can establish a connection with the node server 202 and upload the page code to the node server 202.

[0049] In one embodiment, in order to distinguish different page codes, the node server 202 is further used to create a directory named after the session credential information in the static resource service after generating the session credential information. In this way, after receiving the page code uploaded by the device, the node server 202 can deploy the received page code to the directory named after the session credential information corresponding to the device.

[0050] In an exemplary embodiment, when the received page code is a packaged file, the node server will also decompress the file package and deploy the decompressed page code to a directory named after the session credential information in the static resource service.

[0051] The node server 202 is used to deploy the received page code to the static resource service and return the network address of the static resource service to the Electron desktop client.

[0052] Specifically, after the page code is deployed to the static resource service, in order to enable the subsequent loading of the page code, the network address of the static resource service needs to be returned to the Electron desktop client.

[0053] The Electron desktop client is also used to open the simulator and install the hybrid mode mobile application in the simulator after the simulator is opened.

[0054] In order to debug the device 201 to be debugged more intelligently, the Electron desktop client is also used to create AppleScript automation services and iOS simulator automation services.

[0055] Specifically, AppleScript is a scripting language created by Apple for MacOS 7.1 and later. It allows users to directly control scriptable MacOS applications and some built-in functions and applications of MacOS itself. It can help users use AppleScript scripts in MacOS to control applications such as System Events, Safari browser, iOS Simulator, etc. The AppleScript automation service written in AppleScript can be used to open the Safari developer tools of the Safari browser.

[0056] The iOS simulator automation service uses the node-simctl library to execute the xcrun simctl command to control the iOS simulator, including starting and shutting down the simulator, installing apps, opening URLs, and other services.

[0057] Among them, xcrun is a command line tool provided by the Xcode application under MacOS, which is used to control Xcode development-related functions.

[0058] simctl is a subcommand of the xcrun tool, which is used to control the simulator and provides functions such as starting and shutting down the simulator, installing applications, and opening URLs.

[0059] node-simctl is a Node version of the simctl tool provided by Appium. It is used to control the iOS Simulator simulator in the Node program.

[0060] The Electron desktop client is also used to open the iOS simulator through the iOS simulator automation service, and after the iOS simulator is opened, install the hybrid mode mobile application through the iOS simulator automation service, and after the hybrid mode mobile application is installed, open the network address in the iOS simulator through the iOS simulator automation service, so that the hybrid mode mobile application calls the WKWebview kernel to load the page to be debugged.

[0061] Specifically, the iOS simulator is a software used to simulate a real iOS device. In this embodiment, in order to save time required during the debugging process, the iOS simulator is automatically started through the iOS simulator automation service, and after the iOS simulator is started, the hybrid mode mobile application is installed through the iOS simulator automation service, and after the hybrid mode mobile application is installed, the network address is opened in the iOS simulator through the iOS simulator automation service, thereby fully automating the installation of the hybrid mode mobile application in the iOS simulator and opening the page to be debugged through the hybrid mode mobile application.

[0062] The WKWebView kernel is the core part of the modern WebKit API in iOS 8 and OS X Yosemite applications. It replaces UIWebView in UIKit and WebView in AppKit, providing a unified cross-platform API (iOS and OS).

[0063] In an exemplary implementation, in order to avoid having multiple iOS simulators opened at the same time, in this embodiment, when opening the iOS simulator through the iOS simulator automation service, the Electron desktop client can first close all currently opened iOS simulators through the iOS simulator automation service, and after all iOS simulators are closed, reopen the default or user-selected iOS simulator. Afterwards, the hybrid mode mobile application can be installed through the iOS simulator automation service.

[0064] In an exemplary embodiment, after completing the installation of the hybrid mode mobile application, the Electron desktop client can also install the test environment certificate (e.g., SSL certificate) through the iOS simulator automation service so that the hybrid mode mobile application can access the HTTPS service of the test environment.

[0065] In an exemplary embodiment, after the Electron desktop client opens the network address in the iOS simulator through the iOS simulator automation service, the hybrid mode mobile application can be opened through the URL Schema, so that the hybrid mode mobile application can call the WKWebview kernel to load the page to be debugged.

[0066] Among them, URL Schema is supported by most current apps. It has the function of waking up the app and opening the corresponding page when the URL is opened in the browser of a real machine.

[0067] Since iOS 8, WKWebview has gradually replaced UIWebview and become the main Webview used by iOS App. WKWebview is based on the Webkit kernel.

[0068] In an exemplary embodiment, the hybrid mode mobile application calls the WKWebview kernel to load the page to be debugged, including: the hybrid mode mobile application calls the WKWebview kernel to start the WKWebview kernel debugging service, and calls the WKWebview kernel to render the page to be debugged using the Webkit engine.

[0069] Specifically, the WKWebview kernel debugging service is the Webview debugging service enabled locally by the WKWebview kernel, similar to the Chromium kernel debugging service of Android. However, due to the limitations of iOS, third-party applications cannot control the rendering and internal debugging of WKWebview under normal circumstances, nor can they access the WKWebview kernel debugging service. Only the Safari developer tool can communicate with and debug the service, and the debugging protocol is based on the Webkit-like kernel debugging protocol. After enabling the kernel debugging service, the WKWebview kernel will use the Webkit engine to render the page to be debugged.

[0070] The Electron desktop client is also used to open Safari developer tools from the Safari browser via AppleScript automation services.

[0071] Specifically, the Electron desktop client can simulate clicking the Safari developer tool in the Safari browser through the AppleScript automation service to open the Safari developer tool.

[0072] Among them, the Safari developer tool is a tool provided by the Safari browser for debugging iOS real devices or simulators. It is similar to the Chrome Devtools tool and can perform debugging functions such as element review, Console printing, and management of Network requests.

[0073] The Safari developer tool is used to establish a connection channel with the WKWebview kernel through the Safari debugging protocol, and debug the page to be debugged through the connection channel.

[0074] Specifically, after establishing a connection channel, the Safari developer tool and the WKWebview kernel debugging service of the iOS simulator can communicate based on a Webkit-like debugging protocol, exchange page debugging data, and perform fully functional page debugging.

[0075] The desktop client is used to upload the page code of the hybrid mode mobile application to be debugged to the node server 202.

[0076] Specifically, the debugging device 200 refers to a device in the hybrid mode mobile application debugging system for debugging the debugging device 200. In this embodiment, before debugging the hybrid mode mobile application (Hybrid application), it is necessary to upload the page code of the hybrid mode mobile application to the node server 202 through the desktop client in the debugging device 200.

[0077] In an exemplary implementation, the debugging device 200 further includes a local project debugging service and a desktop debugging window installed in the debugging device 200 .

[0078] After the Electron desktop client 200 is started, it will create a WebSocket client and a WebSocket server locally on the PC.

[0079] The WebSocket client will actively initiate a connection request to the node server 202 to establish a first WebSocket persistent connection between the two, and the data obtained from the node server 202 can be forwarded to the WebSocket client through the first WebSocket persistent connection. The WebSocket client will also forward the data obtained from the WebSocket server (the data is obtained through the internal data channel between the WebSocket server and the WebSocket client) to the node server 202 through the first WebSocket persistent connection.

[0080] The WebSocket server serves as a data transfer station for debugging data of the page to be debugged, HMR hot update data of the page to be debugged, and data related to Service Worker hijacking request forwarding. The WebSocket server can be connected to a debugging tool (e.g., Chrome Devtools Frontend debugging tool) to realize communication between the node server 202 and the Chrome Devtools Frontend debugging tool, Webpack service, Hybrid application (mixed mode mobile application), the page to be debugged, and Service Worker.

[0081] In this embodiment, after starting the Electron desktop client, it will also create a first module hot replacement client locally on the PC.

[0082] Specifically, the first module hot replacement client is a local WebSocket client created by the Electron desktop client, which is used to communicate with the module hot replacement server to realize the exchange of HMR hot update JSON data.

[0083] In this embodiment, in order to process the page code in time through the local project debugging service, after starting the Electron desktop client, it will also create a local project packaging service locally on the PC to start the local project debugging service through the local project packaging service.

[0084] Specifically, the local project packaging service is a Webpack development server created by a child process of the Electron client, which is used to execute and enable the local project debugging service and process the page code with the local project debugging service.

[0085] In this embodiment, the Electron desktop client is also used to add a first script for creating a second module hot replacement client and a second script for creating a module hot replacement server in the page code through the local project packaging service.

[0086] Specifically, the module hot replacement server is a WebSocket server created locally by Webpack when Webpack turns on DevServer mode, for the first module hot replacement client to connect to and provide HMR hot update JSON data.

[0087] Among them, the first script is a JavaScript script, which is used to replace the built-in module hot replacement client of Webpack. By adding the first script to the page code, a WebSocket long connection will be established with the built-in module hot replacement server of Webpack when the page code is loaded, which is used to exchange the JSON data of HMR hot update. In this embodiment, the second module hot replacement client created by the first script can change the default WebSocket long connection target address of the HMR hot update of the page to be debugged to the node server 202 address, which is used to forward the JSON data of HMR hot update to the node server 202.

[0088] Among them, Webpack is a module packager whose main purpose is to package JavaScript code files that run on browsers.

[0089] It should be noted that HMR hot update, that is, hot module replacement, is a function that replaces, adds or deletes modules during the running of the application without reloading the entire page. It has the following characteristics:

[0090] 1. Preserve the page status (page status includes form, routing, etc.).

[0091] 2. Only update the changed content, and pack, load and render pages faster to save valuable development time.

[0092] 3. When CSS / JS is modified in the source code, it will be updated immediately in the browser, which is almost equivalent to changing the style directly in the browser devtools.

[0093] Among them, the second script is also a JavaScript script, which can be used to replace the built-in module hot replacement server of Webpack. Specifically, the core of the JavaScript script is to change the serverPath path of the built-in module hot replacement server to a custom path so that a WebSocket long connection can be established with the created module hot replacement client.

[0094] In an exemplary embodiment, when the first script and the second script are added to the page code through the local project packaging service, the configuration file code contained in the page code can be parsed to obtain gitignore and git filemode configurations, and the first script and the second script are added to the configuration file obtained after parsing. After the first script and the second script are added, a new project configuration file can be generated according to the existing config configuration file.

[0095] In this embodiment, after the local project packaging service completes adding the first script and the second script to the page code, the local project debugging service can create a module hot replacement service end according to the second script.

[0096] The local project debugging service may also package the page code including the first script to generate a page code file directory.

[0097] The local project debugging service is a Dev running service for a local front-end project based on Webpack.

[0098] The page code file directory refers to the dist file, which includes multiple files. For example, the dist file contains the project static resources html, css, js files, etc.

[0099] In this embodiment, the local project debugging service is also used to add a code segment for loading a third script of Service Worker in a preset file in the page code file directory, and to add the third script to the page code file directory.

[0100] Among them, Service Worker is an event-driven Worker registered under the specified source and path. It uses JavaScript to control the associated page or website, intercept and modify access and request resources, and cache resources in a fine-grained manner. It essentially acts as a proxy server between web applications, browsers, and the network. It runs in the Worker context, that is, in other threads rather than the browser main thread, so it cannot access the page DOM and will not cause blocking. It can only be carried by HTTPS and is a thread that is completely asynchronous with the browser main thread.

[0101] In this embodiment, when loading a page to be debugged, Service Worker can intercept all HTTP / HTTPS network requests in the current page to be debugged, modify the network request and response results, and then return them to the current page to be debugged as the network request result of the current page to be debugged. In this embodiment, a code segment for loading the Service Worker script can be pre-added in the page code file directory, so that when loading the page code, another thread can be started through the code segment to run the third script of the Service Worker to take over the current page to be debugged.

[0102] In this embodiment, the preset file is a pre-set file for adding code segments, which is specifically an html file in the page code file target.

[0103] In this embodiment, after adding the code segment, the third script of the JavaScript of the Service Worker can be placed in the page code file directory, so that the ServiceWorker script can be packaged together with other static resource files in the page code file directory through the Electron desktop client to generate a page code file package, and the page code file package can be uploaded to the node server 202.

[0104] In an exemplary implementation, the page code file directory containing the third script can be packaged into a tar package through the Electron desktop client. In this way, the Electron desktop client can upload the tar package to the node server 202 via an HTTP request. Specifically, the Electron desktop client can put the tar package into the request body of the HTTP request.

[0105] The node server 202 is used to deploy the received page code to the static resource service and return the network address of the static resource service to the debugging device 200 .

[0106] Specifically, the node server 202 can be deployed in a public network environment to carry API interface services, manage WebSocket long connection data interaction, receive, decompress, and manage session credentials (Session ID) and project static resources of different clients, and provide static resource services, etc. The static resource service is a container in the node server 202 for storing page codes.

[0107] In this embodiment, after receiving the page code uploaded by the debugging device 200 , the node server 202 deploys the received page code to the static resource service and returns the network address of the static resource service to the debugging device 200 .

[0108] In an exemplary embodiment, when the page code received by the node server 202 is a page code file package generated by packaging through the Electron desktop client, the node server 202 is also used to decompress the page code file package to generate a first code file, and deploy the generated first code file to the static resource service, and return the network address of the static resource service to the Electron desktop client.

[0109] It is understandable that when the page code received by the node server 202 is in the form of a file package, the page code file package needs to be decompressed first, and then the decompressed first code file will be deployed to the static resource service, so that the device 201 to be debugged can obtain the first code file from the static resource service.

[0110] In an exemplary embodiment, in order to quickly find the page code (or the first code file) stored in the static resource service, the node server 202 can create a directory named after the session credential information in the static resource service after generating the session credential information. In this way, when the page code file (or the first code file) is subsequently deployed, the received page code file package can be decompressed, and the page code obtained after decompression can be deployed to the directory named after the session credential information.

[0111] The device to be debugged 201 is used to obtain the network address from the debugging device 200, and obtain and load the page code from the static resource service according to the network address to open the page to be debugged.

[0112] Specifically, the device to be debugged 201 is a device that needs to be debugged by the debugging device 200. In this embodiment, when debugging the device to be debugged 201, the device to be debugged 201 will first obtain the network address from the debugging device 200, so that the page code can be obtained and loaded from the static resource server according to the network address, thereby opening the page to be debugged.

[0113] The debugging device 200 is further used to debug the page to be debugged by using a debugging tool installed in the debugging device 200 .

[0114] Specifically, the debugging tool is a tool required to be used in the process of remote debugging of the device to be debugged 201. In this embodiment, when debugging, after opening the page to be debugged, the debugging tool can be used to directly perform remote page debugging on the page to be debugged. Among them, page debugging can include page debugging operations such as reviewing elements, console printing, viewing network, memory management, etc.

[0115] In an exemplary implementation, the device to be debugged 201 may include an Android device installed with the hybrid mode mobile application. The Android device refers to a device using the Android system.

[0116] The debugging tool includes the Chrome Devtools Frontend debugging tool. The Chrome Devtools Frontend debugging tool performs page debugging based on the Chrome Devtools Protocol cross-end debugging protocol. The protocol performs page debugging data interaction based on data in JSON format and has no device restrictions. Most mainstream browsers and Webviews based on Chromium and Blink kernels on the market can be used to implement cross-end debugging.

[0117] The hybrid mode mobile application is used to obtain and load the first code file from the static resource service to open the page to be debugged.

[0118] Specifically, in order to enable the hybrid mode mobile application to conveniently obtain and load the first code file from the static resource service, the Electron desktop client can generate a corresponding identification code according to the network address after receiving the network address returned by the node server 202, wherein the identification code can be a QR code, a barcode, etc. In this way, when the hybrid mode mobile application needs to obtain the first code file, it can scan the barcode to obtain the network address from the barcode, and then obtain and load the first code file from the static resource service according to the network address to open the page to be debugged.

[0119] In one embodiment, in order to facilitate the subsequent hybrid mode mobile application to establish a WebSocket persistent connection with the node server 202, the Electron desktop client can also splice the session credential information with the network address, and generate a corresponding identification code based on the character information obtained after splicing; the hybrid mode mobile application is also used to establish the fourth WebSocket persistent connection with the node server 202 based on the session credential information identified from the identification code.

[0120] The hybrid mode mobile application is also used to load the third script according to the code segment in the first code file, intercept the network request of the page to be debugged through the third script, and create the second module hot replacement client according to the first script in the first code file.

[0121] Specifically, since the acquired first page code contains a code segment for loading the third script (ServiceWorker's script), the Service Worker's script can be loaded at the same time during the process of loading the acquired first page code file, and the network request of the page to be debugged can be intercepted by the Service Worker, so that the request address of the intercepted network request can be modified to the API interface service address of the node server 202.

[0122] In an exemplary embodiment, when the Service Worker modifies the request address of the intercepted network request to the API interface service address of the node server 202, the node server 202 will send the network request to the WebSocket client through the first WebSocket long connection. After receiving the network request, the WebSocket client performs domain name resolution on the network request through the Electron desktop client, and sends the network request to the server according to the address obtained after resolution. After receiving the network request, the server can respond to the network request.

[0123] Among them, the server-side server is the server for deploying API interface services, which is usually deployed in multiple environments, such as testing, PRE, and formal environments, and is used for front-end and back-end joint debugging at different stages.

[0124] In an exemplary embodiment, when the node server 202 receives the network request through the API interface service address, it will parse the network request and encapsulate the first network request obtained after the analysis into a second network request including a request sequence number, a request address, a request method, a request header and a request body.

[0125] In an exemplary embodiment, after receiving the network request, the service-side server will respond to the network request to generate a response result, and return the response result to the Electron desktop client. In this embodiment, when the Electron desktop client receives the response result returned by the service-side server, it can encapsulate the response result and send the encapsulated first response result to the node server 202 through the WebSocket client; then, the node server 202 will parse the received first response result and return the second response result obtained after parsing to the Service Worker, so that the Service Worker uses the second response result as the response result of the network request contained in the page to be debugged.

[0126] In one embodiment, in order to facilitate the analysis of the response result, after the Electron desktop client receives the first response result, it will encapsulate the received first response result into a second response result including a response sequence number, a response status code, response status information, a response header and a response body.

[0127] The second module hot-replaces the client, and is used to establish a second WebSocket persistent connection with the node server.

[0128] Specifically, the second module hot replacement client is a WebSocket client created when loading the first page code file, and is used to establish a WebSocket long connection with the module hot replacement server to exchange HMR hot update JSON data. In this embodiment, after receiving the HMR hot update JSON data, the second module hot replacement client will actively load the packaged hot module file to replace the local module in the page to be debugged, so as to achieve the effect of hot update.

[0129] The hybrid mode mobile application is also used to enable the Webview debugging mode, so that the Android device calls the Chromium kernel to create a Unix Domain Socket server according to the Webview debugging mode.

[0130] Specifically, the Webview debugging mode is a mode for remote debugging of applications. The Unix DomainSocket server is a service for providing external connections, communications, and exchange of JSON data for Hybrid page debugging. Its process ID format is @webview_devtools_remote_${pid}, where pid is the Webview process id. When the UnixDomain Socket server communicates with the Hybrid application, it uses an IPC (Inter-Process-Communication) communication method based on the file system that does not require network transmission. This communication method does not require network packaging, verification, and unpacking, and is more reliable and efficient.

[0131] The hybrid mode mobile application is further used to establish a third WebSocket persistent connection with the Unix Domain Socket server, and to establish a fourth WebSocket persistent connection with the node server 202 .

[0132] Specifically, when the hybrid mode mobile application establishes the fourth WebSocket long connection with the node server 202, the session credential information can be first identified from the identification code, and then the fourth WebSocket long connection can be established with the node server 202 based on the session credential information, so that the debugging JSON data of the page to be debugged can be exchanged with the node server 202 through the fourth WebSocket long connection.

[0133] In an exemplary implementation, the Unix Domain Socket server has corresponding process identification information, and the hybrid mode mobile application is further used to obtain process identification information of multiple processes currently opened in the Android device, and to search for the Unix Domain Socket server according to each process identification information; the hybrid mode mobile application is further used to initiate a handshake request to the Unix Domain Socket server, and after the handshake is successful, send a protocol upgrade instruction to the Unix Domain Socket server to upgrade the current communication protocol to the WebSocket protocol.

[0134] Specifically, the process identification information is information used to distinguish different processes. The hybrid mode mobile application can use the LocalSocket library to find the corresponding process of the Unix Domain Socket server according to the process identification information of each currently opened process, and then initiate a handshake request to the found process. After the handshake is successful, an HTTP message is sent to the Socket socket to upgrade the current communication protocol to the WebSocket protocol. After the upgrade is successful, the hybrid mode mobile application can communicate with the Unix Domain Socket Server server based on the WebSocket protocol.

[0135] The desktop client is also used to open the desktop debugging window;

[0136] The desktop debugging window is used to load the debugging tool installed in the debugging device 200 to debug the page to be debugged.

[0137] Specifically, the desktop client can open a desktop debugging window through the WebSocket client, and load a debugging tool (such as the Chrome Devtools Frontend debugging tool) installed in the debugging device 200 in the desktop debugging window to debug the page to be debugged.

[0138] Specifically, the Chrome Devtools Frontend debugging tool is used to debug the front-end UI of the page. It can be separated from the Chromium kernel and run independently as a front-end project. It communicates with the Chromium kernel through the WebSocket protocol to exchange debugging data in JSON format, thereby achieving the development effect of Chrome's built-in Devtools.

[0139] The Chrome Devtools Frontend debugging tool is used to establish a fifth WebSocket persistent connection with the WebSocket server, so as to debug the page to be debugged by exchanging debugging data with the Chromium kernel through the fifth WebSocket persistent connection.

[0140] Specifically, when the Chrome Devtools Frontend debugging tool establishes the fifth WebSocket persistent connection with the WebSocket server, it can first obtain the address information of the WebSocket server through the WebSocket client, and then establish a WebSocket persistent connection with the WebSocket server according to the obtained address information of the WebSocket server.

[0141] In one embodiment, when the Chrome Devtools Frontend debugging tool debugs the page to be debugged through the fifth WebSocket persistent connection, it can send a debugging request to the WebSocket server through the fifth WebSocket persistent connection, so that the WebSocket server can sequentially send the debugging request to the Unix Domain Socket server through the WebSocket client, the channel of the first WebSocket persistent connection, the channel of the fourth WebSocket persistent connection, and the channel of the third WebSocket persistent connection, thereby debugging the page to be debugged.

[0142] In another embodiment, when the debugging tool debugs the page to be debugged through the fifth WebSocket persistent connection, it can also send a debugging information acquisition request of the Hybrid page to be debugged to the WebSocket server through the fifth WebSocket persistent connection, so that the WebSocket server can send the debugging information acquisition request to the Unix Domain Socket server through the WebSocket client, the channel of the first WebSocket persistent connection, the channel of the fourth WebSocket persistent connection and the channel of the third WebSocket persistent connection in sequence, thereby acquiring the debugging information of the page to be debugged from the Unix Domain Socket server and performing debugging operations according to the acquired debugging information.

[0143] In an exemplary embodiment, in order to debug the page to be debugged in a timely manner, the hybrid mode mobile application is also used to send a signal that the debugging channel of the page to be debugged has been opened to the node server 202 through the fourth WebSocket long connection after establishing a fourth WebSocket long connection with the node server 202; the node server 202 is also used to send the signal to the WebSocket client through the first WebSocket long connection after receiving the signal, so that the WebSocket client opens the desktop debugging window after receiving the signal.

[0144] In this embodiment, the desktop debugging window is opened only when a signal indicating that the debugging channel has been opened is received, so as to officially start page debugging of the page to be debugged.

[0145] The node server 202 is also used to notify the Electron desktop client to establish a sixth WebSocket long connection between the first module hot replacement client and the module hot replacement server through the first WebSocket long connection after the second WebSocket long connection is established, so as to realize hot update of the page through the sixth WebSocket long connection.

[0146] Specifically, after the second WebSocket long connection is established, the node server 202 will notify the Electron desktop client through the first WebSocket long connection to establish a sixth WebSocket long connection between the first module hot replacement client and the module hot replacement server. In this way, the second module hot replacement client can send the page hot update data request to the module hot replacement server through the channel of the second WebSocket long connection, the channel of the first WebSocket long connection, and the channel of the sixth WebSocket long connection in sequence, so as to obtain the data of the page hot update.

[0147] In an exemplary embodiment, when the page code is modified, the Electron desktop client can also send the modified page code to the second module hot replacement client through the module hot replacement server in sequence through the channel of the sixth WebSocket long connection, the channel of the first WebSocket long connection, and the channel of the second WebSocket long connection, so as to implement hot update of the page according to the modified page code through the second module hot replacement client.

[0148] Reference Figure 3 , which is a hybrid mode mobile application debugging method of an embodiment of the present application. The method is applied to a debugging system of a debugging device, a node server and a simulator, wherein the debugging device is installed with a browser and a desktop client, wherein the debugging system is the debugging system in the above embodiment, and will not be described in detail in this embodiment.

[0149] In this embodiment, the method includes:

[0150] Step S30, uploading the page code of the hybrid mode mobile application to be debugged to the node server through the desktop client;

[0151] Step S31, deploying the received page code to the static resource service through the node server, and returning the network address of the static resource service to the desktop client;

[0152] Step S32, opening the simulator through the desktop client, and after the simulator is opened, installing the hybrid mode mobile application in the simulator;

[0153] Step S33, opening the network address in the simulator through the desktop client, so that when the hybrid mode mobile application detects that the simulator opens the network address, it calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged;

[0154] Step S34, opening the debugging tool in the browser through the desktop client;

[0155] Step S35, establishing a connection channel with the WKWebview kernel through the debugging tool, and debugging the page to be debugged through the connection channel.

[0156] The hybrid mode mobile application debugging method in this application, by relying on a series of system underlying tool chains, overcomes Apple's restrictions on real machine debugging, and implements a relatively complete Hybrid page remote debugging function through automated engineering, thereby improving debugging efficiency and maintaining the effect consistent with real machine Hybrid page debugging.

[0157] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on at least two network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiment scheme of the present application. Those of ordinary skill in the art may understand and implement it without creative labor.

[0158] Through the description of the above implementation methods, a person of ordinary skill in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A hybrid mode mobile application debugging system, characterized in that the debugging system includes a debugging device, a node server and a simulator, wherein the debugging device is installed with a browser and a desktop client, in: The desktop client is used to upload the page code of the hybrid mode mobile application to be debugged to the node server; The node server is used to deploy the received page code to the static resource service, and return the network address of the static resource service to the desktop client; The desktop client is further used to start the simulator and install the hybrid mode mobile application in the simulator after the simulator is started; The desktop client is further used to open the network address in the simulator, so that when the hybrid mode mobile application detects that the simulator opens the network address, it calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged; The desktop client is also used to open the debugging tool in the browser; The debugging tool is used to establish a connection channel with the WKWebview kernel and debug the page to be debugged through the connection channel; The desktop client is an Electron desktop client, the simulator is an iOS simulator, the browser is a Safari browser, and the debugging tool is a Safari developer tool integrated in the Safari browser, wherein: The Electron desktop client is used to create AppleScript automation services and iOS simulator automation services; The Electron desktop client is further used to open the iOS simulator through the iOS simulator automation service, and after the iOS simulator is opened, install the hybrid mode mobile application through the iOS simulator automation service, and after the hybrid mode mobile application is installed, open the network address in the iOS simulator through the iOS simulator automation service; The Electron desktop client is further used to open the Safari developer tool from the Safari browser via the AppleScript automation service; The Safari developer tool is used to establish a connection channel with the WKWebview kernel through the Safari debugging protocol, and debug the Hybrid page to be debugged through the connection channel.

2. The hybrid mode mobile application debugging system according to claim 1, It is characterized in that The Electron desktop client is also used to request the node server to obtain session credential information; The node server is used to generate session credential information when receiving a session credential information acquisition request sent by the Electron desktop client, and send the session credential information to the Electron desktop client, so that the Electron desktop client establishes a connection with the node server according to the session credential information.

3. The hybrid mode mobile application debugging system according to claim 1, It is characterized in that The node server is further configured to create a directory named after the session credential information is generated in the static resource service.

4. The hybrid mode mobile application debugging system according to claim 3, It is characterized in that The Electron desktop client is also used to package the page code and upload the packaged file package to the node server; The node server is further used to decompress the file package and deploy the page code obtained after decompression to a directory named after the session credential information in the static resource service.

5. The hybrid mode mobile application debugging system according to claim 1, It is characterized in that The Electron desktop client is also used to simulate a click on the Safari developer tool in the Safari browser through the AppleScript automation service to open the Safari developer tool.

6. The hybrid mode mobile application debugging system according to claim 1, It is characterized in that The Electron desktop client is also used to close all currently enabled iOS simulators through the iOS simulator automation service, and reopen the selected iOS simulator after all iOS simulators are closed.

7. The hybrid mode mobile application debugging system according to claim 1, It is characterized in that The Electron desktop client is also used to install the test environment certificate through the iOS simulator automation service.

8. The hybrid mode mobile application debugging system according to any one of claims 1 to 7, It is characterized in that The Electron desktop client is also used to open the network address in the iOS simulator through the iOS simulator automation service, and then open the hybrid mode mobile application through the URL Schema, so that the hybrid mode mobile application calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged.

9. A hybrid mode mobile application debugging method, applied to a debugging system including a debugging device, a node server and a simulator, wherein the debugging device is installed with a browser and a desktop client, It is characterized in that The method comprises: Uploading the page code of the hybrid mode mobile application to be debugged to the node server through the desktop client; Deploy the received page code to the static resource service through the node server, and return the network address of the static resource service to the desktop client; Opening the simulator through the desktop client, and after the simulator is opened, installing the hybrid mode mobile application in the simulator; Open the network address in the simulator through the desktop client, so that when the hybrid mode mobile application detects that the simulator opens the network address, it calls the WKWebview kernel to obtain and load the page code from the static resource service to open the page to be debugged; Open the debugging tool in the browser through the desktop client; Establish a connection channel with the WKWebview kernel through the debugging tool, and debug the page to be debugged through the connection channel; The desktop client is an Electron desktop client, the simulator is an iOS simulator, the browser is a Safari browser, and the debugging tool is a Safari developer tool integrated in the Safari browser, wherein: Using the Electron desktop client, creating AppleScript automation services and iOS simulator automation services; Using the Electron desktop client, enabling the iOS simulator automation service to start the iOS simulator, and after the iOS simulator is started, installing the hybrid mode mobile application through the iOS simulator automation service, and after the hybrid mode mobile application is installed, opening the network address in the iOS simulator through the iOS simulator automation service; causing the AppleScript automation service to open Safari developer tools from the Safari browser via the Electron desktop client; Through the Safari developer tool, the Safari debugging protocol establishes a connection channel with the WKWebview kernel, and the Hybrid page to be debugged is debugged through the connection channel.