-
Notifications
You must be signed in to change notification settings - Fork 541
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
Jwoo/ios render sync #1547
Jwoo/ios render sync #1547
Changes from all commits
0bb7fca
1040a70
c90ef84
794fe54
663f61a
58a0556
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,22 +39,19 @@ + (ACRUILabel *)buildLabel:(NSString *)text | |
lab.isFactSetLabel = YES; | ||
lab.translatesAutoresizingMaskIntoConstraints = NO; | ||
lab.style = style; | ||
__block NSMutableAttributedString *content = nil; | ||
NSMutableAttributedString *content = nil; | ||
if(rootView){ | ||
std::shared_ptr<FactSet> fctSet = std::dynamic_pointer_cast<FactSet>(element); | ||
NSMutableDictionary *textMap = [rootView getTextMap]; | ||
// Syncronize access to imageViewMap | ||
dispatch_sync([rootView getSerialTextQueue], ^{ | ||
if(textMap[elementId]) { // if content is available, get it, otherwise cache label, so it can be used used later | ||
content = textMap[elementId]; | ||
} else { | ||
textMap[elementId] = lab; | ||
} | ||
}); | ||
} | ||
|
||
if(content){ | ||
NSDictionary* data = textMap[elementId]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm a little confused about the synchronization. Elsewhere it looks like access to this textMap is serialized on ACRView's _serial_text_queue, but here we're accessing it from a different thread without any synchronization. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, the reason is that once asyncronous tasks are completed, remaining works are done in serial since the works are UI related and have to be run on main thread. In reply to: 193501004 [](ancestors = 193501004) |
||
NSData *htmlData = data[@"html"]; | ||
NSDictionary *options = data[@"options"]; | ||
|
||
std::shared_ptr<HostConfig> config = [acoConfig getHostConfig]; | ||
// Initializing NSMutableAttributedString for HTML rendering is very slow | ||
content = [[NSMutableAttributedString alloc] initWithData:htmlData options:options documentAttributes:nil error:nil]; | ||
// Drop newline char | ||
[content deleteCharactersInRange:NSMakeRange([content length] -1, 1)]; | ||
// Set paragraph style such as line break mode and alignment | ||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; | ||
paragraphStyle.lineBreakMode = textConfig.wrap ? NSLineBreakByWordWrapping:NSLineBreakByTruncatingTail; | ||
|
@@ -70,7 +67,6 @@ + (ACRUILabel *)buildLabel:(NSString *)text | |
NSStrokeWidthAttributeName:[ACOHostConfig getTextStrokeWidthForWeight:textConfig.weight]} | ||
range:NSMakeRange(0, content.length)]; | ||
lab.attributedText = content; | ||
|
||
std::string ID = element->GetId(); | ||
std::size_t idx = ID.find_last_of('_'); | ||
if(std::string::npos != idx){ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change the dispatch to async, there's no guarantee that imgView will be set by the time you get here. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're correct. i may have forgotten to push my latest commit.
In reply to: 193240758 [](ancestors = 193240758)