Skip to content

Commit

Permalink
Fix: crash (#91)
Browse files Browse the repository at this point in the history
Co-authored-by: yvanpeng <[email protected]>
  • Loading branch information
yuanyuan100 and yvanpeng authored Jul 15, 2024
1 parent 633ff90 commit ba8cf49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Lemon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>5.1.9</string>
<key>CFBundleVersion</key>
<string>1018</string>
<string>1019</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
Expand Down
12 changes: 8 additions & 4 deletions localPod/LemonStat/LemonStat/Classes/src/McGpuInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,24 @@ - (void)updateInfoIOService {
}

NSNumber *utilization = stats[@"Device Utilization %"];
if (!utilization) {
if (![utilization isKindOfClass:NSNumber.class]) {
utilization = stats[@"GPU Activity(%)"];
}
if (!utilization) {
if (![utilization isKindOfClass:NSNumber.class]) {
continue;
}

// IOKit 框架定义的标识符属性
NSInteger IOVARendererID = [dict[@"IOVARendererID"] longValue];
NSNumber *IOVARendererID = dict[@"IOVARendererID"];
NSInteger ID = 0;
if ([IOVARendererID isKindOfClass:NSNumber.class]) {
ID = [IOVARendererID longValue];
}
CGFloat usage = [utilization longValue] / 100.0;
usage = fmaxf(0.0, fminf(usage, 1.0));

McGpuCore *gpuCore = [[McGpuCore alloc] init];
gpuCore.ID = IOVARendererID;
gpuCore.ID = ID;
gpuCore.usage = usage;

[mutableCores addObject:gpuCore];
Expand Down

0 comments on commit ba8cf49

Please sign in to comment.