I tried uploading 4 images to the media library and tapped to cancel while they were uploading. The app didn't crash but I saw this in the console (main thread checker plus several file errors):
Main Thread Checker: UI API called on a background thread: -[UICollectionView reloadData]
PID: 10809, TID: 2990027, Thread name: (none), Queue name: NSManagedObjectContext 0x1d41cbc70, QoS: 0
Backtrace:
4 WordPress 0x0000000101813be0 _T09WordPress26MediaLibraryViewControllerC17unpauseDataSource33_A7F934FBB1204E78EA852DA00FE84F51LLyyF + 612
5 WordPress 0x00000001018140a0 _T09WordPress26MediaLibraryViewControllerC06uploadC033_A7F934FBB1204E78EA852DA00FE84F51LLySo0C0CSg_s5Error_pSg5errorSS7mediaIDtFysAI_pcfU0_ + 196
6 WordPress 0x00000001012e3974 _T0s5Error_pIxx_So7NSErrorCIyBy_TR + 72
7 WordPress 0x0000000101166f20 __53-[MediaService uploadMedia:progress:success:failure:]_block_invoke_2.132 + 436
8 CoreData 0x0000000185062c48 <redacted> + 156
9 libdispatch.dylib 0x000000010491528c _dispatch_client_callout + 16
10 libdispatch.dylib 0x0000000104923f80 _dispatch_queue_serial_drain + 696
11 libdispatch.dylib 0x00000001049187ec _dispatch_queue_invoke + 332
12 libdispatch.dylib 0x0000000104924f6c _dispatch_root_queue_drain_deferred_wlh + 428
13 libdispatch.dylib 0x000000010492c020 _dispatch_workloop_worker_thread + 652
14 libsystem_pthread.dylib 0x0000000182422f1c _pthread_wqthread + 932
15 libsystem_pthread.dylib 0x0000000182422b6c start_wqthread + 4
2017-12-14 10:13:48.541146+0100 WordPress[10809:2990027] [reports] Main Thread Checker: UI API called on a background thread: -[UICollectionView reloadData]
PID: 10809, TID: 2990027, Thread name: (none), Queue name: NSManagedObjectContext 0x1d41cbc70, QoS: 0
Backtrace:
4 WordPress 0x0000000101813be0 _T09WordPress26MediaLibraryViewControllerC17unpauseDataSource33_A7F934FBB1204E78EA852DA00FE84F51LLyyF + 612
5 WordPress 0x00000001018140a0 _T09WordPress26MediaLibraryViewControllerC06uploadC033_A7F934FBB1204E78EA852DA00FE84F51LLySo0C0CSg_s5Error_pSg5errorSS7mediaIDtFysAI_pcfU0_ + 196
6 WordPress 0x00000001012e3974 _T0s5Error_pIxx_So7NSErrorCIyBy_TR + 72
7 WordPress 0x0000000101166f20 __53-[MediaService uploadMedia:progress:success:failure:]_block_invoke_2.132 + 436
8 CoreData 0x0000000185062c48 <redacted> + 156
9 libdispatch.dylib 0x000000010491528c _dispatch_client_callout + 16
10 libdispatch.dylib 0x0000000104923f80 _dispatch_queue_serial_drain + 696
11 libdispatch.dylib 0x00000001049187ec _dispatch_queue_invoke + 332
12 libdispatch.dylib 0x0000000104924f6c _dispatch_root_queue_drain_deferred_wlh + 428
13 libdispatch.dylib 0x000000010492c020 _dispatch_workloop_worker_thread + 652
14 libsystem_pthread.dylib 0x0000000182422f1c _pthread_wqthread + 932
15 libsystem_pthread.dylib 0x0000000182422b6c start_wqthread + 4
2017-12-14 10:13:54:859 WordPress[10809:2990212] Error occurred importing to Media with system error, code: 516, error: Error Domain=NSCocoaErrorDomain Code=516 "“img_0221.jpeg” no se ha podido trasladar a “Media” porque ya existe un ítem con el mismo nombre." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Containers/Data/Application/59F6C54D-647B-4208-989F-9B2DE0E579CC/Library/Caches/Media/img_0221.jpeg, NSUserStringVariant=(
Move
), NSDestinationFilePath=/var/mobile/Containers/Data/Application/59F6C54D-647B-4208-989F-9B2DE0E579CC/Library/Caches/Media/thumbnail-9a5f5fe3-d83c-4ba7-94a6-14bbc19ddb53-372x372.jpeg, NSFilePath=/var/mobile/Containers/Data/Application/59F6C54D-647B-4208-989F-9B2DE0E579CC/Library/Caches/Media/img_0221.jpeg, NSUnderlyingError=0x1c405ede0 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}}
2017-12-14 10:13:54:859 WordPress[10809:2990028] Error occurred importing to Media with system error, code: 516, error: Error Domain=NSCocoaErrorDomain Code=516 "“img_0224.jpeg” no se ha podido trasladar a “Media” porque ya existe un ítem con el mismo nombre." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Containers/Data/Application/59F6C54D-647B-4208-989F-9B2DE0E579CC/Library/Caches/Media/img_0224.jpeg, NSUserStringVariant=(
Move
), NSDestinationFilePath=/var/mobile/Containers/Data/Application/59F6C54D-647B-4208-989F-9B2DE0E579CC/Library/Caches/Media/thumbnail-13533556-5be6-4616-9b96-a1c4228eca7c-372x372.jpeg, NSFilePath=/var/mobile/Containers/Data/Application/59F6C54D-647B-4208-989F-9B2DE0E579CC/Library/Caches/Media/img_0224.jpeg, NSUnderlyingError=0x1d505ef30 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}}
2017-12-14 10:14:00.088163+0100 WordPress[10809:2990027] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
Stack:(
0 Foundation 0x000000018330f248 <redacted> + 96
1 Foundation 0x000000018330ef2c <redacted> + 76
2 Foundation 0x000000018313ece0 <redacted> + 132
3 Foundation 0x000000018330d034 <redacted> + 112
4 UIKit 0x000000018bfca264 <redacted> + 172
5 UIKit 0x000000018bcdcf48 <redacted> + 1348
6 QuartzCore 0x0000000186841998 <redacted> + 184
7 QuartzCore 0x0000000186845b20 <redacted> + 332
8 QuartzCore 0x00000001867b236c <redacted> + 336
9 QuartzCore 0x00000001867d9b90 <redacted> + 540
10 QuartzCore 0x00000001867da278 <redacted> + 244
11 libsystem_pthread.dylib 0x00000001824235e4 <redacted> + 572
12 libsystem_pthread.dylib 0x0000000182423334 <redacted> + 88
13 libsystem_pthread.dylib 0x00000001824230b4 _pthread_wqthread + 1340
14 libsystem_pthread.dylib 0x0000000182422b6c start_wqthread + 4
)
2017-12-14 10:14:00.092008+0100 WordPress[10809:2990027] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
Stack:(
0 Foundation 0x000000018330f248 <redacted> + 96
1 Foundation 0x000000018330ef2c <redacted> + 76
2 Foundation 0x000000018313ece0 <redacted> + 132
3 Foundation 0x000000018330d034 <redacted> + 112
4 UIKit 0x000000018bcdd1bc <redacted> + 1976
5 QuartzCore 0x0000000186841998 <redacted> + 184
6 QuartzCore 0x0000000186845b20 <redacted> + 332
7 QuartzCore 0x00000001867b236c <redacted> + 336
8 QuartzCore 0x00000001867d9b90 <redacted> + 540
9 QuartzCore 0x00000001867da278 <redacted> + 244
10 libsystem_pthread.dylib 0x00000001824235e4 <redacted> + 572
11 libsystem_pthread.dylib 0x0000000182423334 <redacted> + 88
12 libsystem_pthread.dylib 0x00000001824230b4 _pthread_wqthread + 1340
13 libsystem_pthread.dylib 0x0000000182422b6c start_wqthread + 4
)
Raising in priority because error message handling came up recently from the Mobile Guild as an ongoing problem.
@shiki the file errors in this issue looks similar to https://github.com/wordpress-mobile/WordPress-iOS/issues/12143 to me. However, the issue here has slightly different steps and mentions "Error occurred importing to Media with system error, code: 516". Still, do you think solving https://github.com/wordpress-mobile/WordPress-iOS/issues/12143 will solve this issue as well?
(internal reference: 2275839-zen reports seeing similar local file references to the ones showing in the logs here except they tried uploading images while on a poor network connection in an airport)
@designsimply I believe this is not related to #12143.
I retested this issue and this is no longer happening. The original issue reported that updates on the UI were being done outside the main thread.
The code now guarantees that media state change callbacks are now done on the main thread so this no longer happens.
Most helpful comment
I retested this issue and this is no longer happening. The original issue reported that updates on the UI were being done outside the main thread.
The code now guarantees that media state change callbacks are now done on the main thread so this no longer happens.