SDWebImageSwiftUI: WebImage Instantly crashes on load when inside a TabView
When used inside a TabView, any loading of a WebImage will immediately cause a crash. Here is the code that causes the crash:
TabView {
Text("testing")
.tabItem {
Text("test")
}
WebImage(url: URL(string: "https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/SDWebImage_logo.png"))
.tabItem {
Text("test2")
}
}
I am using Xcode 12.0 with iOS 14.0, with SDWebImage 5.9.0 and SDWebImageSwiftUI 1.5.0.
Below is the stack trace:
#0 0x00000001b30dcc64 in AG::AttributeID::size() const () #1 0x00000001b30d0b2c in AG::Graph::add_indirect_attribute(AG::Subgraph&, AG::AttributeID, unsigned long, std::__1::optional<unsigned long>, bool) () #2 0x00000001b30e2fe8 in (anonymous namespace)::create_indirect_attribute(unsigned int, std::__1::optional<unsigned long>) () #3 0x00000001926b5bf4 in partial apply for thunk for @callee_guaranteed () -> (@unowned IndirectAttribute) () #4 0x00000001926b5a24 in closure #1 in AGSubgraphRef.apply(_๐ () #5 0x00000001926b5818 in Attribute.makeReusable(indirectMap:) () #6 0x00000001926b1fd0 in closure #1 in closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #7 0x00000001923fd324 in closure #1 in closure #1 in PlaceholderInfo.makeItem(placeholder:seed:) () #8 0x0000000192525784 in thunk for @callee_guaranteed (@in_guaranteed _ViewInputs, @guaranteed @escaping @callee_guaranteed (@in_guaranteed _ViewInputs) -> (@out _ViewOutputs)) -> (@out _ViewOutputs?) () #9 0x00000001926ad49c in closure #1 in closure #1 in _ViewList_Elements.makeOneElement(at:inputs:indirectMap:body:) () #10 0x00000001926b7d58 in partial apply for thunk for @callee_guaranteed (@in_guaranteed _ViewInputs, @guaranteed @escaping @callee_guaranteed (@in_guaranteed _ViewInputs) -> (@out _ViewOutputs)) -> (@out _ViewOutputs?, @unowned Bool) () #11 0x00000001926b1e78 in closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #12 0x00000001926b7d94 in partial apply for closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #13 0x00000001926b7d58 in partial apply for thunk for @callee_guaranteed (@in_guaranteed _ViewInputs, @guaranteed @escaping @callee_guaranteed (@in_guaranteed _ViewInputs) -> (@out _ViewOutputs)) -> (@out _ViewOutputs?, @unowned Bool) () #14 0x00000001926b1e78 in closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #15 0x00000001926b7d94 in partial apply for closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #16 0x00000001926b7d58 in partial apply for thunk for @callee_guaranteed (@in_guaranteed _ViewInputs, @guaranteed @escaping @callee_guaranteed (@in_guaranteed _ViewInputs) -> (@out _ViewOutputs)) -> (@out _ViewOutputs?, @unowned Bool) () #17 0x00000001926b1e78 in closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #18 0x00000001926b7d94 in partial apply for closure #1 in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #19 0x00000001926afe78 in UnaryElements.makeElements(from:inputs:indirectMap:body:) () #20 0x00000001926b3350 in SubgraphElements.makeElements(from:inputs:indirectMap:body:) () #21 0x00000001926b1d5c in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #22 0x00000001926b1c28 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #23 0x00000001926b1d5c in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #24 0x00000001926b1c28 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #25 0x00000001926b1d5c in closure #1 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #26 0x00000001926b1c28 in ModifiedElements.makeElements(from:inputs:indirectMap:body:) () #27 0x00000001926b3350 in SubgraphElements.makeElements(from:inputs:indirectMap:body:) () #28 0x00000001926ad420 in closure #1 in ViewList_Elements.makeOneElement(at:inputs:indirectMap:body:) () #29 0x00000001923fcedc in closure #1 in PlaceholderInfo.makeItem(placeholder:seed:) () #30 0x00000001923fc984 in PlaceholderInfo.updateValue() () #31 0x00000001920d83e4 in partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init(๐ () #32 0x00000001b30cc194 in AG::Graph::UpdateStack::update() () #33 0x00000001b30cc5c8 in AG::Graph::update_attribute(AG::data::ptrAG::Node, bool) () #34 0x00000001b30d5728 in AG::Subgraph::update(unsigned int) () #35 0x0000000192738af4 in GraphHost.runTransaction() () #36 0x000000019224d780 in ViewGraph.updateOutputs(at:) () #37 0x000000019269604c in closure #1 in ViewRendererHost.render(interval:updateDisplayList:) () #38 0x0000000192695274 in ViewRendererHost.render(interval:updateDisplayList:) () #39 0x000000019214d748 in closure #1 in _UIHostingView.requestImmediateUpdate() () #40 0x0000000192801ec0 in thunk for @escaping @callee_guaranteed () -> () () #41 0x00000001050f3b68 in _dispatch_call_block_and_release () #42 0x00000001050f55f0 in _dispatch_client_callout () #43 0x0000000105104890 in dispatch_main_queue_callback_4CF () #44 0x000000018b9731e4 in CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE () #45 0x000000018b96d3b4 in __CFRunLoopRun () #46 0x000000018b96c4bc in CFRunLoopRunSpecific () #47 0x00000001a23f1820 in GSEventRunModal () #48 0x000000018e310734 in -[UIApplication run] () #49 0x000000018e315e10 in UIApplicationMain () #50 0x00000001926cd32c in closure #1 in KitRendererCommon(๐ () #51 0x00000001926cd2b8 in runApp(๐ () #52 0x0000000192246b08 in static App.main() () #53 0x0000000104c130b4 in static SDWebImageTestCrashApp.$main() () #54 0x0000000104c13154 in main () #55 0x000000018b633e60 in start ()
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (1 by maintainers)
Iโm also experiencing the AGGraph::getValue() crash but not inside a TabView. The images are in a SwiftUI List view. Wrapping them in an empty VStack or HStack didnโt help.
Should be fixed in v2.0.2
However, I strongly recommended donโt use
WebImageas the top level View component. Wrap it inside List, HStack is a better idea.Since the layout of
Web URLcan not have theintrinsicContentSize(Which may changed when loading image from network). So youโd better provide theframemodifier to limit it container size.