Skip to content

Commit

Permalink
Merge eae4f07 into sapling-pr-archive-passy
Browse files Browse the repository at this point in the history
  • Loading branch information
passy authored Aug 25, 2023
2 parents d37a95b + eae4f07 commit f8b934f
Show file tree
Hide file tree
Showing 164 changed files with 5,025 additions and 1,875 deletions.
2 changes: 1 addition & 1 deletion Flipper.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

flipperkit_version = '0.210.0'
flipperkit_version = '0.212.0'
Pod::Spec.new do |spec|
spec.name = 'Flipper'
spec.cocoapods_version = '>= 1.10'
Expand Down
2 changes: 1 addition & 1 deletion FlipperKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# LICENSE file in the root directory of this source tree.

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'
flipperkit_version = '0.210.0'
flipperkit_version = '0.212.0'
Pod::Spec.new do |spec|
spec.name = 'FlipperKit'
spec.version = flipperkit_version
Expand Down
7 changes: 0 additions & 7 deletions android/plugins/jetpack-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,3 @@ android {


apply plugin: 'com.vanniktech.maven.publish'

import com.vanniktech.maven.publish.SonatypeHost
mavenPublishing {
// Disable javadoc publishing
publishToMavenCentral(SonatypeHost.DEFAULT, false)
}

7 changes: 7 additions & 0 deletions android/src/main/cpp/sonar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ class JFlipperWebSocket : public facebook::flipper::FlipperSocket {
if (socket_ == nullptr) {
return;
}
// Ensure the payload size is valid before sending.
// The maximum allowed size for a message payload is 2^53 - 1. But that is
// for the entire message, including any additional metadata.
if (message.length() > pow(2, 53) - 1) {
throw std::length_error("Payload is too big to send");
}

socket_->send(message);
completion();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.facebook.flipper.core.FlipperConnection;
import com.facebook.flipper.core.FlipperPlugin;

// This plugin is not needed, but kept here for backward compatilibty
// This plugin is not needed, but kept here for backward compatibility
@Deprecated
public class ReactFlipperPlugin implements FlipperPlugin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class UIDebuggerFlipperPlugin(val context: UIDContext) : FlipperPlugin {
MetadataUpdateEvent(MetadataRegister.extractPendingMetadata())))

context.treeObserverManager.start()

context.connectionListeners.forEach { it.onConnect() }
}

@Throws(Exception::class)
Expand All @@ -59,6 +61,8 @@ class UIDebuggerFlipperPlugin(val context: UIDContext) : FlipperPlugin {

context.treeObserverManager.stop()
context.bitmapPool.recycleAll()
context.connectionListeners.forEach { it.onDisconnect() }
context.clearFrameworkEvents()
}

override fun runInBackground(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,62 @@ import android.app.Application
import com.facebook.flipper.core.FlipperConnection
import com.facebook.flipper.plugins.uidebugger.common.BitmapPool
import com.facebook.flipper.plugins.uidebugger.descriptors.DescriptorRegister
import com.facebook.flipper.plugins.uidebugger.model.FrameworkEvent
import com.facebook.flipper.plugins.uidebugger.model.FrameworkEventMetadata
import com.facebook.flipper.plugins.uidebugger.observers.TreeObserverFactory
import com.facebook.flipper.plugins.uidebugger.observers.TreeObserverManager
import com.facebook.flipper.plugins.uidebugger.scheduler.SharedThrottle
import com.facebook.flipper.plugins.uidebugger.traversal.PartialLayoutTraversal

data class UIDContext(
interface ConnectionListener {
fun onConnect()

fun onDisconnect()
}

class UIDContext(
val applicationRef: ApplicationRef,
val connectionRef: ConnectionRef,
val descriptorRegister: DescriptorRegister,
val observerFactory: TreeObserverFactory,
val frameworkEventMetadata: MutableList<FrameworkEventMetadata>
val frameworkEventMetadata: MutableList<FrameworkEventMetadata>,
val connectionListeners: MutableList<ConnectionListener>,
private val pendingFrameworkEvents: MutableList<FrameworkEvent>
) {

val layoutTraversal: PartialLayoutTraversal =
PartialLayoutTraversal(descriptorRegister, observerFactory)

val treeObserverManager = TreeObserverManager(this)
val sharedThrottle: SharedThrottle = SharedThrottle()
val bitmapPool = BitmapPool()

fun addFrameworkEvent(frameworkEvent: FrameworkEvent) {
synchronized(pendingFrameworkEvents) { pendingFrameworkEvents.add(frameworkEvent) }
}

fun extractPendingFrameworkEvents(): List<FrameworkEvent> {
synchronized(pendingFrameworkEvents) {
val copy = pendingFrameworkEvents.toList()
pendingFrameworkEvents.clear()
return copy
}
}

fun clearFrameworkEvents() {
synchronized(pendingFrameworkEvents) { pendingFrameworkEvents.clear() }
}

companion object {
fun create(application: Application): UIDContext {
return UIDContext(
ApplicationRef(application),
ConnectionRef(null),
descriptorRegister = DescriptorRegister.withDefaults(),
observerFactory = TreeObserverFactory.withDefaults(),
frameworkEventMetadata = mutableListOf())
frameworkEventMetadata = mutableListOf(),
connectionListeners = mutableListOf(),
pendingFrameworkEvents = mutableListOf())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ data class FrameworkEventMetadata(

@kotlinx.serialization.Serializable
data class FrameworkEvent(
val treeId: Id,
val nodeId: Id,
val type: String,
val timestamp: Long,
val timestamp: Long, // millis since epoch
val duration: Long?, // in Nanoseconds
val thread: String,
val payload: Map<String, String> // can be json
)
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TreeObserverManager(val context: UIDContext) {
val workerThreadStartTimestamp = System.currentTimeMillis()

val nodes = batchedUpdate.updates.flatMap { it.deferredNodes.map { it.value() } }
val frameworkEvents = batchedUpdate.updates.flatMap { it.frameworkEvents ?: listOf() }
val frameworkEvents = context.extractPendingFrameworkEvents()
val snapshotUpdate = batchedUpdate.updates.find { it.snapshot != null }
val deferredComputationEndTimestamp = System.currentTimeMillis()

Expand Down
4 changes: 2 additions & 2 deletions desktop/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"flipper-server-companion": "0.0.0",
"flipper-server-core": "0.0.0",
"flipper-ui-core": "0.0.0",
"fs-extra": "^11.1.0",
"fs-extra": "^11.1.1",
"invariant": "^2.2.2",
"metro-runtime": "^0.70.2",
"pretty-format": "^27.5.0",
"reconnecting-websocket": "^4.4.0",
"ws": "8.8.0"
"ws": "8.13.0"
},
"optionalDependencies": {},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion desktop/app/src/electron/initializeElectron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export async function initializeElectron(
return {
data,
name: fileName,
path: filePath,
};
}),
);
Expand Down
17 changes: 3 additions & 14 deletions desktop/app/src/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
loadLauncherSettings,
loadProcessConfig,
loadSettings,
sessionId,
setupPrefetcher,
startFlipperServer,
startServer,
Expand All @@ -45,9 +46,7 @@ import constants from './fb-stubs/constants';
import {initializeElectron} from './electron/initializeElectron';
import path from 'path';
import fs from 'fs-extra';
import os from 'os';
import {ElectronIpcClientRenderer} from './electronIpc';
import {checkSocketInUse, makeSocketPath} from 'flipper-server-core';
import {KeytarModule} from 'flipper-server-core/src/utils/keytar';
import {initCompanionEnv} from 'flipper-server-companion';
import ReconnectingWebSocket from 'reconnecting-websocket';
Expand Down Expand Up @@ -118,8 +117,6 @@ async function getFlipperServer(

const serverUsageEnabled = gatekeepers['flipper_desktop_use_server'];
const settings = await loadSettings();

const socketPath = await makeSocketPath();
const port = 52342;
/**
* Only attempt to use the auth token if one is available. Otherwise,
Expand All @@ -134,7 +131,6 @@ async function getFlipperServer(
// check first with the actual TCP socket
const searchParams = new URLSearchParams(token ? {token} : {});
const TCPconnectionURL = new URL(`ws://localhost:${port}?${searchParams}`);
const UDSconnectionURL = new URL(`ws+unix://${socketPath}`);

/**
* Attempt to shutdown a running instance of Flipper server.
Expand All @@ -159,12 +155,7 @@ async function getFlipperServer(
*/
if (await checkPortInUse(port)) {
console.warn(`[flipper-server] TCP port ${port} is already in use.`);

await shutdown(TCPconnectionURL);
} else if (await checkSocketInUse(socketPath)) {
console.warn(`[flipper-server] UDS socket is already in use.`);

await shutdown(UDSconnectionURL);
}

const [homePath, tempPath, desktopPath] = await Promise.all([
Expand All @@ -176,6 +167,7 @@ async function getFlipperServer(
const getEmbeddedServer = async () => {
const server = new FlipperServerImpl(
{
sessionId,
environmentInfo,
env: parseEnvironmentVariables(env),
gatekeepers: gatekeepers,
Expand Down Expand Up @@ -206,7 +198,6 @@ async function getFlipperServer(
const {readyForIncomingConnections} = await startServer({
staticPath,
entry: 'index.web.dev.html',
tcp: false,
port,
});

Expand All @@ -224,9 +215,7 @@ async function getFlipperServer(
await server.connect();
await readyForIncomingConnections(server, companionEnv);

return getExternalServer(
os.platform() === 'win32' ? TCPconnectionURL : UDSconnectionURL,
);
return getExternalServer(TCPconnectionURL);
}
return getEmbeddedServer();
}
Expand Down
4 changes: 2 additions & 2 deletions desktop/doctor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"author": "Facebook, Inc",
"dependencies": {
"envinfo": "^7.8.1",
"fb-watchman": "^2.0.1",
"fb-watchman": "^2.0.2",
"flipper-common": "0.0.0",
"fs-extra": "^11.1.0"
"fs-extra": "^11.1.1"
}
}
2 changes: 1 addition & 1 deletion desktop/eslint-plugin-flipper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@typescript-eslint/experimental-utils": "^5.22.0",
"@typescript-eslint/parser": "^5.55.0",
"fs-extra": "^11.1.0"
"fs-extra": "^11.1.1"
},
"devDependencies": {},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion desktop/examples/headless-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"start": "node index.js"
},
"dependencies": {
"ws": "^8.6.0"
"ws": "^8.13.0"
},
"files": [
"*.js",
Expand Down
2 changes: 1 addition & 1 deletion desktop/examples/headless-tic-tac-toe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"inquirer": "^8.2.4",
"ws": "^8.6.0"
"ws": "^8.13.0"
},
"files": [
"*.js",
Expand Down
2 changes: 2 additions & 0 deletions desktop/flipper-common/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export {
setLoggerInstance,
NoopLogger,
} from './utils/Logger';
export * from './utils/LoggerTailer';
export * from './utils/ScribeLogger';
export * from './server-types';
export * from './companion-types';
export * from './ServerAddOn';
Expand Down
7 changes: 5 additions & 2 deletions desktop/flipper-common/src/server-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ export type FlipperServerCommands = {
name: string,
) => Promise<InstalledPluginDetails>;
'plugins-install-from-npm': (name: string) => Promise<InstalledPluginDetails>;
'plugins-install-from-file': (
path: string,
'plugins-install-from-content': (
contents: string,
) => Promise<InstalledPluginDetails>;
'plugins-remove-plugins': (names: string[]) => Promise<void>;
'plugins-server-add-on-start': (
Expand Down Expand Up @@ -351,6 +351,7 @@ export type FlipperServerCommands = {
options: {
timeout?: number;
internGraphUrl?: string;
headers?: Record<string, string | number | boolean>;
},
) => Promise<GraphResponse>;
'intern-graph-get': (
Expand All @@ -359,6 +360,7 @@ export type FlipperServerCommands = {
options: {
timeout?: number;
internGraphUrl?: string;
headers?: Record<string, string | number | boolean>;
},
) => Promise<GraphResponse>;
'intern-upload-scribe-logs': (
Expand Down Expand Up @@ -524,6 +526,7 @@ export type FlipperServerConfig = {
validWebSocketOrigins: string[];
environmentInfo: EnvironmentInfo;
type?: FlipperServerType;
sessionId: string;
};

export interface FlipperServerExecOptions {
Expand Down
Loading

0 comments on commit f8b934f

Please sign in to comment.