Zhuo Yitong: Honey or poison of the HarmonyOS Next system?
Let's break down the technologies behind both Easy Exit and DroiTong Android container native HAP applications on HarmonyOS Next/5.x+ that enable Android APK compatibility on an Android-less system.
Hello, I'm Lao Liu
Recently, many people have been asking about the two new applications of the Hongmeng NEXT system, DroiTong and EasyAbroad MicroG AOSP 12 based EMUI images.
Lao Liu analyzed some details of this software, and I think it is quite interesting, I think it can be analyzed from three perspectives: user experience, underlying principles and impact on the Hongmeng ecosystem.
User experience
performance
I saw some assessments, especially those who ran the score directly??
Overall, from the perspective of running scores, the performance is 93% of HarmonyOS native, which is basically the average level of containers, and the performance loss is not large.
But the other aspects are worse.
memory
This Android runtime container itself requires around 8GB of memory to run.
So if you don't have a beggar version of the phone with 16G memory, don't think about running any big programs.
power consumption
Many netizens commented that the mobile phone is easy to get hot, which is the performance of high power consumption.
In fact, it is easy to understand that the only way to make up for it is to continuously run a container for another system on one system without a significant loss of performance.
It's also important to note that high memory usage and high power consumption not only affect Android applications running in containers, but also native applications.
The available memory of the native application is reduced, and the CPU is continuously occupied by the container, which may cause lag or even abnormalities during use.
Of course, the battery life of the mobile phone will also drop significantly.
User experience
There are also many users who report more bugs.
I think this is related to the compatibility of the container itself, and on the other hand, it is also related to memory and power consumption.
In the case of high power consumption and tight memory, many mobile apps will have some problems.
Overall, the user experience is usable, but not easy to use.
In other words, it is more suitable for temporary emergencies, and it is not recommended for daily use, in addition to bugs, it will also cause a decrease in battery life.
The underlying principle
As we mentioned earlier, the overall performance penalty is not significant, which can also be verified as not the VM solution.
But in fact, this technical solution is not exactly what many people call container technology, my understanding is a lightweight virtual technology between containers and virtual machines like WSL2.
Next, let's compare several solutions for running another system application on one system.
virtual machine
A virtual machine is the process of running a target system or application by simulating a complete hardware environment in the system.
Assuming that you are using a virtual machine to run an Android application, this would be the following structure.
When running an Android application, the virtual machine deploys the complete Android system on top of the virtual mobile phone hardware, and maps the instructions to the underlying architecture of the HarmonyOS system through dynamic translation.
Let's first take a look at the runtime architecture of a normal Android app
If you run in a virtual machine, the overall architecture is as follows:
As you can see from the architecture, the advantages and disadvantages of virtual machines are obvious.
Advantages:
Strong isolation: VMs are isolated from the host system through an independent operating environment, which can provide higher security.
Strong compatibility: It can natively support almost all Android applications on the host system without modifying the application.
inferior position
Performance overhead: Virtual machines often have a high resource footprint and performance cost due to the need to emulate hardware and runtime environments.
Long startup time: The initialization process of the virtual machine is complex and the startup speed is relatively slow.
However, in the scenario of Zhuoyitong, we do not need to virtualize a different set of mobile phone hardware, because the cost is too great.
Is it possible to share a single hardware between the virtual system and the host system?
There is also such a solution, which is lightweight virtualization technology.
Lightweight virtualization
A typical example of this technical solution is Microsoft's Linux subsystem, hereinafter referred to as WSL2.
In simple terms, WSL2 runs a Linux kernel on Windows, but it doesn't dummy hardware.
WSL2 leverages virtualization technologies such as Hyper-V to provide kernel isolation while eliminating the silos between traditional virtual machines and host systems through deep integration with Windows systems. For example, the performance and user experience of file system operations, network shares, and process calls are closer to those of native applications.
The schematic diagram of the architecture is as follows:
It has the following characteristics:
Virtualized but not emulation:
Run the Linux kernel with lightweight virtualization.
Instead of emulating hardware, it directly utilizes the hardware resources of the host.
Efficient System Call Bridging:
Linux applications call the Linux kernel directly, while the WSL2 kernel communicates with Windows through Microsoft's interface.
It is more efficient than traditional virtual machines, and some of the performance is close to running natively.
The user experience is similar to containers:
Provides a fast-starting, lightweight experience.
Seamlessly interacts with the Windows file system and supports shared resources.
API compatibility layer
Although the performance of lightweight virtualization solutions is much higher than that of virtual machines, there are still middlemen.
Hyper-V still provides virtual CPU and memory upwards, and the Linux kernel itself will also take up a lot of CPU and memory resources.
Is it possible to run another system's application directly on the host runtime?
There are also such schemes.
A typical example is Wine on Linux, which can run windows exe programs directly on Linux.
Wine (Wine Is Not an Emulator) is a compatibility layer that allows Windows programs to be run on Linux, macOS, or other Unix-like systems.
It enables Windows applications to run natively on non-Windows systems by directly translating Windows API calls into native system calls for the corresponding platform.
The architecture is as follows:
Pros of Wine:
High Performance:
No virtualization overhead: Wine translates Windows API calls directly into calls to the host operating system, so it doesn't have the additional performance overhead of virtual machines or containers. This makes Wine typically run Windows applications with performance close to native Windows systems.
Operational efficiency: With no emulated hardware or operating system, Wine is typically more efficient than virtual machines such as VMware or VirtualBox and WSL2.
Smaller resource consumption:
Low resource footprint: Wine doesn't need to emulate an entire hardware environment like a virtual machine, nor does it need to run a full operating system. As a result, it consumes relatively few resources, such as CPU and memory, making it ideal for systems with limited resources.
Fast startup: Wine launches Windows applications faster than virtual machines or WSL2 because it doesn't require a full virtual operating system to be launched.
Cons of Wine:
Compatibility Issues:
Not all Windows apps are compatible: Wine isn't the perfect Windows compatibility tier, and not all Windows apps run smoothly. Although Wine is compatible with many applications, some complex applications, especially programs that require access to the underlying hardware, such as some games or professional software, may not work properly.
Limited driver and API support: Wine doesn't fully implement all of Windows' APIs, it only supports most common Windows calls. For some advanced features or special hardware support, such as DirectX or some graphics acceleration features, Wine's support may be insufficient.
Weak graphics and multimedia support:
Graphics performance issues: Although Wine supports mapping for DirectX and OpenGL, graphics performance can be poor compared to the Windows native runtime, especially on graphics-intensive applications such as 3D games, graphic design software, and more. Wine's DirectX to OpenGL conversion can impact rendering performance.
Limited hardware acceleration support: Wine doesn't have direct access to hardware acceleration features such as GPU acceleration, so it may not perform as well as Windows native in applications that require highly graphical rendering.
Zhuoyitong's solution
The current mainstream cross-platform operation App scheme was introduced earlier, so which one does the protagonist of this article, Zhuo Yitong, use?
Zhuoyitong uses Huawei's own iSulad container.
In fact, the technical solution is similar to the WSL2 introduced earlier.
As you can see, because the HarmonyOS kernel is compatible with Linux ABI (Application Binary Interface), and the Android kernel is modified based on the Linux kernel.
So you can run a custom Android runtime directly on the HarmonyOS kernel.
Of course, there is no full Android kernel function here, so some of the compatibility bugs mentioned above may also be caused by this reason.
Maybe many students who are not engaged in Android development have no concept of this runtime, take a look at the following picture:
The sections in red are all about the Android runtime mentioned in this article.
Or we can think of it this way, for an Android app to work, most of the content in it is required.
So it's understandable,Why just run Zhuo Yitong needs about 8G memory, right?
And there are many things that need to be stationed in the background to respond to user and APP requests in real time, which is why Zhuoyitong will cause continuous power consumption and heating.
Earlier we described the options for running applications on one system on another.
Based on this, the characteristics of Zhuoyitong's technical solutions are introduced.
I believe that everyone has a certain understanding of what Zhuo Yitong is.
So let's take a look at the possible impact of the launch of the two applications, Zhuoyitong and Exit, on the HarmonyOS ecosystem after being compatible with the Android ecosystem through the virtualization solution?
Honey or poison?
compromise
HarmonyOS currently claims to have 15,000 apps.
Relative to their Android counterparts, what percentage of these apps have functions can be roughly known by looking at WeChat.
Even if you don't consider the coverage of functions, the number of 15,000 is still too small for users to support daily use.
The figure below is the data for 2023, and this data does not include a large number of apps that are not listed in the app store.
Taking myself as an example, Lao Liu has installed a lot of open source or development tool companion apps on his mobile phone, and most of these apps are not on the app store.
In 😮 💨 short, if you want to support the daily use of a large number of users, it is not possible to have a sufficient number of applications.
Therefore, it is compatible with Android applications, so that the mobile phone running the HarmonyOS next system can at least meet the daily use, which is a compromise that has to be made.
side effect
Originally, for the company or team, it would be good if the current form did not reduce the number of people, but also increased the cost of HarmonyOS development?
Unless you can see a clear benefit, such as a large enough number of users, there is no incentive to develop.
Now with Zhuoyitong, there is even less incentive for development.
This reminds me of the time when BlackBerry phones were also compatible with Android apps, and in the end, their own ecology did not develop.
Here I also have to mention a mysterious operation:
The application Zhuo Yitong on the shelves of pure-blooded Hongmeng cannot be installed inside, while the exit easy can only install the application in the whitelist.
It is equivalent to the fact that I finally developed a HarmonyOS version of the App, but due to lack of manpower, the functions are not complete for a while, and now users can't use my Android version.
Then I'll simply not develop the HarmonyOS version, so that users can at least use the fully functional version.
So this decision gives people the feeling that they have to compromise and can't let go.
Easy Exit, EasyAbroad uses LXC container as the Android container engine for the Linux shim interaction on top of Linux ABI subsystem of the Hongmeng kernel for OS level virtualisation.
This particular app, which is a more viable third option than the latter two, which is an Android compiler within a binary translator of wrapped libraries within HAR like Windows DLLs that comes with a partial AOSP framework, 3rd party developer has built in, with native HarmonyOS HAP app that takes direct advantage of the native HongMeng kernel and OpenHarmony framework at it’s core with supported Linux libraries of Linux compatibility layer, within Linux ABI, musl-libc/POSIX modules which gets complex on it’s technicalities when native AOSP framework compatibility is removed and replaced with OpenHarmony base at it’s core and the custom HarmonyOS kernel with it, with AOSP binary only allows upgrade path at reused Linux drivers level away from AOSP framework application level.
The future of the HarmonyOS ecosystem
As a front-line developer, I have been an architect and a team, so I have always been concerned about cost.
In its current form, many companies have only one person left in their client teams, Android and iOS.
Even if the established team is still retained, it is difficult to add another HarmonyOS development team.
Therefore, if you want to make the HarmonyOS ecosystem grow rapidly, the most effective way is to vigorously develop the compatibility of cross-platform frameworks like Flutter on HarmonyOS.
If a team and a set of code can develop Android, iOS, and HarmonyOS at the same time, and all of them can provide a native-level user experience, can the previous problems be effectively solved?
As far as I know, there are quite a few apps based on the customized version of Flutter HarmonyOS that have been put on the shelves.
I also hope that the Flutter ecosystem based on the HarmonyOS system can be quickly improved.
summary
This article introduces the experience and working principle of running Android apps in the pure-blooded Hongmeng version of Zhuoyitong and Exit Easy.
At the same time, some views on the HarmonyOS ecosystem of running Android applications in this virtual environment are analyzed.
Personal opinion: A cross-platform framework like Flutter is the key to the rapid growth of the HarmonyOS ecosystem.
If you see that the students here are interested in learning Flutter, please contact Lao Liu, and we will learn from each other.
Click on the "Flutter Development Manual" compiled by Lao Liu for free, covering 90% of application development scenarios.
It can be used as a knowledge map for Flutter to learn.
The Flutter Development Manual covers 90% of development scenarios
作者:程序员老刘
链接:https://juejin.cn/post/7448842151700332555
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。