Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 000af7f

Browse files
authored
Merge 2e594aa into sapling-pr-archive-passy
2 parents b01b935 + 2e594aa commit 000af7f

File tree

285 files changed

+5176
-1820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+5176
-1820
lines changed

Flipper.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
55

6-
flipperkit_version = '0.233.0'
6+
flipperkit_version = '0.250.0'
77
Pod::Spec.new do |spec|
88
spec.name = 'Flipper'
99
spec.cocoapods_version = '>= 1.10'

FlipperKit.podspec

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# LICENSE file in the root directory of this source tree.
55

66
folly_compiler_flags = '-DDEBUG=1 -DFLIPPER_OSS=1 -DFB_SONARKIT_ENABLED=1 -DFOLLY_HAVE_BACKTRACE=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0'
7-
flipperkit_version = '0.233.0'
7+
flipperkit_version = '0.250.0'
88
Pod::Spec.new do |spec|
99
spec.name = 'FlipperKit'
1010
spec.version = flipperkit_version
@@ -18,6 +18,7 @@ Pod::Spec.new do |spec|
1818
spec.module_name = 'FlipperKit'
1919
spec.platforms = { :ios => "11.0" }
2020
spec.default_subspecs = "Core"
21+
spec.frameworks = 'AVFoundation'
2122

2223
# This subspec is necessary since FBDefines.h is imported as <FBDefines/FBDefines.h>
2324
# inside SKMacros.h, which is a public header file. Defining this directory as a
@@ -77,6 +78,7 @@ Pod::Spec.new do |spec|
7778
ss.dependency 'FlipperKit/FKPortForwarding'
7879
ss.dependency 'Flipper', '~>'+flipperkit_version
7980
ss.dependency 'SocketRocket', '~> 0.7.0'
81+
ss.dependency 'SSZipArchive', '~> 2.4.3'
8082
ss.compiler_flags = folly_compiler_flags
8183
ss.source_files = 'iOS/FlipperKit/*.{h,m,mm}', 'iOS/FlipperKit/CppBridge/*.{h,mm}'
8284
ss.public_header_files = 'iOS/FlipperKit/**/{FlipperDiagnosticsViewController,FlipperStateUpdateListener,FlipperClient,FlipperPlugin,FlipperConnection,FlipperResponder,SKMacros,FlipperKitCertificateProvider}.h'

README.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ The last Electron release is [v0.239.0](https://github.com/facebook/flipper/rele
2727

2828
### React Native support
2929

30-
If you are debugging React Native applications, v0.239.0 will be the last release with support for it due to technical limitations for React Dev Tools and Hermes Debugger plugins. As such, please refer to that release when debugging React Native applications.
30+
If you are debugging React Native applications, [v0.239.0](https://github.com/facebook/flipper/releases/tag/v0.239.0) will be the last release with support for it due to technical limitations for React Dev Tools and Hermes Debugger plugins. As such, please refer to that release when debugging React Native applications.
31+
32+
New, dedicated debug tooling for React Native is currently being developed at Meta.
33+
In the mean time we recommend this [blog post](https://shift.infinite.red/why-you-dont-need-flipper-in-your-react-native-app-and-how-to-get-by-without-it-3af461955109) with guidance on how to get the capibilities of Flipper through several alternatives.
3134

3235
---
3336

3437
<p align="center">
35-
Flipper (formerly Sonar) is a platform for debugging mobile apps on iOS and Android and JS apps in your browser or in Node.js. Visualize, inspect, and control your apps from a simple desktop interface. Use Flipper as is or extend it using the plugin API.
38+
Flipper is a platform for debugging mobile apps on iOS and Android and JS apps in your browser or in Node.js. Visualize, inspect, and control your apps from a simple desktop interface. Use Flipper as is or extend it using the plugin API.
3639
</p>
3740

3841
![Flipper](website/static/img/inspector.png)
@@ -83,27 +86,23 @@ This repository includes all parts of Flipper. This includes:
8386
(`/desktop`)
8487
- native Flipper SDKs for iOS (`/iOS`)
8588
- native Flipper SDKs for Android (`/android`)
89+
- cross-platform C++ SDK (`/xplat`)
8690
- React Native Flipper SDK (`/react-native`)
8791
- JS Flipper SDK (`/js`)
88-
- Plugins:
89-
- Logs (`/desktop/plugins/public/logs`)
90-
- Layout inspector (`/desktop/plugins/public/layout`)
91-
- Network inspector (`/desktop/plugins/public/network`)
92-
- Shared Preferences/NSUserDefaults inspector
93-
(`/desktop/plugins/public/shared_preferences`)
94-
- website and documentation (`/website` / `/docs`)
92+
- Plugins (`/desktop/plugins/public/`)
93+
- website and documentation (`/website`, `/docs`)
9594

9695
# Getting started
9796

9897
Please refer to our
9998
[Getting Started guide](https://fbflipper.com/docs/getting-started) to set up
100-
Flipper. Or, (still experimental) run `npx flipper-server` for a browser based
99+
Flipper. Or, run `npx flipper-server` for a browser based
101100
version of Flipper.
102101

103102
## Requirements
104103

105-
- node >= 8
106-
- yarn >= 1.5
104+
- node >= 18
105+
- yarn >= 1.16
107106
- iOS developer tools (for developing iOS plugins)
108107
- Android SDK and adb
109108

@@ -120,16 +119,13 @@ yarn
120119
yarn start
121120
```
122121

123-
NOTE: If you're on Windows, you need to use Yarn 1.5.1 until
124-
[this issue](https://github.com/yarnpkg/yarn/issues/6048) is resolved.
125-
126122
### Building standalone application
127123

128124
Provide either `--mac`, `--win`, `--linux` or any combination of them to
129125
`yarn build` to build a release zip file for the given platform(s). E.g.
130126

131127
```bash
132-
yarn build --mac --version $buildNumber
128+
yarn build --mac
133129
```
134130

135131
You can find the resulting artifact in the `dist/` folder.

android/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ android {
7676
implementation deps.openssl
7777
implementation deps.fbjni
7878
implementation deps.soloader
79+
implementation deps.curtains
7980
implementation deps.jsr305
8081
implementation deps.supportAppCompat
8182
implementation deps.supportSqlite

android/plugins/jetpack-compose/build.gradle

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ android {
2727

2828
dependencies {
2929
implementation project(':android')
30-
implementation 'androidx.compose.ui:ui:1.4.3'
31-
implementation 'androidx.compose.ui:ui-tooling:1.4.3'
32-
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.9.21'
30+
implementation "androidx.compose.ui:ui:$COMPOSE_VERSION"
31+
implementation "androidx.compose.ui:ui-tooling:$COMPOSE_VERSION"
32+
implementation "androidx.compose.ui:ui-tooling-data:$COMPOSE_VERSION"
33+
implementation "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"
34+
implementation "androidx.collection:collection-ktx:1.4.0"
3335
implementation project(':inspection-lib')
36+
implementation deps.soloader
3437
}
3538
}
3639

android/plugins/jetpack-compose/src/main/java/com/facebook/flipper/plugins/jetpackcompose/UIDebuggerComposeSupport.kt

+40-5
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,58 @@
77

88
package com.facebook.flipper.plugins.jetpackcompose
99

10-
import androidx.compose.ui.platform.ComposeView
11-
import com.facebook.flipper.plugins.jetpackcompose.descriptors.*
12-
import com.facebook.flipper.plugins.jetpackcompose.model.*
10+
import android.os.Build
11+
import android.util.Log
12+
import androidx.compose.ui.platform.AbstractComposeView
13+
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
14+
import com.facebook.flipper.plugins.jetpackcompose.descriptors.AbstractComposeViewDescriptor
15+
import com.facebook.flipper.plugins.jetpackcompose.descriptors.ComposeInnerViewDescriptor
16+
import com.facebook.flipper.plugins.jetpackcompose.descriptors.ComposeNodeDescriptor
17+
import com.facebook.flipper.plugins.jetpackcompose.model.ComposeInnerViewNode
18+
import com.facebook.flipper.plugins.jetpackcompose.model.ComposeNode
1319
import com.facebook.flipper.plugins.uidebugger.core.UIDContext
1420
import com.facebook.flipper.plugins.uidebugger.descriptors.DescriptorRegister
21+
import com.facebook.soloader.SoLoader
1522

16-
const val JetpackComposeTag = "JetpackCompose"
23+
const val JetpackComposeTag = "Compose"
1724

1825
object UIDebuggerComposeSupport {
1926

27+
private const val TAG = "UIDebuggerCompose"
28+
29+
init {
30+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
31+
try {
32+
SoLoader.loadLibrary("art_tooling")
33+
} catch (t: Throwable) {
34+
Log.e(TAG, "Failed to load native library.", t)
35+
}
36+
enableDebugInspectorInfo()
37+
}
38+
}
39+
2040
fun enable(context: UIDContext) {
2141
addDescriptors(context.descriptorRegister)
2242
}
2343

2444
private fun addDescriptors(register: DescriptorRegister) {
25-
register.register(ComposeView::class.java, ComposeViewDescriptor)
45+
register.register(AbstractComposeView::class.java, AbstractComposeViewDescriptor)
2646
register.register(ComposeNode::class.java, ComposeNodeDescriptor)
2747
register.register(ComposeInnerViewNode::class.java, ComposeInnerViewDescriptor)
2848
}
49+
50+
private fun enableDebugInspectorInfo() {
51+
// Set isDebugInspectorInfoEnabled to true via reflection such that Redex and R8 cannot see the
52+
// assignment. This allows the InspectorInfo lambdas to be stripped from release builds.
53+
if (!isDebugInspectorInfoEnabled) {
54+
try {
55+
val packageClass = Class.forName("androidx.compose.ui.platform.InspectableValueKt")
56+
val field = packageClass.getDeclaredField("isDebugInspectorInfoEnabled")
57+
field.isAccessible = true
58+
field.setBoolean(null, true)
59+
} catch (ex: Exception) {
60+
Log.e(TAG, "Could not access isDebugInspectorInfoEnabled.", ex)
61+
}
62+
}
63+
}
2964
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.flipper.plugins.jetpackcompose.descriptors
9+
10+
import android.os.Build
11+
import android.os.Debug
12+
import android.util.Log
13+
import android.view.View
14+
import androidx.annotation.RequiresApi
15+
import androidx.compose.ui.platform.AbstractComposeView
16+
import androidx.inspection.DefaultArtTooling
17+
import com.facebook.flipper.plugins.jetpackcompose.model.ComposeNode
18+
import com.facebook.flipper.plugins.uidebugger.descriptors.ChainedDescriptor
19+
import com.facebook.flipper.plugins.uidebugger.descriptors.WarningMessage
20+
import facebook.internal.androidx.compose.ui.inspection.RecompositionHandler
21+
import facebook.internal.androidx.compose.ui.inspection.inspector.InspectorNode
22+
import facebook.internal.androidx.compose.ui.inspection.inspector.LayoutInspectorTree
23+
import java.io.IOException
24+
25+
object AbstractComposeViewDescriptor : ChainedDescriptor<AbstractComposeView>() {
26+
private val recompositionHandler by lazy {
27+
RecompositionHandler(DefaultArtTooling("Flipper")).apply {
28+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
29+
attachJvmtiAgent()
30+
startTrackingRecompositions(this)
31+
}
32+
}
33+
}
34+
35+
override fun onGetName(node: AbstractComposeView): String = node.javaClass.simpleName
36+
37+
private fun transform(
38+
view: View,
39+
nodes: List<InspectorNode>,
40+
layoutInspectorTree: LayoutInspectorTree
41+
): List<ComposeNode> {
42+
val positionOnScreen = IntArray(2)
43+
view.getLocationInWindow(positionOnScreen)
44+
45+
val xOffset = positionOnScreen[0]
46+
val yOffset = positionOnScreen[1]
47+
48+
return nodes.map { node ->
49+
ComposeNode(view, layoutInspectorTree, recompositionHandler, node, xOffset, yOffset)
50+
}
51+
}
52+
53+
override fun onGetChildren(node: AbstractComposeView): List<Any> {
54+
val children = mutableListOf<Any>()
55+
val count = node.childCount - 1
56+
for (i in 0..count) {
57+
val child: View = node.getChildAt(i)
58+
children.add(child)
59+
60+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
61+
val layoutInspector = LayoutInspectorTree()
62+
layoutInspector.hideSystemNodes = true
63+
val composeNodes =
64+
try {
65+
transform(child, layoutInspector.convert(child), layoutInspector)
66+
} catch (t: Throwable) {
67+
listOf(
68+
WarningMessage(
69+
"Unknown error occurred while trying to inspect compose node: ${t.message}",
70+
getBounds(node)))
71+
}
72+
return if (composeNodes.isNullOrEmpty()) {
73+
listOf(
74+
WarningMessage(
75+
"Go to developer options and make sure that \"Enable view attribute inspection\" option is enabled.",
76+
getBounds(node)))
77+
} else {
78+
composeNodes
79+
}
80+
}
81+
}
82+
83+
return children
84+
}
85+
86+
@RequiresApi(Build.VERSION_CODES.Q)
87+
private fun attachJvmtiAgent() {
88+
try {
89+
Debug.attachJvmtiAgent("nonexistent.so", null, null)
90+
} catch (e: IOException) {
91+
// expected: "nonexistent.so" doesn't exist, however attachJvmtiAgent call is enough
92+
// to make art to load JVMTI plugin.
93+
}
94+
}
95+
96+
private fun startTrackingRecompositions(recompositionHandler: RecompositionHandler) {
97+
try {
98+
recompositionHandler.changeCollectionMode(startCollecting = true, keepCounts = true)
99+
} catch (t: Throwable) {
100+
Log.e("ComposeViewDescriptor", "Failed to start tracking recompositions", t)
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)