none provided
Back to all articles

Have Fun with Apple’s Virtualization.Framework

Mar 3, 2025Author: Evgenii Matsiuk 
none provided

One of the reasons I “love” Apple is the plethora of undocumented features that keep us on our toes. At Marathon Cloud, we rely on Apple’s Virtualization.Framework to launch virtual machines for testing purposes. Virtualization.Framework provides high-level Swift APIs for creating and managing virtual machines, making it a powerful tool for developers. We’ll explore more details about this framework and some of its inner workings in upcoming articles.

 

Recently, we decided to explore the use of snapshots in virtual machines through the saveMachineStateTo and restoreMachineStateFrom methods. Snapshots are a fantastic feature that allows us to initialize a machine in a ready state for testing.

 

Our goal was to compare the performance of VMs with snapshots against those without them. We selected a series of client tests and ran them on both types of VMs. Everything seemed fine until, midway through the tests, our snapshotted VMs crashed. What was happening?

none provided

Changing the test set resolved the issue, but the original set consistently led to crashes. It became apparent that certain tests were causing the problem. Upon investigation, we identified the culprit: a test involving a video player. This test passed without issue on non-snapshotted VMs. Despite the lack of documentation regarding any additional restrictions, the VM’s console logs indicated audio issues. Audio?

 

Further research led us to a discussion on Tart CLI (see the issue on GitHub), where users found that certain devices, including audio, cause snapshotted VMs to crash when used. Disabling these devices prevented crashes. Finally!

 

There were no crashes, but some video tests were still failing (though not crashing the VM). What now? Some video players require an audio device to display video, and our client uses such players. However, some players are more tolerant of audio issues. For instance, if you open YouTube in Google Chrome and play a video, it will work without issues, except for logs in the Console app indicating audio device problems.

 

So, we finally discovered what was crashing our VMs. But the disappointing point is that there is no official info about such corner cases. When working with Apple’s ecosystem, prepare for the unexpected. And if you think AI will replace engineers, think again. Not anytime soon.

IOS
UI Testing
Virtualization