Title: [283249] branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac
- Revision
- 283249
- Author
- [email protected]
- Date
- 2021-09-29 12:43:45 -0700 (Wed, 29 Sep 2021)
Log Message
Cherry-pick r283225. rdar://problem/83683557
Make WebLocalizedString() thread-safe
https://bugs.webkit.org/show_bug.cgi?id=230954
Reviewed by Alexey Proskuryakov.
Make WebLocalizedString() thread-safe. It takes minimal effort to make it thread-safe given
that the NSBundle API is thread-safe [1] and clients keep calling it on the background thread.
[1] https://developer.apple.com/documentation/foundation/nslocalizedstringwithdefaultvalue
"As of OS X 10.11 and iOS 9, NSBundle is thread-safe. As such, you can safely call
NSLocalizedStringWithDefaultValue from any execution context."
* Misc/WebLocalizableStrings.mm:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283225 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac/ChangeLog (283248 => 283249)
--- branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac/ChangeLog 2021-09-29 19:21:03 UTC (rev 283248)
+++ branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac/ChangeLog 2021-09-29 19:43:45 UTC (rev 283249)
@@ -1,3 +1,40 @@
+2021-09-29 Alan Coon <[email protected]>
+
+ Cherry-pick r283225. rdar://problem/83683557
+
+ Make WebLocalizedString() thread-safe
+ https://bugs.webkit.org/show_bug.cgi?id=230954
+
+ Reviewed by Alexey Proskuryakov.
+
+ Make WebLocalizedString() thread-safe. It takes minimal effort to make it thread-safe given
+ that the NSBundle API is thread-safe [1] and clients keep calling it on the background thread.
+
+ [1] https://developer.apple.com/documentation/foundation/nslocalizedstringwithdefaultvalue
+ "As of OS X 10.11 and iOS 9, NSBundle is thread-safe. As such, you can safely call
+ NSLocalizedStringWithDefaultValue from any execution context."
+
+ * Misc/WebLocalizableStrings.mm:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283225 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-29 Chris Dumez <[email protected]>
+
+ Make WebLocalizedString() thread-safe
+ https://bugs.webkit.org/show_bug.cgi?id=230954
+
+ Reviewed by Alexey Proskuryakov.
+
+ Make WebLocalizedString() thread-safe. It takes minimal effort to make it thread-safe given
+ that the NSBundle API is thread-safe [1] and clients keep calling it on the background thread.
+
+ [1] https://developer.apple.com/documentation/foundation/nslocalizedstringwithdefaultvalue
+ "As of OS X 10.11 and iOS 9, NSBundle is thread-safe. As such, you can safely call
+ NSLocalizedStringWithDefaultValue from any execution context."
+
+ * Misc/WebLocalizableStrings.mm:
+
2021-09-22 Alan Coon <[email protected]>
Cherry-pick r282707. rdar://problem/83429953
Modified: branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac/Misc/WebLocalizableStrings.mm (283248 => 283249)
--- branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac/Misc/WebLocalizableStrings.mm 2021-09-29 19:21:03 UTC (rev 283248)
+++ branches/safari-612.2.9.0-branch/Source/WebKitLegacy/mac/Misc/WebLocalizableStrings.mm 2021-09-29 19:43:45 UTC (rev 283249)
@@ -37,17 +37,13 @@
NSString *WebLocalizedString(WebLocalizableStringsBundle *stringsBundle, const char *key)
{
- // This function is not thread-safe due at least to its unguarded use of the mainBundle static variable
- // and its use of [NSBundle localizedStringForKey:::], which is not guaranteed to be thread-safe. If
- // we decide we need to use this on background threads, we'll need to add locking here and make sure
- // it doesn't affect performance.
-#if !PLATFORM(IOS_FAMILY)
- ASSERT(isMainThread());
-#endif
-
NSBundle *bundle;
if (stringsBundle == NULL) {
- static NeverDestroyed<RetainPtr<NSBundle>> mainBundle = [NSBundle mainBundle];
+ static LazyNeverDestroyed<RetainPtr<NSBundle>> mainBundle;
+ static std::once_flag flag;
+ std::call_once(flag, [] () {
+ mainBundle.construct([NSBundle mainBundle]);
+ });
ASSERT(mainBundle.get());
bundle = mainBundle.get().get();
} else {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes