Summary: When building for Mac Catalyst, it mostly appears as if it's targeting iOS (`TARGET_OS_OSX` is `0`) and the behavior should be aligned with iOS Simulator builds.
Reviewed By: lblasa
Differential Revision: D34413681
fbshipit-source-id: 1e56bbb3f16f8cd78e77771ff641c5cfcbc49955
Summary:
All our read/write to `identifierDict` in FLEXNetworkRecorder are done in their own thread-safe queue except one read and one write call.
Those two non-thread-safe read/write calls are causing ThreadSanitizer crashes in `react-native-macOS` when we consume flipper. By adding these calls to the `dispatch_async(self.queue` a few lines lower in the method, their access becomes thread safe as well.
Never having worked on Flipper I don't have much context on what FLEXNetworkRecorder actually does and the git history for this file shows the bug has existed since the "Initial commit" so it's unclear to me if we've purposefully not included these calls in the dispatch queue for some reason.
That said, I'd propose this as a fix as the thread sanitizing crash no longer repros for me downstream and I don't see anything immediately obvious for why this can't be in the self.queue as well.
## Changelog
Fix thread sanitizer crash in FLEXNetworkRecorder.
Pull Request resolved: https://github.com/facebook/flipper/pull/3457
Test Plan:
Running react-native-macOS with the ThreadSanitizer consistently hits this race condition on a library object in Flipper with the error below.
```
WARNING: ThreadSanitizer: race on NSMutableDictionary (pid=32575)
Read-only access of NSMutableDictionary at 0x000133ae5c60 by thread T11:
#0 -[__NSDictionaryM objectForKeyedSubscript:] <null>:130036204 (CoreFoundation:arm64+0x1897d8)
https://github.com/facebook/flipper/issues/1 __85-[FLEXNetworkRecorder recordRequestWillBeSentWithRequestID:request:redirectResponse:]_block_invoke FLEXNetworkRecorder.mm:130 (RNTester:arm64+0x1007afc48)
https://github.com/facebook/flipper/issues/2 __tsan::invoke_and_release_block(void*) <null>:130036204 (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x70514)
https://github.com/facebook/flipper/issues/3 _dispatch_client_callout <null>:130036204 (libdispatch.dylib:arm64+0x581c)
Previous modifying access of NSMutableDictionary at 0x000133ae5c60 by thread T1:
#0 -[__NSDictionaryM setObject:forKeyedSubscript:] <null>:130036204 (CoreFoundation:arm64+0x188808)
https://github.com/facebook/flipper/issues/1 -[FLEXNetworkRecorder recordRequestWillBeSentWithRequestID:request:redirectResponse:] FLEXNetworkRecorder.mm:118 (RNTester:arm64+0x1007af754)
https://github.com/facebook/flipper/issues/2 __73-[FLEXNetworkObserver(NSURLSessionTaskHelpers) URLSessionTaskWillResume:]_block_invoke FLEXNetworkObserver.mm:1690 (RNTester:arm64+0x1007adc70)
https://github.com/facebook/flipper/issues/3 __tsan::invoke_and_release_block(void*) <null>:130036204 (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x70514)
https://github.com/facebook/flipper/issues/4 _dispatch_client_callout <null>:130036204 (libdispatch.dylib:arm64+0x581c)
```
After moving the only non-thread safe read/write call into the appropriate dispatch queues I'm not longer able to repro this thread access crash after many attempts.
Reviewed By: fabiomassimo
Differential Revision: D34388079
Pulled By: lblasa
fbshipit-source-id: 2e654d601bc6a7d8d78d9a824e0aee66889b7fb9
Summary:
^
Note: this is already a working case. The difference is that if we are unable to establish a socket connection, we will not attempt to create one using rsocket.
Changelog: Removes rsocket-fallback for mobile clients
Reviewed By: nikoant
Differential Revision: D33655430
fbshipit-source-id: cb6f752f2d1354ab46d011b1f19c89520e1e7dd3
Summary: Achieving API parity with C++ and Android.
Reviewed By: lblasa
Differential Revision: D31921830
fbshipit-source-id: 873901107fc3c53166fa7bbaaff65ebdb0e53c2a
Summary:
This change moves the existing serialiser from FlipperWebSocket to FlipperURLSerializer.
The serialiser can be shared with Android as it no longer has any iOS dependencies.
Reviewed By: fabiomassimo
Differential Revision: D31571272
fbshipit-source-id: 0769b384d4143d7404fcfcf993d49dc1b00eeffd
Summary: This change adds a function to base64 encode. It is used to encode the CSR which gets added to the connection url.
Reviewed By: passy
Differential Revision: D31570706
fbshipit-source-id: 8356550fe87ae3ac6aae8616744a9339cf69b511
Summary:
This change removes ourselves as a delegate before closing.
SocketRocket uses its own internal async queue to perform most operations.
After a disconnect, we don't expect to receive any more delegate calls as the handlers may contain references which may have become invalid.
So, removing ourselves as delegates will ensure that we don't get called after a disconnect.
For sanity, we are also taking a copy of the message handler instead of a reference to it.
Reviewed By: briantkelley
Differential Revision: D31360721
fbshipit-source-id: bae5a2423757cd9064ffac28afb8b78c28a20d87
Summary:
Trigger a manual disconnect on deallocation. This was done automatically for us when the underlying socket gets released. But, this gives a bit more visibility and control onto exactly when this is going to take place.
Additionally, do not clear the message handler when a message is received.
It is not required as sendExpectResponse is one time called only used for certificate exchange. If this takes place again, a new handler will be set anyway.
Reviewed By: passy
Differential Revision: D31231828
fbshipit-source-id: 36ad13564a358b88d1618e94195fe05433d80993
Summary:
Addresses an issue with the connect and disconnect sequence.
Both, connect and disconnect should be performed 'synchronously' instead of being queued in the connection event thread.
Events should be queued in the connection event thread instead.
Reviewed By: passy
Differential Revision: D31195525
fbshipit-source-id: c15487ea163dd277dacee0e5669944ac6971355f
Summary:
This change makes WebSockets the default for Flipper on iOS.
Having said that, we are introducing some logic to deal with clients connecting to older Flipper Desktop versions.
The mobile client will first attempt to connect via WebSocket with the Desktop. This connection can either be secure or insecure. If that fails, it will attempt to connect via RSocket.
Connection failure logic:
The mobile client will attempt to connect up-to 3 times via a WebSocket. If it fails to connect, then the socket provider is switched to RSocket.
As before, the mobile client will attempt to connect up-to 3 times via a RSocket. If it fails to connect, then the socket provider is switched back to WebSocket.
Process repeats until a successful connection is established.
Some logs that can be seen from iOS:
2021-09-15 14:31:51.193503+0100 Sample[92026:92107440] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2021-09-15 14:31:51.878257+0100 Sample[92026:92107440] [connection] nw_socket_handle_socket_event [C1.1:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:31:52.553729+0100 Sample[92026:92107440] [connection] nw_socket_handle_socket_event [C1.2:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:31:52.899511+0100 Sample[92026:92107442] [connection] nw_connection_get_connected_socket [C1] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-09-15 14:31:52.899664+0100 Sample[92026:92107442] TCP Conn 0x600001d384d0 Failed : error 0:61 [61]
2021-09-15 14:31:57.120120+0100 Sample[92026:92107439] [connection] nw_socket_handle_socket_event [C2.1:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:31:57.141785+0100 Sample[92026:92107439] [connection] nw_socket_handle_socket_event [C2.2:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:31:57.151604+0100 Sample[92026:92107483] [connection] nw_connection_get_connected_socket [C2] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-09-15 14:31:57.154312+0100 Sample[92026:92107483] TCP Conn 0x600001d7c0b0 Failed : error 0:61 [61]
2021-09-15 14:31:59.206079+0100 Sample[92026:92107483] [connection] nw_socket_handle_socket_event [C3.1:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:31:59.236824+0100 Sample[92026:92107483] [connection] nw_socket_handle_socket_event [C3.2:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:31:59.251927+0100 Sample[92026:92107439] [connection] nw_connection_get_connected_socket [C3] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-09-15 14:31:59.255963+0100 Sample[92026:92107439] TCP Conn 0x600001d1c210 Failed : error 0:61 [61]
2021-09-15 14:32:01.291303+0100 Sample[92026:92107439] [connection] nw_socket_handle_socket_event [C4.1:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:32:01.312406+0100 Sample[92026:92107439] [connection] nw_socket_handle_socket_event [C4.2:1] Socket SO_ERROR [61: Connection refused]
2021-09-15 14:32:01.323099+0100 Sample[92026:92107483] [connection] nw_connection_get_connected_socket [C4] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-09-15 14:32:01.326028+0100 Sample[92026:92107483] TCP Conn 0x600001d7c0b0 Failed : error 0:61 [61]
flipper: Failed to connect with the current socket provider
flipper: Use legacy socket provider
flipper: FlipperClient::onConnected
Reviewed By: passy
Differential Revision: D30900471
fbshipit-source-id: 7c242ad71306803b050d0174fc22696bb74fdba5
Summary:
The changes below add the notion of alternative ports to Flipper.
These alternative ports are meant to and will be used to connect via WebSocket instead of RSocket. The name does not suggest that as to make as generic as possible so that they can be reused for different purposes in the future.
Reviewed By: passy
Differential Revision: D30898874
fbshipit-source-id: 5eed8c61b41b502c859192aaac59c284b7b36228
Summary: This change reverts a revert. The change was reverted for 'unrelated' issues addressed on this diff dependencies.
Reviewed By: passy
Differential Revision: D30696113
fbshipit-source-id: 8591d6ea79999597024c316e9927a346979e5219
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2838
Test Plan:
Imported from GitHub, without a `Test Plan:` line.
|[Site Preview: flipper](https://our.intern.facebook.com/intern/staticdocs/eph/D30838706/V2/flipper/)
Reviewed By: timur-valiev
Differential Revision: D30838706
Pulled By: passy
fbshipit-source-id: 6f7acf441211d9c5f61a4663af6eaf94f86c4dad
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2834
Test Plan:
Imported from GitHub, without a `Test Plan:` line.
|[Site Preview: flipper](https://our.intern.facebook.com/intern/staticdocs/eph/D30808471/V2/flipper/)
Reviewed By: timur-valiev
Differential Revision: D30808471
Pulled By: passy
fbshipit-source-id: 3cb5d487f1222a08ae9b67cb50fbf459ded40058
Summary:
This allows us to configure a simulator to use a non-default port pair by using the `defaults` mechanism. For instance, this can be done by running
```
xcrun simctl spawn booted defaults write "Apple Global Domain" "com.facebook.flipper.ports" -string "9088,9089"
```
Reviewed By: lblasa, timur-valiev
Differential Revision: D30731874
fbshipit-source-id: 689d60b1c392f36dceef1b3c3cfa0c88f54a7a82
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2764
Reviewed By: lblasa
Differential Revision: D30727119
Pulled By: passy
fbshipit-source-id: 67e5f9bf429244c009d2a27134eb4867ff16d254
Summary: Revert D30371791 (cac09d14aa) to address undefined symbols for a few sandcastle jobs
Reviewed By: fabiomassimo
Differential Revision: D30606610
fbshipit-source-id: 24a5c08bcf5456a96469650a4207b05970399181
Summary:
Contains the implementation of FlipperWebSocket with any necessary changes to use it but without switching it on.
About SocketRocket and Cocoapods
A decision had to be made about whether to define different sub-specs, one for RSocket and another for SocketRocket.
I've opted to keep the podspec as is because:
- Keeps pod consumption as is.
- Makes easier to switch implementations using GK.
- There's no intention to keep RSocket going into the future. So, there's no point in creating a sub-spec only to remove it in the future.
- SocketRocket is a relatively small library so is not contributing to a significant increase in binary size.
If, as reviewer, you consider a subspec makes more sense, then feel free to reach out to discuss.
Reviewed By: fabiomassimo
Differential Revision: D30371791
fbshipit-source-id: 225c5b1de76aff1a6e36640a41765b963aaa2796
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2738
Reviewed By: lblasa
Differential Revision: D30573139
Pulled By: passy
fbshipit-source-id: 0b4f36bfe326fff2e543786572fbc6d17bef6c8b
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2664
Test Plan:
Imported from GitHub, without a `Test Plan:` line.
|[Site Preview: flipper](https://our.intern.facebook.com/intern/staticdocs/eph/D30156476/V2/flipper/)
Reviewed By: passy
Differential Revision: D30156476
Pulled By: nikoant
fbshipit-source-id: 04d3ea60a59fc2fe0507319bd6261376388ec31a
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2662
Test Plan:
Imported from GitHub, without a `Test Plan:` line.
|[Site Preview: flipper](https://our.intern.facebook.com/intern/staticdocs/eph/D30131497/V2/flipper/)
Reviewed By: nikoant
Differential Revision: D30131497
Pulled By: passy
fbshipit-source-id: f321dc0187da2660f585d5f3d47531d7aa19d818
Summary:
This is an automated PR to update the Podfile.lock.
- Make sure that the Podfile.lock contains latest FlipperKit and Flipper pod versions.
- Also make sure that all the dependencies are updated to the latest one.
- This is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
Pull Request resolved: https://github.com/facebook/flipper/pull/2637
Reviewed By: passy
Differential Revision: D29962132
Pulled By: cekkaewnumchai
fbshipit-source-id: 98cb91e790a80eac9ca530856f909e0a744e40d0