Commit Graph

501 Commits

Author SHA1 Message Date
Dmitry Zakharov 429fcc8cab Migrate DeviceInfoModule from RN Module to Native Function.
Reviewed By: danzimm

Differential Revision: D6750934

fbshipit-source-id: f453801737e41632c6b84ff894e7f0eb66b575dc
2018-01-29 11:18:42 -08:00
Valentin Shergin 2716f53220 The New <Text> on iOS
Summary:
This is a complete rewrite of RCTText, the part of React Native which manages Text and TextInput components.

Key points:

* It's understandable now. It follows a simple architectural pattern, and it's easy to debug and iterate. Text flow layout is a first-class citizen in React Native layout system now, not just a wired special case. It also brings entirely new possibilities such as nested interleaving <Text> and <View> components.
* All <Text>-specific APIs were removed from UIManager and co (it's about ~16 public methods which were used exclusively only by <Text>).
* It relies on new Yoga measurement/cloning API and on-dirty handler. So, it removes built-in dirty propagation subsystem from RN completely.
* It caches string fragments properly and granularly on a per-node basis which makes updating text-containing components more performant.
* It does not instantiate UIView for virtual components which reduces memory utilization.
* It drastically improves <TextInput> capabilities (e.g. rich text inside single line <TextInput> is now supported).

Screenshots:
https://cl.ly/2j3r1V0L0324
https://cl.ly/3N2V3C3d3q3R

Reviewed By: mmmulani

Differential Revision: D6617326

fbshipit-source-id: 35d4d81b35c9870e9557d0211c0e934e6072a41e
2018-01-24 00:03:01 -08:00
Semen Zhydenko d2c569795c Typos in comments and log messages
Summary:
No code changes, no testing required.

alligned -> aligned
allignment -> alignment
completly -> completely
conseptually -> conceptually
decendents -> descendants
indefinetly -> indefinitely
dimention -> dimension
doesnt -> doesn't
safegaurd -> safeguard
intialization -> initialization
hierachy -> hierarchy
happend -> happened
gaurd -> guard
programatically -> programmatically
initalized -> initialized
immidiately -> immediately
occured -> occurred
unkown -> unknown
neccessary -> necessary
neccesarily -> necessarily
occuring -> occurring
comoponent -> component
propogate -> propagate
recieved -> received
referece -> reference
perfomance -> performance
recieving -> receiving
subsquently -> subsequently
scoll -> scroll
suprisingly -> surprisingly
targetting -> targeting
tranform -> transform
symetrical -> symmetrical
wtih -> with
Closes https://github.com/facebook/react-native/pull/17578

Differential Revision: D6718791

Pulled By: shergin

fbshipit-source-id: 4ab79c1131ec5971d35a0c7199eba7ec0a0918ad
2018-01-12 22:18:45 -08:00
Valentin Shergin 7d9e902d72 Proper check for RCTRootShadowView in RCTUIManager
Summary: Because setting `intrinsicContentSize` for `RCTSurfaceRootView` doesn't have much sense.

Reviewed By: mmmulani

Differential Revision: D6701107

fbshipit-source-id: 259cdd27339bba3e8c9f98b6ca34affeb87f298c
2018-01-11 18:57:31 -08:00
Valentin Shergin b9b7fabf98 Revert D6641403: [RN] Refined -[RCTUIManager createView:]
Differential Revision: D6641403

fbshipit-source-id: f478810413aa49b44c060db898e7e8698bddb8e1
2018-01-09 22:36:31 -08:00
Valentin Shergin e46ea8c737 Refined -[RCTUIManager createView:]
Summary: Now we do not add newly created view to the registry at the preluminary step.

Reviewed By: mmmulani

Differential Revision: D6641403

fbshipit-source-id: c69077aaba871f3cdb3500c75e1efe07546e1b7f
2018-01-07 21:31:06 -08:00
Valentin Shergin 46be5bf71c Forgotten setNeedsLayout in -[UIManager intrinsicContentSize:]
Summary: That fixes a regression introduced in D5990342.

Differential Revision: D6669153

fbshipit-source-id: e7d7342d58878703e188ef27d82af8196a8d950a
2018-01-05 15:47:01 -08:00
Valentin Shergin 0ec1017660 Fixed double initial prop applying for newly created views
Summary: This is a leftover from recent changes in D6595780 where a prop application step was moved out to separare mount block.

Differential Revision: D6640736

fbshipit-source-id: 70de0f55f992a7912e222ec4bf9ade1c9bad99f2
2017-12-27 18:02:05 -08:00
Valentin Shergin fc5e340e89 Revert D6596375: [RN] Removed unnecessary code path in `[RCTUIManager updateView:]`
Differential Revision: D6596375

fbshipit-source-id: f8b0ea2dafbf997a18e9c86fb279682d31b06d0e
2017-12-20 17:46:19 -08:00
Pieter De Baets a0ff8c7706 Fix ReactLegacy and delete RCTViewControllerProtocol
Summary:
It's always bothered that we have this protocol and I figured it could just be merged with RCTWrapperViewController.
Closes https://github.com/facebook/react-native/pull/17290

Reviewed By: mmmulani

Differential Revision: D6611544

Pulled By: javache

fbshipit-source-id: a50b9d5adbeb2c48dbadbbfc1c77ccf6d1aae144
2017-12-20 15:20:00 -08:00
Valentin Shergin 0ae4c47daa `-[UIView _DEBUG_reactShadowView]` was removed
Summary:
Nobody uses it.
If the reference to the bridge is available (which is should be case for testing purposes at least), it is easy to get same information.

Reviewed By: mmmulani

Differential Revision: D6596376

fbshipit-source-id: 066eeb1e9465b4e0cc9d9b5b6bf41722450870e4
2017-12-19 23:46:09 -08:00
Valentin Shergin c79246dbc6 Removed unnecessary code path in `[RCTUIManager updateView:]`
Summary: The `-[RCTShadowView viewName]` prop must exist, we don't need special handling for this case.

Reviewed By: mmmulani

Differential Revision: D6596375

fbshipit-source-id: 3e99a62bd6296e0285156f03dc2ac93db7f630e5
2017-12-19 23:46:09 -08:00
Valentin Shergin 7d1dedadd7 New implementation of handling `didUpdateReactSubviews` and `didUpdateReactSubviews` events
Summary:
Motivation:
* Current implementation of `didUpdateReactSubviews` relies on `processUpdatedProperties:parentProperties:` method of RCTShadowView, which we plan to remove.
* The existing implementation does not call handlers on unmounted nodes (because they are not part of traversing tree), which is not correct.
* The current implementation is tight with RCTComponentData, which is conceptually wrong, it should be a UIManager thing.
* The new implementation must be much more performant because of simplicity. (We can measure it only after removing `processUpdatedProperties`.)

Reviewed By: mmmulani

Differential Revision: D6595780

fbshipit-source-id: a517207c17b5d5db839c9ce99a37136292acf78c
2017-12-19 23:46:09 -08:00
Valentin Shergin 2679f3efb6 Demolishing of background color propagation infra
Summary: As it was mentioned in previous diffs, we are removing this because it overcomplicates rendering layer and provides (almost) no benefits (and cannot be implemented 100% accurate way).

Reviewed By: mmmulani

Differential Revision: D6582560

fbshipit-source-id: 0778db96a45dd8e2520268d5d00792677cb01a20
2017-12-19 09:11:49 -08:00
Ben Nham 0673ac25f1 improve detection of inspectable JS contexts
Reviewed By: Hypuk

Differential Revision: D6578735

fbshipit-source-id: ac6a3a8bae9aef7fd3b4a036c3f154b3f6b7d80c
2017-12-18 13:32:36 -08:00
Valentin Shergin d2dc451407 reactBridgeDidFinishTransaction was finally removed
Summary:
We are removing `reactBridgeDidFinishTransaction`.
Why?
 * It is a performance drain. Supporting this requires dispatching main-thread block on every single transaction complete;
 * It has "too broad" non-conceptual semantic which encouraged using this as a "band-aid solution" for poorly designed components;
 * It is conceptually incompatible with new approaches that we are trying to implement to optimize the render layer;
 * It was deprecated for very long time.

Reviewed By: mmmulani

Differential Revision: D6549729

fbshipit-source-id: 58094aab982c67cec3d7fa3b616c637cb84d697f
2017-12-18 11:47:26 -08:00
Alex Dvornikov d9c658566a Fix a crash when keyboard is visible and bridge reload happens
Reviewed By: sahrens

Differential Revision: D6573855

fbshipit-source-id: 8768dca7d36782e82fb457f6ff4b09791e669d00
2017-12-14 17:51:59 -08:00
Ayush Sood ee521f9c05 Add extra data view to RN RedBox
Reviewed By: shergin

Differential Revision: D6382976

fbshipit-source-id: 33568a241395b085a840ac52adab3c9dc463ea4c
2017-12-14 10:50:24 -08:00
Paco Estevez Garcia 59c3e33f63 Fix isNuclideDebuggingAvailable on iOS
Reviewed By: bnham

Differential Revision: D6567435

fbshipit-source-id: e8c4d8a3e02fe767f5a6871db61b21faf181cc43
2017-12-14 08:17:12 -08:00
Rahul Ramachandran eaa84997ce Fix - argument type in RCTEventEmitter
Reviewed By: javache

Differential Revision: D6528139

fbshipit-source-id: 170c2359bcc67131330d091e3707124018053938
2017-12-13 08:30:39 -08:00
Yujie Liu 0b1e6444bb remove embeddedBundleURL
Reviewed By: fromcelticpark

Differential Revision: D6501542

fbshipit-source-id: c6f1adddc4e671f73195afde927face28ee79342
2017-12-12 13:11:14 -08:00
Valentin Shergin 60dc9bed00 -[RCTUIManagerObserver uiManagerDidPerformMounting]
Reviewed By: rsnara

Differential Revision: D6434461

fbshipit-source-id: a66407936cec3582cb27c57eb8e36dc225149c45
2017-12-11 17:10:48 -08:00
Valentin Shergin 0a8721c340 Renaming uiManagerWillFlushUIBlocks -> uiManagerWillPerformMounting
Summary:
Because it is not simply flushing, it (in the future) is more complex process. And the names should represent logical meaning of the process, not particular implementation details.
It also nice to have unified terminology across our reactive UI frameworks.

See the next diffs.

Reviewed By: rsnara

Differential Revision: D6436770

fbshipit-source-id: 0a0b686e8ace89e30f6787a37c0a7965c5af757b
2017-12-11 17:10:48 -08:00
Paco Estevez Garcia de424cc291 Add inspector attach to RN Dev Menu (iOS)
Reviewed By: Hypuk

Differential Revision: D6405831

fbshipit-source-id: ffecfbf85a35fad4d0c9a823c5e637a6b9e202ee
2017-12-05 06:31:15 -08:00
Valentin Shergin 71b498b082 Introducing `[RCTUIManager _executeBlockWithShadowView:forTag:]`
Summary:
New super simple abstraction in RCTUIManager.
Nothing really changed and RCTUIManager became shorter.

Reviewed By: rsnara

Differential Revision: D5990342

fbshipit-source-id: b38397b789a999168ac14625585065eda73d328f
2017-11-29 23:01:31 -08:00
Valentin Shergin 21714fe197 Removing RCTUIManager.unsafeFlushUIChangesBeforeBatchEnds experiment
Reviewed By: javache

Differential Revision: D6432476

fbshipit-source-id: fd02b686cf8bc70a4dfcc02d3bbfdf01c611f351
2017-11-29 10:34:04 -08:00
Nicolas Charpentier ee3532b5c2 Implement requiresMainQueueSetup in RCTTVNavigationEventEmitter
Summary:
Fix the following warning:

> Module RCTTVNavigationEventEmitter requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

Trivial change.

[IOS] [MINOR] [RCTTVNavigationEventEmitter] - Implement `requiresMainQueueSetup` in `RCTTVNavigationEventEmitter`
Closes https://github.com/facebook/react-native/pull/16915

Differential Revision: D6394636

Pulled By: shergin

fbshipit-source-id: 3981655832715e73e93ef917d987e25097029b84
2017-11-22 00:39:33 -08:00
Adam Ernst 33cefc1760 RCTRedBox should appear beneath the status bar
Reviewed By: fromcelticpark

Differential Revision: D6370566

fbshipit-source-id: fe59a789113c2e8c24e96e560647efbd8bdfe67b
2017-11-20 18:36:27 -08:00
Adam Ernst 9180d4eb82 Make RCTPackagerConnection a singleton
Reviewed By: fromcelticpark

Differential Revision: D6361741

fbshipit-source-id: 96e92dff5dd3d7aa1f7555442b0eba90e7dbf47c
2017-11-20 18:36:27 -08:00
Yujie Liu ae5ef653cb Rename bundleSource to embeddedBundle
Reviewed By: fromcelticpark

Differential Revision: D6274101

fbshipit-source-id: f62da158d165cb3ce4a510ebc4eed24a8a719381
2017-11-09 09:33:00 -08:00
Yujie Liu b983de9c54 Share bundled source URL to RN
Differential Revision: D6192988

fbshipit-source-id: efa584ee2340a34156956990d6cd96d37ba4ab60
2017-11-07 16:46:53 -08:00
Valentin Shergin 7df58e23a3 Introducing RCTSurface, new experimental thread-safe interop layer
Summary:
RCTSurface instance represents React Native-powered piece of a user interface
which can be a full-screen app, separate modal view controller,
or even small widget. It is called "Surface".

The RCTSurface instance is completely thread-safe by design;
it can be created on any thread, and any its method can be called from
any thread (if the opposite is not mentioned explicitly).
The primary goals of the RCTSurface are:
 - ability to measure and layout the surface in a thread-safe and synchronous manner;
 - ability to create a UIView instance on demand (later);
 - ability to communicate the current stage of the surface granularly.

Differential Revision: D6202576

fbshipit-source-id: 8e644c87fcaad2b6a9c9304b58384d7192747556
2017-11-07 16:16:56 -08:00
Valentin Shergin be6976d6fa RCTAllocatedRootViewTag was moved to RCTUIManagerUtils
Summary: This logic was decoupled from RCTRootView to make it reusable.

Reviewed By: javache

Differential Revision: D6214785

fbshipit-source-id: e7419be03ba0e20d95b47c11e41789636aa6e916
2017-11-07 16:16:56 -08:00
Ramanpreet Nara efa4d3c222 Rename I18nManager Left/Right swap methods
Reviewed By: fkgozali

Differential Revision: D6140072

fbshipit-source-id: 282dc614c036de8f217a729f21a1bbe92b8afd7d
2017-10-24 20:45:59 -07:00
Ramanpreet Nara 98547d4bcf Implement gating support for direction-aware API changes
Reviewed By: achen1

Differential Revision: D6045083

fbshipit-source-id: 857a43029ad88d2324ec77145a1e30d92b5e8fae
2017-10-18 19:33:31 -07:00
Dmitry Zakharov 04ff184c12 Make RCTUIManager and RCTDeviceInfo unsubscribe from NSNotificationCenter on
Reviewed By: fromcelticpark

Differential Revision: D5986167

fbshipit-source-id: 18131572361c4b3f5e0ed5c8f97833a21902cad1
2017-10-10 05:10:05 -07:00
Valentin Shergin 4342879c92 Deprecated stuff was removed from RCTUIManager
Summary: It was deprecated awhile ago.

Reviewed By: javache

Differential Revision: D5990505

fbshipit-source-id: 68deefb76fee31a49bfe832e281dc8ee11061cb8
2017-10-09 17:22:35 -07:00
Valentin Shergin 5e25c0e32f Introducing PseudoUIManagerQueue
Summary:
Queues Problem Intro:
UIManager queue is special queue because it has special relationship with
the Main queue.

This particular relationship comes from two key factors:
 1. UIManager initiates execution of many blocks on the Main queue;
 2. In some cases, we want to initiate (and wait for) some UIManager's work *synchronously* from
    the Main queue.

So, how can we meet these criteria?
"Pseudo UIManager queue" comes to rescue!

"Pseudo UIManager queue" means safe execution of typical UIManager's work
on the Main queue while the UIManager queue is explicitly blocked for preventing
simultaneous/concurrent memory access.

So, how can we technically do this?
 1. `RCTAssertUIManagerQueue` is okay with execution on both actual UIManager and
    Pseudo UIManager queues.
 2. Both `RCTExecuteOnUIManagerQueue` and `RCTUnsafeExecuteOnUIManagerQueueSync`
    execute given block *synchronously* if they were called on actual UIManager
    or Pseudo UIManager queues.
 3. `RCTExecuteOnMainQueue` executes given block *synchronously* if we already on
    the Main queue.
 4. `RCTUnsafeExecuteOnUIManagerQueueSync` is smart enough to do the trick:
    It detects calling on the Main queue and in this case, instead of doing
    trivial *synchronous* dispatch, it does:
      - Block the Main queue;
      - Dispatch the special block on UIManager queue to block the queue and
        concurrent memory access;
      - Execute the given block on the Main queue;
      - Unblock the UIManager queue.

Imagine the analogy: We have two queues: the Main one and UIManager one.
And these queues are two lanes of railway go in parallel. Then,
at some point, we merge UIManager lane with the Main lane, and all cars use
the unified the Main lane.
And then we split lanes again.

This solution assumes that the code running on UIManager queue will never
*explicitly* block the Main queue via calling `RCTUnsafeExecuteOnMainQueueSync`.
Otherwise, it can cause a deadlock.

Reviewed By: mmmulani

Differential Revision: D5935464

fbshipit-source-id: 6a60ff236280d825b4e2b101f06222266097b97f
2017-10-08 21:40:19 -07:00
Adam Ernst e87904cea5 Redo error handling on iOS
Reviewed By: danzimm

Differential Revision: D5969343

fbshipit-source-id: 376984a6e959349260c54884c0b0b719f4c353d6
2017-10-05 13:31:55 -07:00
Valentin Shergin f8e13868dd Fixed crash in [UIManager setLocalData:]
Summary:
This is pretty normal and harmless case, we should not crash here.
I plan to refactor similar places in this file soon.

Reviewed By: AaaChiuuu

Differential Revision: D5983443

fbshipit-source-id: 922fea8ed12ebef45d249f16739aa81fe3254f19
2017-10-04 19:54:24 -07:00
Alex Dvornikov afec987e10 Unify sampling profiler and reload logic by leveraging RCTPackagerConnection
Differential Revision: D5951952

fbshipit-source-id: ceea04ebbddb02944717a266a14523be052ab213
2017-10-04 19:17:06 -07:00
Frank Manns 09680f71df Return instancetype for shared RCTI18nUtil instance
Summary:
In modern Objective-C you should use the `instancetype` keyword for methods which return an instance of the class they are called on. See Apple's [Adopting Modern Objective-C](https://developer.apple.com/library/content/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html) guide.

Because `sharedInstance` was returning an object of type `id`, the returned value needed to be cast before it could be used in Swift.

I also changed the implementation of `sharedInstance` to use Grand Central Dispatch, which is the generally accepted best way of creating a singleton in Objective-C.

I verified my changes with the "RTLExample" app in RNTester.

| LTR | RTL |
|---|---|
|<img width="300" src="https://user-images.githubusercontent.com/1413388/31155210-6454b4d6-a87a-11e7-9dd7-9a52f3924737.png">|<img width="300" src="https://user-images.githubusercontent.com/1413388/31155233-8702aff6-a87a-11e7-8028-51cf2b3eb0c4.png">|
Closes https://github.com/facebook/react-native/pull/16196

Differential Revision: D5971898

Pulled By: shergin

fbshipit-source-id: dfa375c89248adfc9fd885cacc6a6d4cbfea6e90
2017-10-03 20:11:16 -07:00
Ramanpreet Nara 992ade1fc5 Re-render views when direction changes
Reviewed By: shergin

Differential Revision: D5959573

fbshipit-source-id: 36b2cde921362a934a2c88a3ed05be5082ed08bf
2017-10-03 13:01:06 -07:00
Valentin Shergin 33f4779ed8 DeviceInfo.isIPhoneX_deprecated: ugly and temporary way to fix your UI on iPhone X
Summary:
If you are a product developer and you need to fix your app's issues related to iPhone X limitations asap,
you can temporary use `DeviceInfo.isIPhoneX_deprecated`.
You can, but you should not. Please consider use new <SafeAreaView>.
This prop was initially named so ugly because we are trying to discourage the community to use it.
However, we understand that sometimes we need a "band-aid" to prevent our apps bleeding.
Note: This prop (DeviceInfo.isIPhoneX_deprecated) will be removed completely after 06/18.

Reviewed By: fkgozali

Differential Revision: D5946329

fbshipit-source-id: 5d6dcaf0e2d175327d59cde4b5ec2e01cd77ec70
2017-10-02 23:00:03 -07:00
Valentin Shergin 9cd095eae8 Using RCTExecuteOnMainQueue in RCTUIManager
Reviewed By: javache

Differential Revision: D5937423

fbshipit-source-id: 1b7f5976acdfdfd00c6aa5c13e80113ba1e04434
2017-10-02 18:20:19 -07:00
Valentin Shergin feba4f6a92 Using RCTExecuteOnUIManagerQueue convinient func in all conseptually identical cases
Summary:
Reasons:
 * It is more clear and readable;
 * It is more semantical;
 * It allows us to add some magic (and complexity, to be fair) to the RCTExecuteOnUIManagerQueue. (See next diffs in the stack.)

Reviewed By: javache

Differential Revision: D5935466

fbshipit-source-id: aeb18d6e11c047eb19182a656da581b6ce073602
2017-10-02 18:20:19 -07:00
Simon Racz be27f44e1b Removed a wrong assert.
Summary:
This fixes [#15801](https://github.com/facebook/react-native/issues/15801)

We ran into a strange crash on iOS (debug only). After removing the clutter I was able to reproduce it in a tiny app. You can check it out [here.](https://github.com/simonracz/textinput_stress)

The UI in JS and native are not always in sync (which is okay). Due to this, a native view might call back into JS, which is no longer present in the shadow view hierarchy there. I think this should be also okay.

TextInput in some cases calls into [setIntrinsicContentView](6d67e2dbbc/React/Modules/RCTUIManager.m (L382)), where it triggers an overly enthusiastic `NSAssert` and crashes the app.

Check out [textinput_stress](https://github.com/simonracz/textinput_stress)
Rotate the simulator a few times to see the crash or the lack of crash.
Closes https://github.com/facebook/react-native/pull/16170

Differential Revision: D5959776

Pulled By: shergin

fbshipit-source-id: f39f5a3f1d86b330ecf7cbccd90871bc01fd69d9
2017-10-02 17:46:00 -07:00
Jason Carreiro abed3cf6c4 Revert D5944488: [RN][iOS]: Re-render views when direction changes
Differential Revision: D5944488

fbshipit-source-id: 79e695dcc0ea7d09544ace1525828333a5818c5a
2017-10-02 12:19:25 -07:00
Ramanpreet Nara 9bbc70c442 Re-render views when direction changes
Summary:
This is required for D5874536, wherein I'll be introducing direction-aware props for borders.

When a view's border changes due to a direction update, only the frames of its children update. Therefore, only the children `UIView`s get a chance to be re-rendered. This is incorrect because the view that's had its borders changed also needs to re-render. So, I keep a track of the layout direction in a property on all shadow views. Then, when I update that prop within `applyLayoutNode`, I push shadow views into the `viewsWithNewFrames` set.

Reviewed By: mmmulani

Differential Revision: D5944488

fbshipit-source-id: 3f23e9973f3555612920703cdb6cec38e6360d2d
2017-10-02 11:15:48 -07:00
Alex Dvornikov c4f7ce9afd always pass key parameter to RCTReadFile
Differential Revision: D5921064

fbshipit-source-id: ad2dd352060fcb2c873dc5a91781797c9abd6c33
2017-09-28 09:38:44 -07:00