Граф коммитов

531 Коммитов

Автор SHA1 Сообщение Дата
generatedunixname89002005287564 3f85b83653 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D23811656

fbshipit-source-id: 4104948d2e4db786998320bcfdb1598d4a497f2d
2020-09-21 04:38:18 -07:00
Valentin Shergin 57dd48b246 Fabric: Marking all JS function lambdas `noexcept` in UIManagerBinding
Summary:
Exceptions in C++ work quite differently from exceptions in other languages. To make exceptions actually work **correctly** all the code needs to be written with "exceptions in mind" (e.g., see https://www.stroustrup.com/except.pdf). In short, if the code is not "exceptions ready", throwing an exception causes memory leaks, dangling pointers, and invariant violations all over the place, which will probably cause another crashes down the road (which will be especially hard to investigate and attribute to the original issue).
Fabric Core (Layout, Props parsing, ShadowNodes management, and so on) does not use exceptions because in most (all?) the cases the exception is now recoverable. So, if a program detects some internal state invariant violation or missing some resource, *logically* it's fatal. We also don't want to pay code-size and performance tax for exception support, so that's why we don't use them. It's just not the right fit for Fabric Core.

This does not mean that exceptions don't happen though. C++ standard library can throw them... sometimes. And if our library is compiled with exceptions enabled (still the case, unfortunately), an exception can bubble to JavaScript code and losing all context down the road. And it's hard to investigate such crashes. To isolate those occasional exceptions inside C++ core we are marking all C++/JS boundaries with `noexcept` that stops the bubbling.

I hope that will give us much more informative crash reports.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23787492

fbshipit-source-id: 0822dbf36fc680c15b02b5cd0f2d87328296b642
2020-09-18 17:07:29 -07:00
Valentin Shergin 5b93c49e76 Fabric: Using pre-cached UIColor objects for black, white, and clear colors
Summary:
This change maps the three most used colors (black, white, clear) to corresponding predefined values in UIColor. This should meaningfully reduce the overall amount of allocated UIColor/CGColor objects. In my non-scientific measures, it reduces the number of CGColor objects from ~1500 to ~1000. And... it no much at least in terms of kilobytes. However, I still think it's a good idea to implement this because I hope that can remove some work from memory allocation infra and maybe enable some optimizations that UIKit hopefully does for black and white colors. (I tend to believe that this optimization exists because UIKit even has a classes called UIDeviceWhiteColor and UICachedDeviceWhiteColor.)

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753506

fbshipit-source-id: 46e58dc7e6b0dcab3c83d29c7257c90ffbd95246
2020-09-17 11:12:29 -07:00
Valentin Shergin 241795cbc4 Fabric: Color conversion functions now do not depend on internal implementations of SharedColor
Summary:
This diff changes the implementation of `RCTCreateCGColorRefFromSharedColor` and `RCTUIColorFromSharedColor` in such a way that they don't rely on the fact that SharedColor is actually a `shared_ptr<CGColorRef>`. Instead, the methods just extract color components from SharedColor and create UIColor and CGColorRef objects on demand.
This allows us to change the implementation of SharedColor without worrying much about the rest of the system, which will do in the next diff.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753510

fbshipit-source-id: 340127527888776ebd5d241ed60c7e5220564013
2020-09-17 11:12:28 -07:00
Valentin Shergin d3bb76b8b6 Fabric: Using RCTUIColorFromSharedColor everywhere
Summary:
Even though we have wonderful helper functions converting SharedColor to UIColor and CGColorRef, in many places we still use some hardcoded things. This diff fixes that; it will be important for the next diff.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753508

fbshipit-source-id: 09d280b132266252753526c2735ab3e41b96c8d5
2020-09-17 11:12:28 -07:00
Valentin Shergin f2ca6f568e Fabric: Removing `RCTCGColorRefUnretainedFromSharedColor()`
Summary:
This diff removes `RCTCGColorRefUnretainedFromSharedColor` function because it's not compatible with future changes we plan to make.
Converting SharedColor to unretained CGColorRef is actually quite dangerous because... it's an unowned pointer.

Reviewed By: JoshuaGross

Differential Revision: D23753509

fbshipit-source-id: df030ade69b63cbb872d6bdbde51575eedc6a4a6
2020-09-17 11:12:28 -07:00
Valentin Shergin 2103839525 Fabric: Optimized hit-testing
Summary:
An experiment where we use `LayoutMetrics::overflowInset` to optimize performance of hit-testing algorithm.
In my measurements enabling this feature drastically (2x) reduced amount of calls to `hitTest:withEvent:` method.

Reviewed By: sammy-SC

Differential Revision: D23669091

fbshipit-source-id: ac6dadc90b6a2fbb45e41e0d4a113bd5ae8f1218
2020-09-15 22:29:30 -07:00
Samuel Susla b705eafd22 Fix retain cycle in RCTFabricSurface
Summary:
Changelog: [internal]

Fix retain cycle caused by chain: `RCTSurfaceTouchHandler` -> `RCTSurfaceTouchHandler._rootComponentView` -> `RCTSurfaceTouchHandler`

`RCTSurfaceTouchHandler._rootComponentView` calls `addGestureRecognizer` with `RCTSurfaceTouchHandler` as a parameter which, according to documentation, strongly holds onto gesture recogniser.

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/React/Fabric/RCTSurfaceTouchHandler.mm?lines=189

For details about `addGestureRecognizer`, refer to https://developer.apple.com/documentation/appkit/nsview/1483749-addgesturerecognizer?language=objc#

Reviewed By: shergin

Differential Revision: D23704441

fbshipit-source-id: b1ab0feff552eaf10c1c71a931690c5258ce87cf
2020-09-15 17:34:35 -07:00
Paige Sun acda299453 6/6 Log image-rendered for Fabric image logging
Reviewed By: fkgozali

Differential Revision: D23450649

fbshipit-source-id: 58265a2c7855a2f4371d68637f09a07921821adf
2020-09-11 15:09:12 -07:00
Paige Sun 24ba03ccae 4/6 Log view-appear and view-disappear for Fabric image logging
Reviewed By: fkgozali

Differential Revision: D23447863

fbshipit-source-id: db16d97034a8d4ba6fcd08da5068039450f3c57b
2020-09-11 15:09:12 -07:00
Paige Sun 13759f192d 3/6 Add IGviewpoint for image visibility callbacks
Summary: Changelog: [Internal] Add IGviewpoint to get image visibility callbacks for when an UIImageView is in or out of view

Reviewed By: fkgozali

Differential Revision: D23428528

fbshipit-source-id: 87e4cee8fbe3c6b7da5153f87bbb530b2f990d96
2020-09-11 15:09:12 -07:00
Valentin Shergin 661d34bb42 Fabric: Removing MainRunLoopEventBeat and RuntimeEventBeat (iOS)
Summary:
The `enable_run_loop_based_event_beat_ios` experiment was shipped a couple of months ago.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23606061

fbshipit-source-id: e1926f46933d6603f20104f211c944c50173a627
2020-09-11 08:23:27 -07:00
Valentin Shergin 7e899348c7 Fabric: Better error reporting in UIView+ComponentViewProtocol
Summary:
We need this to make crash logs more actionable. For now we know that those asserts fire so we should make them actionable.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23580103

fbshipit-source-id: 8532e33b016e738a4f128c9b547c33d204610bcc
2020-09-08 16:45:27 -07:00
Samuel Susla 67af6e54fc Fix removal for nested legacy interop layer
Summary:
Changelog: [Internal]

In https://fburl.com/diffusion/3705cj0i we assert that view which is about to be recycled, has no superview.
This is a problem in Legacy interop layer which is nested within another interop layer. This originally wasn't considered.

Removing views in `finalizeUpdates` like it has been done until now is not enough because when a component is deleted, `finaliseUpdates` isn't called.

Reviewed By: shergin

Differential Revision: D23572999

fbshipit-source-id: f007dfe293b7d27d56253656c02529163304f83c
2020-09-08 10:53:57 -07:00
Samuel Susla 4b95bb2f84 Check for nullability of [NSString UTF8String]
Summary:
Changelog: [internal]

[NSString UTF8String] is nullable. Therefore, we need to check if it isn't nil before passing it to std::string constructor which crashes if it's nil.

Reviewed By: shergin

Differential Revision: D23572652

fbshipit-source-id: 59e7f5e918b2e5c69333bfb687371f856555d8e0
2020-09-08 10:29:21 -07:00
Moti Zilberman 345baf477c Fix reorder-init-list warning in RCTViewComponentView
Summary:
Changes the order of `RCTBorderColors` field designators to match their declaration order, fixing one case of `-Wreorder-init-list` when compiling the RN codebase with Xcode 12.

Changelog: [Internal]

Reviewed By: MichaReiser

Differential Revision: D23447685

fbshipit-source-id: f04a3841187f0869d2efb60e81ce075c45f27f3c
2020-09-01 07:32:57 -07:00
Samuel Susla 33c16689a8 Deallocate UIViewController after it was used in Modal component
Summary:
Changelog: [Internal]

# Problem
`RCTModalHostViewComponentView` reuses the same UIViewController between recycles. This can be a problem if dismissal of the modal is animated as the UIViewController is still presented while it is being dismissed. That's when "Application tried to present modally an active controller" exception can happen.

# Solution
Deallocate UIViewController when `RCTModalHostViewComponentView` is recycled.

Reviewed By: PeteTheHeat

Differential Revision: D23345711

fbshipit-source-id: da540571184afcb88b52758c4a1f0b4ec5874eb1
2020-08-26 18:49:21 -07:00
Samuel Susla 9b973f32e4 Fix TextInput value not restoring after reuse
Summary:
Changelog: [Internal]

# Problem

The problem was setting `_backedTextInputView.attributedText` to nil inside `[RCTTextInputComponentView prepareForRecycle]`.

Ordinarily this isn't a problem becase `UIManager::updateState` drops the update if the ShadowNode no longer exists. But in certain cases the ShadowNode can exist, empty string being set as its value

# Fix

Fix is trivial, invalidate state before nullifying `_backedTextInputView`. This prevents the state update from being dispatched.

# Discussion

We should go over all other components and make sure state is invalidated as first thing in `[RCTViewComponentView prepareForRecycle]`.

Reviewed By: shergin

Differential Revision: D23324929

fbshipit-source-id: 9568e920d99683ad95f965ef4b63c529f50f3283
2020-08-25 15:43:08 -07:00
Samuel Susla b7afbb1fe2 Use window size instead of screensize for maximum size
Summary:
Changelog: [Internal]

This was set to screensize in D13104172 (346c9d5f2c) to work around issues at that time.
The issues might not be around anymore.

Reviewed By: PeteTheHeat

Differential Revision: D23298723

fbshipit-source-id: 4f33a2cc65ae4fe5ba20b0b2b270b135878c339f
2020-08-25 06:50:34 -07:00
Samuel Susla 258387ddaa Use window size instead of screen size in InputAccessoryView
Summary:
Changelog: [internal]

Use window size instead of screen size to layout InputAccessoryView.

Reviewed By: PeteTheHeat

Differential Revision: D23297141

fbshipit-source-id: d6d7223342d17a2e1b9e5fca6f999b7ad365d056
2020-08-25 06:50:34 -07:00
Samuel Susla 1704a725c5 Use ConcreteStateTeller in RCTImageComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239098

fbshipit-source-id: fa558e705e121f3d3fbded80ae99e5f51c80ae4a
2020-08-24 06:43:18 -07:00
Samuel Susla 0f7a1145ff Use ConcreteStateTeller in RCTInputAccessoryComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239095

fbshipit-source-id: a3324b5df6e6bd7508d74b66de9235852d828bbd
2020-08-24 06:43:18 -07:00
Samuel Susla 0b532e1be7 Use ConcreteStateTeller in RCTLegacyViewManagerInteropComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239097

fbshipit-source-id: 4c0d7b24917509d3d9660098349c226ad42e832e
2020-08-24 06:43:18 -07:00
Samuel Susla 9a5807162c Use ConcreteStateTeller in RCTParagraphComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239100

fbshipit-source-id: 10d10a369cb7ec82d2f6118a21ec70c2cc20abb3
2020-08-24 06:43:18 -07:00
Samuel Susla c2dab01c62 Use ConcreteStateTeller in RCTModalHostViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23239096

fbshipit-source-id: b82301e5db48861d6d241abd681df38701e3ac44
2020-08-24 06:43:18 -07:00
Samuel Susla ca091b009a Use ConcreteStateTeller in RCTScrollViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23238812

fbshipit-source-id: 8c777ae1264cfade507bfd336eefbe86ffb94b8f
2020-08-24 06:43:18 -07:00
Samuel Susla 724952e5d6 Use ConcreteStateTeller in RCTSafeAreaViewComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23238703

fbshipit-source-id: 67596194b599ce8d39a6e7403bf61dce0fd61434
2020-08-24 06:43:18 -07:00
Samuel Susla e454863bca Use ConcreteStateTeller in RCTTextInputComponentView
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D23216864

fbshipit-source-id: 2b82e2d43cc694251a1873ad9059eff4abca4e73
2020-08-24 06:43:17 -07:00
Paige Sun 6aa63272dc Create internal Fabric subclass of RCTImageComponentView
Summary: Changelog: [Internal] Create internal Fabric subclass of RCTImageComponentView

Reviewed By: sammy-SC

Differential Revision: D23211115

fbshipit-source-id: 0e756de3f3e555bf212dc88dfc8c32930ac85132
2020-08-22 01:19:10 -07:00
Samuel Susla 7d7903cd43 Back out "Fabric: Asserting if the RuntimeExecutor callback in RCTRuntimeExecutorFromBridge is not called"
Summary:
Changelog: [internal]

Original commit changeset: f11932019ab6

Reviewed By: JoshuaGross

Differential Revision: D23212230

fbshipit-source-id: 9e35e107eca5a25ba164e4588aa1c9c3517c6056
2020-08-19 11:01:26 -07:00
Samuel Susla e4cfbbad6d Introduce RCTFBModalComponentView
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23155490

fbshipit-source-id: 2c83c2ec71ca4d842275b4db6aac7169d3d77955
2020-08-17 15:44:29 -07:00
Paige Sun e1a5bd6bd6 Stop logging for Fabric from FBReactStreamingImageLoader
Summary: Changelog: [Internal]  Stop logging for Fabric from FBReactStreamingImageLoader

Reviewed By: fkgozali

Differential Revision: D23172395

fbshipit-source-id: d9fc4e82958d2f88ff91bddeb385fe3073cd8f1e
2020-08-17 15:44:29 -07:00
Samuel Susla 4c86bc6a41 Prevent RCTStringFromNSString from crashing if passed nil
Summary:
Changelog: [Internal]

[UITextField attributedText] is nullable. If it returns nil, we would crash inside `RCTStringFromNSString`.
[Source](https://developer.apple.com/documentation/uikit/uitextfield/1619602-attributedtext?language=objc)

Reviewed By: shergin

Differential Revision: D23154453

fbshipit-source-id: 33ec4950c4011461d0c4de3a4da3db760a8924b9
2020-08-16 10:28:41 -07:00
Samuel Susla c429ee9974 Implement ScrollView.contentInsetAdjustmentBehavior
Summary:
Changelog: [internal]

Fabric's ScrollView was ignoring value of `ScrollView.contentInsetAdjustmentBehavior`, this diff fixes that.

Reviewed By: shergin

Differential Revision: D23102235

fbshipit-source-id: 8cf42e730b560a21d56d7e007059109ccd01154e
2020-08-13 10:11:46 -07:00
Valentin Shergin b2570bd74d Removing `dispatch_async`-delayed TTRC reporting for Fabric TTRC tracker (gated)
Summary:
This diff introduces a new experiment touching performance measuring infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23071089

fbshipit-source-id: 22e6f34754956311bd6a0140fe2accd5758d87c7
2020-08-12 12:12:47 -07:00
Samuel Susla 22c1032dbc Fix text not being restored from state in TextInput
Summary:
Changelog: [internal]

Restore text value from state when re-initialising RCTTextInputComponentView

Reviewed By: shergin

Differential Revision: D22844624

fbshipit-source-id: b47e3fe890793f8de429b637535d641262c42be2
2020-08-11 13:20:30 -07:00
Jiayan Zhuang b628d4f5d5 Fix the frame issue for truncated text
Summary:
Changelog:
[Internal] - Fix the frame issue for truncated text.

When double tapping to expand/truncate the text, the rect of the element always moves to the top and then come back to the original place.. This seems because after truncating/expanding the text, the view would re-render and the container would be destroyed. I used the API accessibilityFrameInContainerSpace to set the frame before. And the frame was not updated properly. Converting the bound to the screen coordinates and set accessibilityFrame directly fixed it.

Reviewed By: PeteTheHeat

Differential Revision: D23040295

fbshipit-source-id: 1b449c39c79007d5321ff7b565c170f6d3fab8a4
2020-08-10 17:54:33 -07:00
Samuel Susla 154ce78972 Take viewport offset into account in UIManager.measureInWindow
Summary:
Changelog: [Internal]

Fabric's UIManager.measureInWindow didn't take viewport's offset into account. This diff fixes it by including viewport's offset in `LayoutContext`.

Reviewed By: JoshuaGross

Differential Revision: D23021903

fbshipit-source-id: 9106a8789d66fe19d8cb0a9378ee5bc8f2c83005
2020-08-10 12:52:23 -07:00
Samuel Susla 3be9f3ef2c Make RCTSurface and RCTFabricSurface conform to common protocol
Summary:
Changelog: [internal]

RCTSurface and RCTFabricSurface are two distinct classes that need to have the same interface otherwise the program crashes. This diff ties their interfaces through a protocol, triggering a build time error if they diverge.

Reviewed By: PeteTheHeat, JoshuaGross

Differential Revision: D23021837

fbshipit-source-id: 09ce345298ec2b45ac5a3fd2e0d3f5fa757a174f
2020-08-10 12:52:23 -07:00
Jiayan Zhuang dd040a87a7 Implement localization for accessibility guide words (#29576)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29576

Changelog:
[Internal] - Implement localization for accessibility guide words

Reviewed By: PeteTheHeat

Differential Revision: D22419882

fbshipit-source-id: 85fc4e741df3c59b64173c027a3c4e61b01bad4c
2020-08-06 16:38:56 -07:00
Jiayan Zhuang 07640dce69 Build the basic RCTLocalizationProvider
Summary:
Changelog:
[Internal][Add] - Build the basic RCTLocalizationProvider

RCTLocalizationProvider is to enable the localization in fabric. But I'd start with internal apps now.

Reviewed By: PeteTheHeat

Differential Revision: D22704051

fbshipit-source-id: 845693a131c325f3c3d92b2ff491d5421966ad3e
2020-08-06 14:35:35 -07:00
Jiayan Zhuang 3f405dcbd2 Add support for accessibilityRole = "switch"
Summary:
Changelog:
[Internal] - Add support for accessibilityRole = "switch"

Reviewed By: sammy-SC

Differential Revision: D22906500

fbshipit-source-id: 81dfbfd56a24c89ffedc0fde5a63f7bdeed0c5db
2020-08-06 13:16:48 -07:00
Jiayan Zhuang 6fa9dbabfc Update accessibilityState prop
Summary:
Changelog:
[Internal] - Add default value for accessibilityState "checked" and handle unhandled states.

It is also work for the case that accessibilityRole = "switch" and accessibilityState is set.

Reviewed By: sammy-SC

Differential Revision: D22914427

fbshipit-source-id: 4767a21f3bd109019b57bc09918758a38fbdea93
2020-08-06 12:14:38 -07:00
Jiayan Zhuang df66b7a4d2 Add UIContentSizeCategoryDidChangeNotification to re-render text
Summary:
Changelog:
[Internal] - Add UIContentSizeCategoryDidChangeNotification to re-render text

We don't need to restart the app to re-render text now, but we still need to swipe the screen or click on buttons to force to refresh. We may address this in the future.

Reviewed By: PeteTheHeat

Differential Revision: D22867293

fbshipit-source-id: 4747a45adc2bdc638cf7ef9c07a9484e48600583
2020-08-04 15:12:14 -07:00
Samuel Susla 22584954cd Account for view offset in bottom sheet
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22887857

fbshipit-source-id: 97194737a5c7c83f0ff9b35d90608c5e7e9b6bab
2020-08-04 01:50:56 -07:00
Samuel Susla a1b6f7bd9e Fabric: Asserting if the RuntimeExecutor callback in RCTRuntimeExecutorFromBridge is not called
Summary:
The implementation of RuntimeExecutor must execute all provided callbacks. However, the implementation of RCTRuntimeExecutorFromBridge cannot guarantee it because it relies on Bridge to make the call. In this diff, we wrap the callback into a callable that asserts if it's not being called before destruction.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D22810439

fbshipit-source-id: f11932019ab6ccbab7e65db5919e0c64dcaf37ed
2020-08-03 10:45:14 -07:00
Samuel Susla f838c7e5c3 Fabric: Asserts in RCTRuntimeExecutorFromBridge
Summary:
The implementation of RuntimeExecutor must execute all provided callbacks. However, the implementation has some branches that lead to such cases. To understand if this happens and when we need to add some asserts.

Changelog: [Internal] Fabric-specific internal change.

Differential Revision: D22810440

fbshipit-source-id: 7c29b765045b644fe0ad9d56b4c253dfe9395c31
2020-08-03 10:45:14 -07:00
Samuel Susla c452b826df Implement ScrollView.snapToOffsets and associated props
Summary:
Changelog: [Internal]
Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22820677

fbshipit-source-id: 8eed7ecd4dc766e8579a89707849e041adb073eb
2020-08-03 07:08:29 -07:00
Samuel Susla 94d0078653 Implement ScrollView.snapToInterval and associated props
Summary:
Changelog: [Internal]

Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22794554

fbshipit-source-id: ccfa777356932d81aa986349fba1685acf65d7f1
2020-08-03 07:08:29 -07:00
Joshua Gross e3302eeeab LayoutAnimations: call onSuccess, onFailure callbacks
Summary:
Hook up onSuccess and onFailure callbacks to LayoutAnimations.

Note that in non-Fabric RN, onSuccess is not known to work in Android. I could not find any uses of onFailure and it's not documented, so for now, it is only called if the setup of the animation fails.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22889352

fbshipit-source-id: 4306debb350388dd2b7a2cbfe295eb99723988e2
2020-08-02 16:37:03 -07:00