Concurrent Function Upgrade for Enhanced Performance (#4918)
Summary: Republishing sanjaiyan-dev's PR https://github.com/facebook/flipper/pull/4889 running `git rebase` because of a conflict. Pull Request resolved: https://github.com/facebook/flipper/pull/4918 Reviewed By: lblasa Differential Revision: D47294545 Pulled By: passy fbshipit-source-id: 74904ec6179ed5a3bab6f9b701c3cd769ecad3bf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c8776175c3
commit
7cef8286f9
@@ -29,8 +29,10 @@ export async function initializeElectron(
|
|||||||
flipperServerConfig: FlipperServerConfig,
|
flipperServerConfig: FlipperServerConfig,
|
||||||
electronIpcClient: ElectronIpcClientRenderer,
|
electronIpcClient: ElectronIpcClientRenderer,
|
||||||
) {
|
) {
|
||||||
const electronProcess = await electronIpcClient.send('getProcess');
|
const [electronProcess, electronTheme] = await Promise.all([
|
||||||
const electronTheme = await electronIpcClient.send('getNativeTheme');
|
electronIpcClient.send('getProcess'),
|
||||||
|
electronIpcClient.send('getNativeTheme'),
|
||||||
|
]);
|
||||||
|
|
||||||
const execPath = process.execPath || electronProcess.execPath;
|
const execPath = process.execPath || electronProcess.execPath;
|
||||||
const isProduction = !/node_modules[\\/]electron[\\/]/.test(execPath);
|
const isProduction = !/node_modules[\\/]electron[\\/]/.test(execPath);
|
||||||
|
|||||||
@@ -167,6 +167,12 @@ async function getFlipperServer(
|
|||||||
await shutdown(UDSconnectionURL);
|
await shutdown(UDSconnectionURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [homePath, tempPath, desktopPath] = await Promise.all([
|
||||||
|
electronIpcClient.send('getPath', 'home'),
|
||||||
|
electronIpcClient.send('getPath', 'temp'),
|
||||||
|
electronIpcClient.send('getPath', 'desktop'),
|
||||||
|
]);
|
||||||
|
|
||||||
const getEmbeddedServer = async () => {
|
const getEmbeddedServer = async () => {
|
||||||
const server = new FlipperServerImpl(
|
const server = new FlipperServerImpl(
|
||||||
{
|
{
|
||||||
@@ -175,11 +181,11 @@ async function getFlipperServer(
|
|||||||
gatekeepers: gatekeepers,
|
gatekeepers: gatekeepers,
|
||||||
paths: {
|
paths: {
|
||||||
appPath,
|
appPath,
|
||||||
homePath: await electronIpcClient.send('getPath', 'home'),
|
homePath,
|
||||||
execPath,
|
execPath,
|
||||||
staticPath,
|
staticPath,
|
||||||
tempPath: await electronIpcClient.send('getPath', 'temp'),
|
tempPath,
|
||||||
desktopPath: await electronIpcClient.send('getPath', 'desktop'),
|
desktopPath,
|
||||||
},
|
},
|
||||||
launcherSettings: await loadLauncherSettings(),
|
launcherSettings: await loadLauncherSettings(),
|
||||||
processConfig: loadProcessConfig(env),
|
processConfig: loadProcessConfig(env),
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ async function start(deviceQuery: string, appName: string, pluginId: string) {
|
|||||||
const environmentInfo = await getEnvironmentInfo(staticPath, false, true);
|
const environmentInfo = await getEnvironmentInfo(staticPath, false, true);
|
||||||
// TODO: initialise FB user manager to be able to do certificate exchange
|
// TODO: initialise FB user manager to be able to do certificate exchange
|
||||||
|
|
||||||
|
const [launcherSettings, settings] = await Promise.all([
|
||||||
|
loadLauncherSettings(argv.launcherSettings),
|
||||||
|
loadSettings(argv.settingsString),
|
||||||
|
]);
|
||||||
const server = new FlipperServerImpl(
|
const server = new FlipperServerImpl(
|
||||||
{
|
{
|
||||||
environmentInfo,
|
environmentInfo,
|
||||||
@@ -101,9 +105,9 @@ async function start(deviceQuery: string, appName: string, pluginId: string) {
|
|||||||
execPath: process.execPath,
|
execPath: process.execPath,
|
||||||
desktopPath: `/dev/null`,
|
desktopPath: `/dev/null`,
|
||||||
},
|
},
|
||||||
launcherSettings: await loadLauncherSettings(argv.launcherSettings),
|
launcherSettings,
|
||||||
processConfig: loadProcessConfig(process.env),
|
processConfig: loadProcessConfig(process.env),
|
||||||
settings: await loadSettings(argv.settingsString),
|
settings,
|
||||||
validWebSocketOrigins: [],
|
validWebSocketOrigins: [],
|
||||||
},
|
},
|
||||||
logger,
|
logger,
|
||||||
|
|||||||
@@ -210,8 +210,10 @@ export class FlipperServerImpl implements FlipperServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async createFolders() {
|
private async createFolders() {
|
||||||
await mkdirp(flipperDataFolder);
|
await Promise.all([
|
||||||
await mkdirp(flipperSettingsFolder);
|
mkdirp(flipperDataFolder),
|
||||||
|
mkdirp(flipperSettingsFolder),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async startDeviceListeners() {
|
async startDeviceListeners() {
|
||||||
|
|||||||
@@ -82,10 +82,15 @@ export const loadSecureServerConfig = async (): Promise<SecureServerConfig> => {
|
|||||||
await ensureOpenSSLIsAvailable();
|
await ensureOpenSSLIsAvailable();
|
||||||
await certificateSetup();
|
await certificateSetup();
|
||||||
await generateAuthToken();
|
await generateAuthToken();
|
||||||
|
const [key, cert, ca] = await Promise.all([
|
||||||
|
fs.readFile(serverKey),
|
||||||
|
fs.readFile(serverCert),
|
||||||
|
fs.readFile(caCert),
|
||||||
|
]);
|
||||||
serverConfig = {
|
serverConfig = {
|
||||||
key: await fs.readFile(serverKey),
|
key,
|
||||||
cert: await fs.readFile(serverCert),
|
cert,
|
||||||
ca: await fs.readFile(caCert),
|
ca,
|
||||||
requestCert: true,
|
requestCert: true,
|
||||||
rejectUnauthorized: true, // can be false if necessary as we don't strictly need to verify the client
|
rejectUnauthorized: true, // can be false if necessary as we don't strictly need to verify the client
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ export async function startFlipperServer(
|
|||||||
console.warn('Failed to find desktop path, falling back to homedir');
|
console.warn('Failed to find desktop path, falling back to homedir');
|
||||||
desktopPath = os.homedir();
|
desktopPath = os.homedir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [launcherSettings, settings] = await Promise.all([
|
||||||
|
loadLauncherSettings(enableLauncherSettings),
|
||||||
|
loadSettings(settingsString),
|
||||||
|
]);
|
||||||
return new FlipperServerImpl(
|
return new FlipperServerImpl(
|
||||||
{
|
{
|
||||||
environmentInfo,
|
environmentInfo,
|
||||||
@@ -64,9 +69,9 @@ export async function startFlipperServer(
|
|||||||
tempPath: os.tmpdir(),
|
tempPath: os.tmpdir(),
|
||||||
desktopPath: desktopPath,
|
desktopPath: desktopPath,
|
||||||
},
|
},
|
||||||
launcherSettings: await loadLauncherSettings(enableLauncherSettings),
|
launcherSettings,
|
||||||
processConfig: loadProcessConfig(env),
|
processConfig: loadProcessConfig(env),
|
||||||
settings: await loadSettings(settingsString),
|
settings,
|
||||||
validWebSocketOrigins: ['localhost:', 'http://localhost:'],
|
validWebSocketOrigins: ['localhost:', 'http://localhost:'],
|
||||||
type,
|
type,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ export default async function runLint(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const packageJsonSchema = await fs.readJson(packageJsonSchemaPath);
|
const [packageJsonSchema, pluginPackageJsonSchema] = await Promise.all([
|
||||||
const pluginPackageJsonSchema = await fs.readJson(
|
fs.readJson(packageJsonSchemaPath),
|
||||||
pluginPackageJsonSchemaPath,
|
fs.readJson(pluginPackageJsonSchemaPath),
|
||||||
);
|
]);
|
||||||
const ajv = new Ajv({
|
const ajv = new Ajv({
|
||||||
allErrors: true,
|
allErrors: true,
|
||||||
loadSchema,
|
loadSchema,
|
||||||
|
|||||||
@@ -456,9 +456,11 @@ async function buildServerRelease() {
|
|||||||
platforms.push(BuildPlatform.WINDOWS);
|
platforms.push(BuildPlatform.WINDOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const platform of platforms) {
|
await Promise.all(
|
||||||
await bundleServerReleaseForPlatform(dir, versionNumber, platform);
|
platforms.map((platform) =>
|
||||||
}
|
bundleServerReleaseForPlatform(dir, versionNumber, platform),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nodeArchFromBuildPlatform(platform: BuildPlatform): string {
|
function nodeArchFromBuildPlatform(platform: BuildPlatform): string {
|
||||||
|
|||||||
@@ -168,8 +168,7 @@ export async function moveSourceMaps(
|
|||||||
// If we don't move them out of the build folders, they'll get included in the ASAR
|
// If we don't move them out of the build folders, they'll get included in the ASAR
|
||||||
// which we don't want.
|
// which we don't want.
|
||||||
console.log(`⏭ Removing source maps.`);
|
console.log(`⏭ Removing source maps.`);
|
||||||
await fs.remove(mainBundleMap);
|
await Promise.all([fs.remove(mainBundleMap), fs.remove(rendererBundleMap)]);
|
||||||
await fs.remove(rendererBundleMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,12 @@ async function getWorkspacesByRoot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getWorkspaces(): Promise<Workspaces> {
|
export async function getWorkspaces(): Promise<Workspaces> {
|
||||||
const rootWorkspaces = await getWorkspacesByRoot(rootDir);
|
const [rootWorkspaces, publicPluginsWorkspaces, fbPluginsWorkspaces] =
|
||||||
const publicPluginsWorkspaces = await getWorkspacesByRoot(publicPluginsDir);
|
await Promise.all([
|
||||||
const fbPluginsWorkspaces = await getWorkspacesByRoot(fbPluginsDir);
|
getWorkspacesByRoot(rootDir),
|
||||||
|
getWorkspacesByRoot(publicPluginsDir),
|
||||||
|
getWorkspacesByRoot(fbPluginsDir),
|
||||||
|
]);
|
||||||
const mergedWorkspaces: Workspaces = {
|
const mergedWorkspaces: Workspaces = {
|
||||||
rootPackage: rootWorkspaces!.rootPackage,
|
rootPackage: rootWorkspaces!.rootPackage,
|
||||||
packages: [
|
packages: [
|
||||||
|
|||||||
Reference in New Issue
Block a user