Summary:
rename FLEXNetworkLib to SKFLEXNetworkLib so it doesnt clash with Stock FLEX if embedded in the app too
also 'fix' 3 warnings by adding explicit casts
Reviewed By: lblasa
Differential Revision: D35200011
fbshipit-source-id: 82bdecc5076b86958ea0cb80260584c012940045
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:
Flipper Network plugin uses timestamps for various usages e.g. start time of network requests, request duration, etc.
This diff changes the origin of such timestamps.
[NSDate timeIntervalSinceReferenceDate] in favour of FBMonotonicDeviceTimeGetCurrentMilliseconds().
The former uses a timestamp based on date. The latter uses the system boot time.
This translates in errors when the Flipper Desktop app tries to make sense of such timestamps.
This change also adds parity with the Android network plugin that uses System.currentTimeMillis().
The result is multiplied by 1000 as JavaScript expects a timestamp in millseconds.
Reviewed By: fabiomassimo
Differential Revision: D29029192
fbshipit-source-id: b38a4798ecf1564f5801ff3549ffeb9671fa32d6
Summary:
This PR fixes the crash mentioned [here](https://github.com/facebook/flipper/issues/1674#issuecomment-754402609) in the https://github.com/facebook/flipper/issues/1674 . The issue was that logging `NSLog(@"%@", [self valueForKey:@"_methodDescription"]);` in the swizzled network delegate class used to cause a crash. The cause of this was the nil `methodDescription.types` sent to `class_addMethod`.
In the following change we do not add a method to the class which doesn't implement the selector, we will anyway listen for those events from the base NSURLSession class. Removing the `class_addMethod`, fixes both the issue mentioned
[here](https://github.com/facebook/flipper/issues/1674#issuecomment-754402609) in https://github.com/facebook/flipper/issues/1674.
This PR also fixes an issue where no network calls where logged in Flipper when the iOS version was 14, the reason was that the URLSessionResume task was not properly swizzled for 14.
## Changelog
- Do not add a runtime method to the delegate which doesn't implement a responder
- Fix swizzling logic of the URLSession task resume method for ios 14
Pull Request resolved: https://github.com/facebook/flipper/pull/1810
Test Plan:
- I ran the sample app and checked that the network calls are logged.
- I copy pasted the changes in RN project and verified that the issues mentioned in https://github.com/facebook/flipper/issues/1674 doesn't happen and also verified that the network calls being hit from JS and Native code gets logged in Flipper. Verified with IsolatedSwizzles.zip mentioned over [here](https://github.com/facebook/flipper/issues/1674#issuecomment-754726174). Also verified by copy pasting the code in the fresh RN project.
Reviewed By: fabiomassimo
Differential Revision: D25801510
Pulled By: mweststrate
fbshipit-source-id: 53ef574696d2abbdbfc2b6d94769327cdfa8aa2b
Summary: This adds macOS compatibility to Flipper client along with some of the standard plugins.
Reviewed By: jknoxville
Differential Revision: D24644439
fbshipit-source-id: dc15636a6ac1bf684fa1c89735f51f0e97667b62
Summary:
Changelog: [iOS][Network] Network plugin now supports iOS 14
Network plugin stopped working for iOS 14 as reported in https://github.com/facebook/flipper/issues/1534.
The fix is based on the origin Flex network observer, as seen in https://github.com/FLEXTool/FLEX/pull/451
- NetworkPlugin supports iOS 14+
Pull Request resolved: https://github.com/facebook/flipper/pull/1543
Test Plan: Verified manually that before this fix the network plugin broken on iOS 14, and after it, it initializes correctly.
Reviewed By: passy
Differential Revision: D24136401
Pulled By: mweststrate
fbshipit-source-id: 87e0e0fa4bc927d082387d937390b1e728125753
Summary:
This diff fixes the warnings raised from FlipperKit. Also this diff updates the deployement target of FlipperKit to iOS 10. Even wilde assumes the min deployment OS version to be iOS 10. In layout plugin we use [UIAccessibiltyTraiTabBar](https://developer.apple.com/documentation/uikit/uiaccessibility/uiaccessibilitytraits/1648592-tabbar), which assumes iOS 10 and above.
Partially fixes https://github.com/facebook/flipper/issues/803
Still there are some warnings which are coming from the dependencies outside of Flipper.
Reviewed By: passy
Differential Revision: D19941558
fbshipit-source-id: 31809fedb9aa297bc318b5af72e29e8444f0142f
Summary:
This diff runs CLANGFORMAT lint on plugins. I have added CLANGFORMAT as the lint engined for objc files in xplat/sonar. Right now the iOS folder is not formatted according to CLANGFORMAT.
Ran `arc lint -a --paths-cmd "find ./iOS/Plugins -type f" --verbose`
Reviewed By: passy
Differential Revision: D19942173
fbshipit-source-id: 8b975b0a344df073b02d69cd1f9ee5629af2799d
Summary:
Flipper's network plugin may cause crash on a frequency of about one time per 1~2 days(I think it depends on how many network request we send).

I assume the crash is caused by part of the code of HTTPParser is not thread-safe, and invoke it asynchronously may cause double-free crash. So I manually ask for HTTPBody synchronously, make the HTTPParser parse the request and cache them in advance, before any possible asynchronous invoking.
## Changelog
Fix potential crash cause by network plugin.
Pull Request resolved: https://github.com/facebook/flipper/pull/563
Test Plan:
1. Run our App with Flipper integrated
2. Make sure FlipperNetworkPlugin is active
3. It may take days to reproduce the crash
Reviewed By: passy
Differential Revision: D17739327
Pulled By: priteshrnandgaonkar
fbshipit-source-id: e814145c346bd2da1d2f5f87b6a2f7e200f0bf2d
Summary:
Bugfix
Add protect when save task
If local cache resource are valid, we don't create a Task .So here are crash.
Pull Request resolved: https://github.com/facebook/flipper/pull/466
Reviewed By: passy
Differential Revision: D15851816
Pulled By: priteshrnandgaonkar
fbshipit-source-id: 753b3c5c9a6ed4c703c934a89e45fa30df99068c
Summary:
`/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3
In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf.
Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too.
Reviewed By: zertosh
Differential Revision: D15640366
fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
Summary: Add the affiliates bit that the linter is checking for.
Reviewed By: jknoxville
Differential Revision: D15164826
fbshipit-source-id: 500ffe89ec0c2fd3acfbc374408d16a337cecfa4
Summary:
This diff sets up flipper for running plugins in background. This diff does the following
- Adds a function named `runInBackground` to the interface `FlipperPlugin` to make the plugins opt in to be run in background, default is false
- Changes the javascript side of the flipper to store the messages received by the plugins in background
- Process the stored messages when the plugin in background becomes active
- Currently I have just turned on network plugin to be in background mode.
- Remove the buffering from the network plugin, as it will run in background
- Write a batching layer to batch the messages and send to flipper.
Note: I haven't tested the wilde app yet, but the sample app works. I will remove the "[WIP]" from the title once I have tested it in wilde
Reviewed By: danielbuechele
Differential Revision: D10301403
fbshipit-source-id: 034eebf659a545d6b480a4ac1b73b0aa4b2f9797
Summary: Renames the file name of SonarKitNetworkPlugin to FlipperKitNetworkPlugin
Reviewed By: passy
Differential Revision: D9972211
fbshipit-source-id: c092c75f0e1bab54cd247e3ae69449577453ec07