Skip to content

fix: correct iOS lowMemory to real memory pressure, bump to 1.14.1 - #112

Merged
AmisKwok merged 4 commits into
mainfrom
fix/ios-lowmemory-1.14.1
Oct 1, 2026
Merged

AmisKwok merged 4 commits into
mainfrom
fix/ios-lowmemory-1.14.1

Conversation

@AmisKwok

@AmisKwok AmisKwok commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary / 摘要

Fixes an iOS semantic bug where getProcessMemoryInfo's lowMemory field reported ProcessInfo.isLowPowerModeEnabled (Low Power / low-battery mode) instead of the actual low-memory state, mismatching Android/OHOS; also bumps the package to 1.14.1.
修复 iOS 语义 bug:getProcessMemoryInfo 的 lowMemory 字段此前返回 isLowPowerModeEnabled(低电量 / 省电模式)而非真实低内存状态,与 Android / OHOS 不符;同时将包版本升至 1.14.1。

Changes / 变更

  • iOS getProcessMemoryInfo now reports real system memory pressure via a DispatchSource memory-pressure monitor (CRITICAL→true / NORMAL→false) for the lowMemory field, replacing the incorrect isLowPowerModeEnabled (Low Power Mode).
    / iOS getProcessMemoryInfo 的 lowMemory 字段现改用 DispatchSource 内存压力监听返回真实系统内存压力,取代错误的 isLowPowerModeEnabled(低电量模式)。
  • Bumped version 1.14.0 → 1.14.1 across pubspec.yaml, ios/zero_inspector_kit.podspec, lib/src/utils/inspector_version.dart, README.md, README_zh.md, and example/pubspec.lock.
    / 在 pubspec.yaml、iOS podspec、inspector_version.dart、中英文 README 及 example/pubspec.lock 中将版本由 1.14.0 升到 1.14.1。
  • Added a ## 1.14.1 CHANGELOG entry and updated the "Upgrade recommended" callouts in both READMEs to describe this fix.
    / 新增 ## 1.14.1 变更日志条目,并更新中英文 README 的"推荐升级"提示,简述本次修复。

Context / 背景

On iOS there is no public API to query a boolean "is low memory" state, so the original code reused isLowPowerModeEnabled as a proxy — conflating battery saver mode with memory pressure. The lowMemory field already means "low memory state" on other platforms (Android uses real memory pressure), so the iOS value was misleading. This wires up the proper DispatchSource memory-pressure signal.
iOS 没有公开 API 能直接查询"是否处于低内存状态"的布尔值,原代码误用 isLowPowerModeEnabled 作为代理,把省电模式与内存压力混为一谈。lowMemory 字段在其它平台(Android 使用真实内存压力)本就表示"低内存状态",因此 iOS 原返回值有误导。本次接入正确的 DispatchSource 内存压力信号。

Checklist / 检查项

  • Title follows Conventional Commits / 标题符合约定式提交
  • CI checks pass after merge / 合入后 CI 通过

Test plan

  • flutter test test/version_consistency_test.dart passes (all 5 checks green) / flutter test test/version_consistency_test.dart 通过(5 项全绿)
  • On an iOS device/simulator under memory pressure, getProcessMemoryInfo()['lowMemory'] reflects the pressure state and no longer mirrors Low Power Mode / 在 iOS 真机 / 模拟器上施加内存压力时,getProcessMemoryInfo()['lowMemory'] 应反映内存压力状态,不再与低电量模式同步

🤖 Generated with Zero Buddy

- iOS getProcessMemoryInfo now reports system memory pressure via a DispatchSource memory-pressure monitor for the lowMemory field, instead of ProcessInfo.isLowPowerModeEnabled (Low Power / low-battery mode), matching Android/OHOS semantics.

- Bump version 1.14.0 -> 1.14.1 (pubspec, podspec, inspector_version, README, example lock).
Replace unavailable DispatchSourceMemoryPressure.memoryPressureFlags with source.data (raw memory-pressure event flags), which is available across toolchains. Behavior unchanged: CRITICAL sets lowMemory true, NORMAL sets it false.
source.data returns DispatchSource.MemoryPressureEvent in this toolchain (memoryPressureFlags is unavailable); use flags.contains(.critical/.normal) directly. Restores correct low-memory detection.
@AmisKwok
AmisKwok merged commit 3575eae into main Oct 1, 2026
10 checks passed
@AmisKwok
AmisKwok deleted the fix/ios-lowmemory-1.14.1 branch October 1, 2026 15:17
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