Skip to content

Conversation

viatearz
Copy link
Contributor

@viatearz viatearz commented Aug 4, 2025

It was confirmed that some games suffer from excessive CPU usage.
This is caused by CMMotionManager setting the default update interval to 0, which results in extremely frequent updates.

You can verify the update frequency using the following code:

// NSObject+Swizzle.mm

@implementation NSObject (Swizzle)
- (void)hook_UINSVirtualMotionDevice_scanAccelerometer {
    NSLog(@"[PlayTools] hook_UINSVirtualMotionDevice_scanAccelerometer");
    [self hook_UINSVirtualMotionDevice_scanAccelerometer];
}
@end

@implementation PTSwizzleLoader
+ (void)load {
    [objc_getClass("UINSVirtualMotionDevice") swizzleInstanceMethod:NSSelectorFromString(@"_scanAccelerometer") withMethod:@selector(hook_UINSVirtualMotionDevice_scanAccelerometer)];
}
@end

As shown below, the actual update interval can be as short as 0.0001 seconds.
Screenshot

Some other games explicitly set the update interval to 0.01 or 0.02 seconds via [CMMotionManager setAccelerometerUpdateInterval:], so they do not have excessive CPU usage.

How to Fix
Hook [CMMotionManager init] and change the default update interval to 0.01 seconds.

@viatearz
Copy link
Contributor Author

viatearz commented Aug 4, 2025

Related Games:
#189 Yu-Gi-Oh! Master Duel
PlayCover/PlayCover#1600 Princess Connect Re:Dive(CN)
PlayCover/PlayCover#1832 Ensemble Stars
PlayCover/PlayCover#456 Star Wars: Galaxy of Heroes
GODDESS OF VICTORY: NIKKE
Brown Dust 2
Shadowverse: Worlds Beyond
MementoMori
Solo Leveling: Arise
and many others.

@viatearz viatearz force-pushed the fix/high_cpu_usage branch from 5d22aa6 to dd0002d Compare August 17, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant