Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求助怎么修复卡顿 #2343

Closed
HaoRuizhi opened this issue Mar 15, 2024 · 6 comments
Closed

求助怎么修复卡顿 #2343

HaoRuizhi opened this issue Mar 15, 2024 · 6 comments

Comments

@HaoRuizhi
Copy link

Thread 0:
0 libsystem_kernel.dylib 0x1de0610f4 0x1de060000 + 4340
1 libdispatch.dylib 0x19e95af4c 0x19e956000 + 20300
2 CFNetwork 0x197a395cc 0x197a35000 + 17868
3 CFNetwork 0x197af988c 0x197a35000 + 805004
4 Foundation 0x19598b9a4 0x1958f8000 + 604580
5 AppName NSData.init(contentsOf:options:) (in AppName) 96
6 AppName FilepathImageProvider.imageForAsset(asset:) (in AppName) 312
7 AppName AnimationImageProvider.imageForAsset(asset:)AnimationImageProvider (in AppName) 20
8 AppName CachedImageProvider.imageForAsset(asset:) (in AppName) 132
9 AppName AnimationImageProvider.imageForAsset(asset:)AnimationImageProvider (in AppName) 20
10 AppName ImageLayer.setupImage(context:) (in AppName) 180
11 AppName LayerModel.makeAnimationLayer(context:) (in AppName) 516
12 AppName CALayer.setupLayerHierarchy(for:context:) (in AppName) 280
13 AppName PreCompLayer.setup(context:) (in AppName) 304
14 AppName LayerModel.makeAnimationLayer(context:) (in AppName) 296
15 AppName CALayer.setupLayerHierarchy(for:context:) (in AppName) 280
16 AppName CoreAnimationLayer.setupChildLayers() (in AppName) 252
17 AppName CoreAnimationLayer.init(animation:imageProvider:textProvider:fontProvider:compatibilityTrackerMode:logger:) (in AppName) 556
18 AppName LottieAnimationView.makeAutomaticEngineLayer(for:) (in AppName) 336
19 AppName LottieAnimationView.makeAnimationLayer(usingEngine:) (in AppName) 160
20 AppName _$s6Lottie0A13AnimationViewC9animation13imageProvider04textF004fontF013configuration6loggerAcA0aB0CSg_AA0b5ImageF0_pSgAA0b4TextF0_pAA0b4FontF0_pAA0A13ConfigurationVAA0A6LoggerCtcfcTf4nneennn_nAA07DefaultlF0C_AA0pmF0CTB5 (in AppName) 1004
21 AppName LottieAnimationView.__allocating_init(filePath:imageProvider:animationCache:configuration:) (in AppName) 944
以上是具体堆栈信息
卡顿点事NSData.init(contentsOf:options:) 调用是在主线程调用的,大家有遇到过这种问题不

@calda
Copy link
Member

calda commented Mar 15, 2024

Please share a sample project that reproduces this error

Copy link

This issue is stale because it is marked "can't reproduce" and has had no activity in the past week. Please comment with additional information, or this issue will be closed due to inactivity in one week.

@github-actions github-actions bot added the Stale label Mar 23, 2024
@supergithuber
Copy link

Thread 0: 0 libsystem_kernel.dylib 0x1de0610f4 0x1de060000 + 4340 1 libdispatch.dylib 0x19e95af4c 0x19e956000 + 20300 2 CFNetwork 0x197a395cc 0x197a35000 + 17868 3 CFNetwork 0x197af988c 0x197a35000 + 805004 4 Foundation 0x19598b9a4 0x1958f8000 + 604580 5 AppName NSData.init(contentsOf:options:) (in AppName) 96 6 AppName FilepathImageProvider.imageForAsset(asset:) (in AppName) 312 7 AppName AnimationImageProvider.imageForAsset(asset:)AnimationImageProvider (in AppName) 20 8 AppName CachedImageProvider.imageForAsset(asset:) (in AppName) 132 9 AppName AnimationImageProvider.imageForAsset(asset:)AnimationImageProvider (in AppName) 20 10 AppName ImageLayer.setupImage(context:) (in AppName) 180 11 AppName LayerModel.makeAnimationLayer(context:) (in AppName) 516 12 AppName CALayer.setupLayerHierarchy(for:context:) (in AppName) 280 13 AppName PreCompLayer.setup(context:) (in AppName) 304 14 AppName LayerModel.makeAnimationLayer(context:) (in AppName) 296 15 AppName CALayer.setupLayerHierarchy(for:context:) (in AppName) 280 16 AppName CoreAnimationLayer.setupChildLayers() (in AppName) 252 17 AppName CoreAnimationLayer.init(animation:imageProvider:textProvider:fontProvider:compatibilityTrackerMode:logger:) (in AppName) 556 18 AppName LottieAnimationView.makeAutomaticEngineLayer(for:) (in AppName) 336 19 AppName LottieAnimationView.makeAnimationLayer(usingEngine:) (in AppName) 160 20 AppName _$s6Lottie0A13AnimationViewC9animation13imageProvider04textF004fontF013configuration6loggerAcA0aB0CSg_AA0b5ImageF0_pSgAA0b4TextF0_pAA0b4FontF0_pAA0A13ConfigurationVAA0A6LoggerCtcfcTf4nneennn_nAA07DefaultlF0C_AA0pmF0CTB5 (in AppName) 1004 21 AppName LottieAnimationView.__allocating_init(filePath:imageProvider:animationCache:configuration:) (in AppName) 944 以上是具体堆栈信息 卡顿点事NSData.init(contentsOf:options:) 调用是在主线程调用的,大家有遇到过这种问题不

same issue as you

@supergithuber
Copy link

supergithuber commented Mar 29, 2024

Please share a sample project that reproduces this error

to_keyboard.json

When loading the lottie's JSON above, it will block the main thread of app more than ten seconds.

sample code:
let view = LottieAnimationView(name: "to_keyboard")
view.play()

@calda
Copy link
Member

calda commented Apr 15, 2024

I tested this locally and I see that the performance issue happens in a debug build, but not in a release build.

That suggests this is some sort of pathological performance issue in the Swift compiler (e.g. the compiler not generating properly optimized code in debug, or something) rather than a problem in Lottie itself.

If you have repro steps for this that show performances issues in a release build as well, feel free to re-open the issue.

@calda calda closed this as completed Apr 15, 2024
@liuyongjiesail
Copy link

LottieView.init {
.named("cleanup_complete")
} placeholder: {
ProgressView()
}
.playing()

SwiftUI 使用异步加载方式可以解决同步加载大文件导致的卡顿问题

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

No branches or pull requests

4 participants