SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.09k stars 214 forks source link

Unit test crash on macOS 12 with `Attempted to read an unowned reference but object 0x12345 was already deallocated` #286

Closed dreampiggy closed 7 months ago

dreampiggy commented 7 months ago

This is happended in #285

The crash does not exists on macOS 13 or 14...Only 12. The crash does not exists on watchOS / iOS / tvOS , only macOS 12...

Hope @Kyle-Ye can help for this.

Reproduce

  1. branch: feature/export_animated_image_view_type
  2. pod install
  3. Open SDWebImageSwiftUI.xcworkspace
  4. Run testAnimatedImageWithData
Kyle-Ye commented 7 months ago

Have a macOS 12 device on hand. You can add me as "Assignees" and I'll give it a try tonight.

Kyle-Ye commented 7 months ago

There is some env problem installing cocoapods in my env.

And I tried my best to reproduce it under SwiftPM env. (Add testTarget, specify path, fix the resource bundle issue, update swift version etc.)

~But due to my env is macOS 12.7.1 + Xcode 13.4.1, the max version I can set is Swift 5.6. So I can only use 0.9.2 version of ViewInspector package.~

~Under such condition, there is no crash and I can't reproduce it.~

I see your xcworkspace in CI is also using ViewInspector: https://github.com/nalexn/ViewInspector.git @ 0.9.2. And the CI env is macOS 12.7.1 + Xcode 14.1.

I guess Xcode SDK is what makes it different. I'll install it and try it again later.

Kyle-Ye commented 7 months ago

Run it through CLI via /Applications/Xcode-14.1.0.app/Contents/Developer/usr/bin/xcodebuild clean -workspace SDWebImageSwiftUI.xcworkspace -scheme "SDWebImageSwiftUITests macOS" -destination platform=macOS,arch=arm64 -configuration Debug CODE_SIGNING_ALLOWED=NO reproduced the CI crash issue.

Here is my local crash report.

SDWebImageSwiftUIDemo-macOS-2023-11-30-230327.ips.zip

However after this crash build, I can't reproduce it again even with a clean build.

dreampiggy commented 7 months ago

This does not effect real usage on macOS 12 Mac. Change to use macOS 13 on github ci and no issues...