Tpatch Dynamic Patch system (IOS)

Source: Internet
Author: User

Copyright notice: This article by Zhu Yu original article, reprint please indicate source:
Article original link: https://www.qcloud.com/community/article/160

Source: Tengyun https://www.qcloud.com/community

Tpatch is a system that uses JavaScript to patch iOS, which is a very effective solution to the crash and various problems of online apps.

1. Where does it come from?

For every development, from writing Hello World to using various languages, you may encounter a variety of bugs. Some bugs can be solved quickly, such as web-side, send a JS or HTML. However, in the terminal development, such as iOS, found that the online problem is often not so fast to solve, changing the package may require Apple short days longer than a week of audit, high cost. Is there a way to quickly solve online problems with iOS apps? Tpatch is one of the better solutions.

2.TPatch Features

    • Support Multithreading:
      The natural advantage of using JS patching is that JavaScriptCore is thread-safe, although the granularity of the lock is a bit large, and some methods have problems with the lock (these are resolved in Tpatch).
    • Block Support:
      There are many similarities between the function in JS and the block of OC. With the function defined in the patch, passed to OC, we will turn to block, and block can be passed between OC and JS, this LUA patch is difficult to do.
    • Asynchronous mechanism:
      Because the Javssciptcore is thread-safe, it also brings another problem, if the worker thread and the main thread are patched, the worker's patch time is very serious, and if the main thread patch starts to run, it will be blocked. Tpatch introduces an asynchronous mechanism that allows quick return of patches into the Jscore, asynchronous execution, and reduced impact between patches.
    • Support for online reset rollback:
      After the release of the patch, it is possible to monitor the problem of patches, the user side of the running logic has been "contaminated." Tpatch support, after the patch background set the patch expires, the user side app will delete the local problematic patch pack, and online reset, instead of waiting for the app to restart and then restore, the next reboot may be several days.
    • Easy commissioning:
      Using the natural advantages of the JavaScriptCore, the internal debug interface is provided. We can do the same as debugging the Web page in the app, using Safari remote debugging patches on Mac, breakpoints, stacks, exceptions and so on.
    • Precision Delivery:
      Tpatch supports delivery by user, iOS version, business app version, and mask tag. Mask is an extensible bit tag that can be customized for business, such as taking a jailbreak tag, or a network tag, which can be issued based on jailbreak and network tagging.
3. Core Principles

Tpatch includes a patch back-end system and terminal components, the core principle is the patch background according to patch configuration, issued a patch JS to the terminal, the terminal to perform this patch, using OC Runtime to cover the problem of the method or a logic, fixed runtime logic, so as to achieve the purpose of fixing the bug.

4. Patching process


1) in the patch background after the patch script, the first will go through the iOS7 and above the system to bring the Javascriptcore.framework JS patch execution, through the call Tpatch.js inside the bridge interface, call to OC inside the method of patching, patched.
2) When the business code executes the patched function, it will not be the original OC code, but a section of JS code. JS can be caused by JS and OC Engine support block, asynchronous execution and so on, and Support online reset rollback.

5. Comparison with other programs
    • Waxpatch:
      is a lua+wax patching scenario, the app needs to integrate the LUA interpreter and the wax framework (close to 1M). But Waxpatch to block is not perfect, multi-threaded patches may also have problems, wax has been two years without anyone to maintain. In contrast, the tpatch is lighter, with only 200K impact on the installation package, and the functionality is even more powerful.
    • Jspatch:
      Also use JS to patch, and tpatch terminal components core principle is similar. However, jspatch in the actual mass of products in the use of many problems have not been solved, such as block transfer, multi-threaded crash problems, tpatch solve these problems, more stable, and support asynchronous mechanism, dynamic rollback and other optimization features.

Tpatch Dynamic Patch system (IOS)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.