Skip to content

[Bug report] -[PHImageManager runRequestWithContext:] + 76 (PHImageManager.m:594) crash #1315

@hc2088

Description

@hc2088

Version

3.7.1

Platforms

iOS

Device Model

iphone14 (17.4)

flutter info

flutter doctor -v                                                                                          
[✓] Flutter (Channel stable, 3.32.8, on macOS 15.5 24F74 darwin-arm64 (Rosetta), locale zh-Hans-CN) [342ms]
    • Flutter version 3.32.8 on channel stable at /opt/fvm/versions/3.32.8
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision edada7c56e (3 months ago), 2025-07-25 14:08:03 +0000
    • Engine revision ef0cd00091
    • Dart version 3.8.1
    • DevTools version 2.45.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,062ms]
    • Android SDK at /Users/huchu/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = /Users/huchu/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1,037ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2025.1) [8ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)

[!] Proxy Configuration [7ms]
    • HTTP_PROXY is set
    ! NO_PROXY is not set

[✓] Connected device (4 available) [5.8s]
    • huchu (wireless) (mobile) • 00008101-001175A23A12001E            • ios            • iOS 17.3.1 21D61
    • iPhone 16 Plus (mobile)   • F98FBC2F-9464-45CA-86FD-45D893B32D61 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-6 (simulator)
    • macOS (desktop)           • macos                                • darwin-arm64   • macOS 15.5 24F74 darwin-arm64 (Rosetta)
    • Chrome (web)              • chrome                               • web-javascript • Google Chrome 141.0.7390.66

[!] Network resources [1,084ms]
    ✗ A network error occurred while checking "https://storage.flutter-io.cn": Connection reset by peer

! Doctor found issues in 2 categories.

How to reproduce?

  final data = await asset.thumbnailDataWithSize(
    ThumbnailSize(thumbWidth, thumbWidth),
    quality: thumbQuality,
  ); 

调用这里出触发的调用栈为:

PhotoManagerPlugin.getThumbnail (plugin.dart:249)
AssetEntity.thumbnailDataWithOption (entity.dart:684)
AssetEntity.thumbnailDataWithSize (entity.dart:660)
_EnhancedGalleryWidgetState._getThumb (enhanced_gallery.dart:282)

_FutureBuilderState._subscribe. (async.dart:1)

从而导致上面native崩溃:
Thread 15 Crashed:
0 libsystem_kernel.dylib 0x00000001d9e6c064 __abort_with_payload + 8 (:-1)
1 libsystem_kernel.dylib 0x00000001d9e8bc84 abort_with_payload_wrapper_internal + 104 (terminate_with_reason.c:102)
2 libsystem_kernel.dylib 0x00000001d9e8bc1c abort_with_reason + 32 (terminate_with_reason.c:116)
3 libobjc.A.dylib 0x000000018909beac _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 116 (objc-errors.mm:216)
4 libobjc.A.dylib 0x000000018909be38 _objc_fatal(char const*, ...) + 32 (objc-errors.mm:232)
5 libobjc.A.dylib 0x000000018909b01c weak_register_no_lock + 396 (objc-weak.mm:423)
6 libobjc.A.dylib 0x000000018909ac2c objc_storeWeak + 472 (NSObject.mm:387)
7 Photos 0x00000001a8ad39c4 -[PHImageManager runRequestWithContext:] + 76 (PHImageManager.m:594)
8 Photos 0x00000001a8adf1c0 -[PHImageManager requestNewCGImageForAsset:targetSize:contentMode:options:resultHandler:] + 940 (PHImageManager.m:1061)
9 Photos 0x00000001a8adede4 -[PHImageManager requestImageForAsset:targetSize:contentMode:options:resultHandler:] + 172 (PHImageManager.m:639)
10 photo_manager 0x00000001051af010 -[PMManager fetchThumb:option:resultHandler:progressHandler:] + 488 (PMManager.m:459)
11 photo_manager 0x00000001051aedac -[PMManager getThumbWithId:option:resultHandler:progressHandler:] + 192 (PMManager.m:431)
12 photo_manager 0x00000001051b9518 -[PMPlugin handleMethodResultHandler:manager:notificationManager:] + 2388 (PMPlugin.m:437)
13 photo_manager 0x00000001051b8b68 __19-[PMPlugin onAuth:]_block_invoke + 40 (PMPlugin.m:376)
14 libdispatch.dylib 0x00000001990a913c _dispatch_call_block_and_release + 32 (init.c:1530)
15 libdispatch.dylib 0x00000001990aadd4 _dispatch_client_callout + 20 (object.m:576)
16 libdispatch.dylib 0x00000001990bca6c _dispatch_root_queue_drain + 864 (queue.c:7136)
17 libdispatch.dylib 0x00000001990bd09c _dispatch_worker_thread2 + 156 (queue.c:7204)
18 libsystem_pthread.dylib 0x00000001edc548f8 _pthread_wqthread + 228 (pthread.c:2709)
19 libsystem_pthread.dylib 0x00000001edc510cc start_wqthread + 8 (:-1)

Logs

Thread 15 name:
Thread 15 Crashed:
0   libsystem_kernel.dylib        	0x00000001d9e6c064 __abort_with_payload + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001d9e8bc84 abort_with_payload_wrapper_internal + 104 (terminate_with_reason.c:102)
2   libsystem_kernel.dylib        	0x00000001d9e8bc1c abort_with_reason + 32 (terminate_with_reason.c:116)
3   libobjc.A.dylib               	0x000000018909beac _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 116 (objc-errors.mm:216)
4   libobjc.A.dylib               	0x000000018909be38 _objc_fatal(char const*, ...) + 32 (objc-errors.mm:232)
5   libobjc.A.dylib               	0x000000018909b01c weak_register_no_lock + 396 (objc-weak.mm:423)
6   libobjc.A.dylib               	0x000000018909ac2c objc_storeWeak + 472 (NSObject.mm:387)
7   Photos                        	0x00000001a8ad39c4 -[PHImageManager runRequestWithContext:] + 76 (PHImageManager.m:594)
8   Photos                        	0x00000001a8adf1c0 -[PHImageManager requestNewCGImageForAsset:targetSize:contentMode:options:resultHandler:] + 940 (PHImageManager.m:1061)
9   Photos                        	0x00000001a8adede4 -[PHImageManager requestImageForAsset:targetSize:contentMode:options:resultHandler:] + 172 (PHImageManager.m:639)
10  photo_manager                 	0x00000001051af010 -[PMManager fetchThumb:option:resultHandler:progressHandler:] + 488 (PMManager.m:459)
11  photo_manager                 	0x00000001051aedac -[PMManager getThumbWithId:option:resultHandler:progressHandler:] + 192 (PMManager.m:431)
12  photo_manager                 	0x00000001051b9518 -[PMPlugin handleMethodResultHandler:manager:notificationManager:] + 2388 (PMPlugin.m:437)
13  photo_manager                 	0x00000001051b8b68 __19-[PMPlugin onAuth:]_block_invoke + 40 (PMPlugin.m:376)
14  libdispatch.dylib             	0x00000001990a913c _dispatch_call_block_and_release + 32 (init.c:1530)
15  libdispatch.dylib             	0x00000001990aadd4 _dispatch_client_callout + 20 (object.m:576)
16  libdispatch.dylib             	0x00000001990bca6c _dispatch_root_queue_drain + 864 (queue.c:7136)
17  libdispatch.dylib             	0x00000001990bd09c _dispatch_worker_thread2 + 156 (queue.c:7204)
18  libsystem_pthread.dylib       	0x00000001edc548f8 _pthread_wqthread + 228 (pthread.c:2709)
19  libsystem_pthread.dylib       	0x00000001edc510cc start_wqthread + 8 (:-1)

Example code (optional)

Contact

No response

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions