stephan-tolksdorf / stulabel Goto Github PK
View Code? Open in Web Editor NEWA faster and more flexible label view for iOS
License: Other
A faster and more flexible label view for iOS
License: Other
Hey! We've been testing this framework on a few text-heavy screen for a while now without any issues, however, on our last update, we seem to have introduced this type of crash for a decent number of users. Haven't been able to reproduce this myself yet but will update this thread if I do.
Update:
Seems to be related to the STUBackgroundAttribute and happens only on release builds.
#0. Crashed: com.apple.main-thread
0 STULabel 0x101e6cde0 stu_label::LabelLayer::removeContentCGImagesOfLabelLayersWithoutWindow() + 1722 (STULabelLayer.mm:1722)
1 Foundation 0x182975b64 -[__NSObserver _doit:] + 316
2 CoreFoundation 0x1825f2288 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
3 CoreFoundation 0x1825f22d0 ___CFXRegistrationPost1_block_invoke + 64
4 CoreFoundation 0x1825f1630 _CFXRegistrationPost1 + 368
5 CoreFoundation 0x1825f12e8 ___CFXNotificationPost_block_invoke + 104
6 CoreFoundation 0x18256d59c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1416
7 CoreFoundation 0x1825f0c38 _CFXNotificationPost + 1244
8 Foundation 0x18294d0c8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
9 UIKitCore 0x186721ec4 __47-[UIApplication _applicationDidEnterBackground]_block_invoke + 312
10 UIKitCore 0x18610f154 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
11 UIKitCore 0x186721c80 -[UIApplication _applicationDidEnterBackground] + 116
12 UIKitCore 0x185ee80e4 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 + 856
13 UIKitCore 0x18637d698 _UIScenePerformActionsWithLifecycleActionMask + 100
14 UIKitCore 0x185ee7cf0 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 196
15 UIKitCore 0x185ee7748 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296
16 UIKitCore 0x185ee7b1c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 736
17 UIKitCore 0x185ee73d8 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336
18 UIKitCore 0x185eeb8c4 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 188
19 UIKitCore 0x1862aef08 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 824
20 UIKitCore 0x186396c84 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244
21 UIKitCore 0x185eeb5fc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 136
22 UIKitCore 0x186396b80 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 100
23 UIKitCore 0x185eeb468 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 376
24 UIKitCore 0x185d5d2c0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 636
25 UIKitCore 0x185d5be28 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248
26 UIKitCore 0x185d5cff8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
27 UIKitCore 0x1862cfd70 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464
28 FrontBoardServices 0x1877ca248 -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] + 544
29 FrontBoardServices 0x1877eed28 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 + 120
30 FrontBoardServices 0x1877d3f04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
31 FrontBoardServices 0x1877eec5c __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke + 184
32 libdispatch.dylib 0x182363184 _dispatch_client_callout + 16
33 libdispatch.dylib 0x18230bfd8 _dispatch_block_invoke_direct$VARIANT$mp + 224
34 FrontBoardServices 0x187813418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
35 FrontBoardServices 0x1878130e4 -[FBSSerialQueue _queue_performNextIfPossible] + 404
36 FrontBoardServices 0x18781360c -[FBSSerialQueue _performNextFromRunLoopSource] + 28
37 CoreFoundation 0x182614a00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
38 CoreFoundation 0x182614958 __CFRunLoopDoSource0 + 80
39 CoreFoundation 0x1826140f0 __CFRunLoopDoSources0 + 180
40 CoreFoundation 0x18260f23c __CFRunLoopRun + 1080
41 CoreFoundation 0x18260eadc CFRunLoopRunSpecific + 464
42 GraphicsServices 0x18c5af328 GSEventRunModal + 104
43 UIKitCore 0x18671c63c UIApplicationMain + 1936
Attached is the demo project with the changed TapToReadMoreVC class in an attempt to change the link color. Is there any way we can change link colors?
STULabel-master.zip
So I've been messing about with things a bunch recently, specifically using STULabel with both Texture (AsyncDisplayKit) and SwiftUI, and I've noticed there's a pretty wonky crash happening with the KVO stuff as part of STULabelSuperlayerObserver
.
Basically, it's getting into a state where STULabelLayer
's -dealloc
is being invoked, which is causing STULabelSuperlayerObserver
's -dealloc
to be invoked, which'll crash since it's trying to remove observers on an object that's already been deallocated (rather than having the STULabelSuperlayerObserver
explicitly torn down / removed beforehand).
What's the purpose of STULabelSuperlayerObserver
/ does it need to be used?
I've been messing a bunch with this trying to fix it, and it seems to only happen once I present a View Controller (containing an STULabel wrapped in a ScrollView), and then later dismiss it. Changing the _layer
to not be __unsafe_unretained
mitigates the issue, but then also causes all STULabel
s to never release lol
Hey. Time to time App is crashing. Can you help me?
#0 0x000000018d689f6c in objc_exception_throw ()
#1 0x000000018d863c4c in +[NSException raise:format:arguments:] ()
#2 0x000000018dce80d4 in -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] ()
#3 0x0000000102c64e8c in stu_assertion_failed at /STULabel/STULabel/Internal/stu/Assert.m:36
#4 0x0000000102cec6f4 in stu_label::LabelRenderTask::assignResultTo(stu_label::LabelLayer&) at /STULabel/STULabel/STULabelLayer.mm:1805
#5 0x0000000102cf114c in stu_label::LabelLayer::configureWithPrerenderer(STULabelPrerenderer*) at /STULabel/STULabel/STULabelLayer.mm:1108
#6 0x0000000102cf0488 in ::-[STULabelLayer configureWithPrerenderer:](STULabelPrerenderer *) at /STULabel/STULabel/STULabelLayer.mm:2012
#7 0x0000000102ce60f8 in ::-[STULabel configureWithPrerenderer:](STULabelPrerenderer *) at /STULabel/STULabel/STULabel.mm:2251
#8 0x000000010121b6cc in PostCell.setup(post:sizing:) at /Views/Cells/PostCell.swift:237
#9 0x0000000101011200 in PostsListViewController.tableView(_:cellForRowAt:) at /Controllers/PostsListViewController.swift:273
#10 0x0000000101011cf0 in @objc PostsListViewController.tableView(_:cellForRowAt:) ()
#11 0x0000000191bafc88 in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] ()
#12 0x0000000191bb01f8 in -[UITableView _createPreparedCellForRowAtIndexPath:willDisplay:] ()
#13 0x0000000191bbbb48 in -[UITableView _heightForRowAtIndexPath:] ()
#14 0x0000000191bc91dc in -[UISectionRowData heightForRow:inSection:canGuess:] ()
#15 0x0000000191bce50c in -[UITableViewRowData heightForRow:inSection:canGuess:adjustForReorderedRow:] ()
#16 0x0000000191bcfd14 in -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:] ()
#17 0x0000000191bcfee8 in -[UITableViewRowData rectForGlobalRow:heightCanBeGuessed:] ()
#18 0x0000000191b8dfa4 in -[UITableView _contentOffsetYForRestoringScrollPositionOfFirstVisibleRowWithContentInsetTop:canGuessHeights:] ()
#19 0x0000000191b7cb5c in -[UITableView _updateVisibleCellsNow:] ()
#20 0x0000000191b9a510 in -[UITableView layoutSubviews] ()
#21 0x0000000191e5f604 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#22 0x00000001943ad78c in -[CALayer layoutSublayers] ()
#23 0x00000001943b3908 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#24 0x00000001943be528 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#25 0x0000000194306ed0 in CA::Context::commit_transaction(CA::Transaction*, double) ()
#26 0x0000000194330bbc in CA::Transaction::commit() ()
#27 0x00000001943315b0 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
#28 0x000000018d8dec2c in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#29 0x000000018d8d9b18 in __CFRunLoopDoObservers ()
#30 0x000000018d8da0e4 in __CFRunLoopRun ()
#31 0x000000018d8d98a0 in CFRunLoopRunSpecific ()
#32 0x0000000197831328 in GSEventRunModal ()
#33 0x00000001919ca740 in UIApplicationMain ()
#34 0x000000010124875c in main at /AppDelegate.swift:18
Faced such an error. It would be nice to find a solution to this problem.
It is not possible to determine the case, I have never shown it. However, users get it quite often (on different versions of iOS and smartphone models)
Crashed: Thread
EXC_BREAKPOINT 0x0000000000000001
0 STULabel stu_label::FontFaceGlyphBoundsCache::boundingRect(double, stu::ArrayRef, CGPoint const*) + 3684 (Font.mm)
1 STULabel ThreadLocalAllocatorRef + 4 [inlined] (ThreadLocalAllocator.hpp:68)
2 STULabel ThreadLocalAllocatorRef + 4 [inlined] (ThreadLocalAllocator.hpp:69)
3 STULabel TempVector + 28 [inlined] (ThreadLocalAllocator.hpp:119)
4 STULabel TempVector + 28 [inlined] (ThreadLocalAllocator.hpp:122)
5 STULabel stu_label::FontFaceGlyphBoundsCache::boundingRect(double, stu::ArrayRef, CGPoint const*) + 96 (Font.mm:522)
6 STULabel stu_label::GlyphSpan::imageBoundsImpl(stu_label::GlyphRunRef, CFRange, stu_label::LocalGlyphBoundsCache&) + 64 (GlyphSpan.mm:47)
7 STULabel isEmpty + 0 [inlined] (Rect.hpp:339)
8 STULabel operator() + 48 [inlined] (TextFrameLine-ImageBounds.mm:185)
9 STULabel call<(lambda at /STULabel/Internal/TextFrameLine-ImageBounds.mm:180:5)> + 88 (FunctionRef.hpp:209)
10 STULabel stu_label::TextFrameLine::forEachCTLineSegment(stu_label::FlagsRequiringIndividualRunIteration, stu::FunctionRef<stu_label::ShouldStop (stu_label::TextLinePart, stu_label::CTLineXOffset, __CTLine const&, stu::Optional<stu_label::GlyphSpan>)>) const + 520 (TextFrameLine-GlyphSpanIteration.mm:37)
11 STULabel calculateLineGlyphPathBoundsLLO + 44 [inlined] (TextFrameLine-ImageBounds.mm:191)
12 STULabel calculateLineImageBoundsLLO + 108 [inlined] (TextFrameLine-ImageBounds.mm:219)
13 STULabel stu_label::TextFrameLine::calculateImageBoundsLLO(stu_label::ImageBoundsContext const&) const + 392 (TextFrameLine-ImageBounds.mm:472)
14 STULabel stu_label::TextFrame::calculateImageBounds(stu_label::TextFrameOrigin, stu_label::ImageBoundsContext const&) const + 352 (TextFrame.mm:380)
15 STULabel STUTextFrameGetImageBoundsForRange(STUTextFrame const*, STUTextFrameRange, CGPoint, double, STUTextFrameDrawingOptions const*, STUCancellationFlag const*) + 568 (STUTextFrame.mm)
16 STULabel inverseValue_f64 + 0 [inlined] (DisplayScaleRounding.hpp:68)
17 STULabel inverseValue + 0 [inlined] (DisplayScaleRounding.hpp:54)
18 STULabel stu_label::labelTextFrameRenderInfo(STUTextFrame const*, stu_label::LabelTextFrameInfo const&, CGPoint const&, stu_label::LabelParameters const&, bool, bool, STUCancellationFlag const*) + 224 (LabelRendering.mm:130)
19 STULabel stu_label::LabelLayer::display() + 588 (STULabelLayer.mm:1155)
20 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 416
21 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 416
22 QuartzCore CA::Transaction::commit() + 728
23 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
24 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32
25 CoreFoundation __CFRunLoopDoObservers + 604
26 CoreFoundation __CFRunLoopRun + 960
27 CoreFoundation CFRunLoopRunSpecific + 572
28 GraphicsServices GSEventRunModal + 160
29 UIKitCore -[UIApplication _run] + 1052
30 UIKitCore UIApplicationMain + 164
31 MyApplication main + 88 (main.m:14)
32 libdyld.dylib start + 4
Also filed with Apple as FB14703057 (Deadlock in UIKit while injecting test bundle).
Steps to repro:
Actual behavior:
Tests fail to launch due to deadlock
Expected behavior:
Tests run
--
Deadlock occurs inside of the UIScreen.mainScreen
access initiated by +load
added in the category on UIScreen.
I am using Xcode 14.3 and M1 Pro Machine.
its giving me 2 errors
I'm using Xcode 13.4 and this Error Occurs :
Pods/STULabel/STULabel/STUTextLink.mm:443:8: Declaration of 'atomic' must be imported from module 'std.atomic' before it is required
I need 9.0! thank sir
Some new C++ stuff seems to have been changed but I don't really understand a lot of the template stuff you wrote :P
Any chance you could take a look?
Thanks!
STULabel/STULabel/Internal/NSStringRef.hpp:105:41: note: in instantiation of exception specification for 'operator _NSRange<_NSRange, unsigned long, 0>' requested here
copyUTF16Chars_slowPath(NSRange(utf16IndexRange), out.begin());
M1 iMac
XCode 13.4
Always throws error during build. Removing derived data doesn't fix it. Building directly in Xcode works fine, only happens in Xcodebuild. Removing STULabel lets build succeed.
/Users/MyUser/Library/Developer/Xcode/DerivedData/bb-iphone-gxoeyvvbhtizhsemkonoptlbnczq/Build/Intermediates.noindex/ArchiveIntermediates/bb-iphone/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/STULabel.build/Objects-normal/arm64/STUTextFrameLine.dia:1:1: warning: Could not read serialized diagnostics file: error("Failed to open diagnostics file") (in target 'STULabel' from project 'Pods')
Using the cocoa pod, the project wont build, i get this error:
In file included from /Volumes/data/dev/nativescript/nativescript-label/dev_demo/platforms/ios/Pods/STULabel/STULabel/STUTextHighlightStyle-Internal.hpp:5:
/Volumes/data/dev/nativescript/nativescript-label/dev_demo/platforms/ios/Pods/STULabel/STULabel/Internal/TextStyle.hpp:178:12: error: no matching constructor for initialization of
'stu_label::UnderlineStyle'
return {static_cast<UInt16>(style_ & ~underlineMinYIsStrictBit)};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/data/dev/nativescript/nativescript-label/dev_demo/platforms/ios/Pods/STULabel/STULabel/Internal/TextStyle.hpp:86:8: note: candidate constructor (the implicit move constructor)
not viable: no known conversion from 'stu::UInt16' (aka 'unsigned short') to 'stu_label::UnderlineStyle' for 1st argument
struct UnderlineStyle : Parameter<UnderlineStyle, UInt16> {
^
/Volumes/data/dev/nativescript/nativescript-label/dev_demo/platforms/ios/Pods/STULabel/STULabel/Internal/TextStyle.hpp:86:8: note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from 'stu::UInt16' (aka 'unsigned short') to 'const stu_label::UnderlineStyle' for 1st argument
struct UnderlineStyle : Parameter<UnderlineStyle, UInt16> {
^
/Volumes/data/dev/nativescript/nativescript-label/dev_demo/platforms/ios/Pods/STULabel/STULabel/Internal/TextStyle.hpp:88:3: note: candidate constructor not viable: no known conversion
from 'stu::UInt16' (aka 'unsigned short') to 'NSUnderlineStyle' for 1st argument
UnderlineStyle(NSUnderlineStyle underlineStyle = {})
^
Can you help?
Would it be possible to make this a swift package?
Compiler error on Xcode 12:
Reference to 'Byte' is ambiguous
in 5 places.
Pods/STULabel/STULabel/Internal/TextStyle.hpp:432:59: Reference to 'Byte' is ambiguous
Pods/STULabel/STULabel/Internal/TextStyle.hpp:433:55: Reference to 'Byte' is ambiguous
Pods/STULabel/STULabel/Internal/TextStyle.hpp:327:71: Reference to 'Byte' is ambiguous
Pods/STULabel/STULabel/Internal/TextStyle.hpp:335:71: Reference to 'Byte' is ambiguous
Pods/STULabel/STULabel/Internal/TextStyle.hpp:448:50: Reference to 'Byte' is ambiguous
Wonder library for sure :)
I've been bumping into an issue since day one with STULabel.
Seems you can't set a label with a text (like: "abc")
And then update with a blank text (like: " ") or ("") or even multiple spaces
But the text simply won't update.
My work-around, after trying so many different options:
Create your own update function of STULabel, in an extension.
And then call that function, everytime you want to update a text.
What it does: it makes the text invisible, when-ever it is empty, and visible, when it has a text.
extension STULabel {
public func update(_ text: String) { // fix: empty text doesn't update field!
self.text = text
self.isHidden = text.isEmpty // <- fix
}
}
Hope this helps someone, who's still using this amazing library.
This is of course a temporary fix, but it works really good.
When compiling for Catalyst (iOSMac) it seems to import OSTypes.h (which also imports MacTypes.h) and OSTypes.h defines UInt which collides with the one used in Config.hpp.
I'm not sure what the easy fix for this is, we could codemod everything to use the stu:: prefix, but that'd make things look super verbose. I don't know enough C++ to do anything otherwise tho :/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.