Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use v8 instead of JSC + native SVG support #1196

Merged
merged 5 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ android {
}
}

packagingOptions {
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
}

buildTypes {
debug {
manifestPlaceholders = [isDebug:true]
Expand All @@ -236,8 +231,8 @@ android {

}
packagingOptions {
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
// Make sure libjsc.so does not packed in APK
exclude "**/libjsc.so"
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
Expand Down Expand Up @@ -272,6 +267,7 @@ dependencies {
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'org.chromium:v8-android:7.8.+'

implementation project(':react-native-branch')
implementation "io.branch.sdk.android:library:4.1.2"
Expand Down
13 changes: 9 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ allprojects {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
maven { // Replace AAR from original RN with AAR from react-native-v8
url("$rootDir/../node_modules/react-native-v8/dist")
}
maven { url "https://jitpack.io" }
maven {
// prebuilt libv8android.so
url("$rootDir/../node_modules/v8-android/dist")
}
maven {
url "https://jitpack.io"
}
}

subprojects {
Expand Down
45 changes: 45 additions & 0 deletions app/components/Base/RemoteImage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import PropTypes from 'prop-types';
import { View, Image, ViewPropTypes } from 'react-native';
import FadeIn from 'react-native-fade-in-image';
// eslint-disable-next-line import/default
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import { SvgCssUri } from 'react-native-svg';

const RemoteImage = props => {
const source = resolveAssetSource(props.source);
if (source && (source.uri && source.uri.match('.svg'))) {
const style = props.style || {};
if (source.__packager_asset && typeof style !== 'number') {
if (!style.width) {
style.width = source.width;
}
if (!style.height) {
style.height = source.height;
}
}
return (
<View style={style}>
<SvgCssUri {...props} uri={source.uri} width={'100%'} height={'100%'} />
</View>
);
}

if (props.fadeIn) {
return (
<FadeIn placeholderStyle={props.placeholderStyle}>
<Image {...props} />
</FadeIn>
);
}
return <Image {...props} />;
};

RemoteImage.propTypes = {
fadeIn: PropTypes.bool,
source: PropTypes.any,
style: ViewPropTypes.style,
placeholderStyle: ViewPropTypes.style
};

export default RemoteImage;
25 changes: 15 additions & 10 deletions app/components/UI/AccountList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,27 @@ class AccountList extends PureComponent {
const { identities, selectedAddress } = this.props;
Object.keys(identities).forEach((address, i) => {
if (selectedAddress === address) {
this.setState({ selectedAccountIndex: i });
this.mounted && this.setState({ selectedAccountIndex: i });
}
});
};

componentDidMount() {
this.mounted = true;
this.getInitialSelectedAccountIndex();
const orderedAccounts = this.getAccounts();
InteractionManager.runAfterInteractions(() => {
if (orderedAccounts.length > 4) {
this.scrollToCurrentAccount();
}
});
this.setState({ orderedAccounts });
this.mounted && this.setState({ orderedAccounts });
}

componentWillUnmount = () => {
this.mounted = false;
};

scrollToCurrentAccount() {
this.flatList &&
this.flatList.current &&
Expand All @@ -147,7 +152,7 @@ class AccountList extends PureComponent {
const { keyrings } = this.props;
requestAnimationFrame(async () => {
try {
this.setState({ selectedAccountIndex: newIndex });
this.mounted && this.setState({ selectedAccountIndex: newIndex });

const allKeyrings =
keyrings && keyrings.length ? keyrings : Engine.context.KeyringController.state.keyrings;
Expand All @@ -164,7 +169,7 @@ class AccountList extends PureComponent {
});
} catch (e) {
// Restore to the previous index in case anything goes wrong
this.setState({ selectedAccountIndex: previousIndex });
this.mounted && this.setState({ selectedAccountIndex: previousIndex });
Logger.error('error while trying change the selected account', e); // eslint-disable-line
}
InteractionManager.runAfterInteractions(() => {
Expand All @@ -173,7 +178,7 @@ class AccountList extends PureComponent {
}, 1000);
});
const orderedAccounts = this.getAccounts();
await this.setState({ orderedAccounts });
this.mounted && this.setState({ orderedAccounts });
});
};

Expand All @@ -183,25 +188,25 @@ class AccountList extends PureComponent {

addAccount = async () => {
if (this.state.loading) return;
this.setState({ loading: true });
this.mounted && this.setState({ loading: true });
const { KeyringController } = Engine.context;
requestAnimationFrame(async () => {
try {
await KeyringController.addNewAccount();
const { PreferencesController } = Engine.context;
const newIndex = Object.keys(this.props.identities).length - 1;
PreferencesController.setSelectedAddress(Object.keys(this.props.identities)[newIndex]);
this.setState({ selectedAccountIndex: newIndex });
this.mounted && this.setState({ selectedAccountIndex: newIndex });
setTimeout(() => {
this.flatList && this.flatList.current && this.flatList.current.scrollToEnd();
this.setState({ loading: false });
this.mounted && this.setState({ loading: false });
}, 500);
const orderedAccounts = this.getAccounts();
await this.setState({ orderedAccounts });
this.mounted && this.setState({ orderedAccounts });
} catch (e) {
// Restore to the previous index in case anything goes wrong
Logger.error('error while trying to add a new account', e); // eslint-disable-line
this.setState({ loading: false });
this.mounted && this.setState({ loading: false });
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/AssetIcon/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { StyleSheet } from 'react-native';
import Image from 'react-native-remote-svg';
import RemoteImage from '../../Base/RemoteImage';
import PropTypes from 'prop-types';
import getAssetLogoPath from '../../../util/assets';
import { colors } from '../../../styles/common';
Expand All @@ -20,7 +20,7 @@ const AssetIcon = React.memo(props => {
if (!props.logo) return null;
const uri = props.watchedAsset ? props.logo : getAssetLogoPath(props.logo);
const style = [styles.logo, props.customStyle];
return <Image fadeIn placeholderStyle={{ backgroundColor: colors.white }} source={{ uri }} style={style} />;
return <RemoteImage fadeIn placeholderStyle={{ backgroundColor: colors.white }} source={{ uri }} style={style} />;
});

AssetIcon.propTypes = {
Expand Down
9 changes: 3 additions & 6 deletions app/components/UI/CollectibleImage/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, View, Image } from 'react-native';
import SvgImage from 'react-native-remote-svg';
import { StyleSheet, View } from 'react-native';
import RemoteImage from '../../Base/RemoteImage';
import Identicon from '../Identicon';
import { colors } from '../../../styles/common';

Expand Down Expand Up @@ -66,13 +66,10 @@ export default class CollectibleImage extends PureComponent {
iconStyle
} = this.props;

const isSVG = image && image.substr(-3) === 'svg';
const ImageComponent = isSVG ? SvgImage : Image;

return (
<View style={renderFull ? styles.fullWrapper : [styles.listWrapper, containerStyle]}>
{image && image.length !== 0 ? (
<ImageComponent
<RemoteImage
fadeIn
resizeMode={'contain'}
placeholderStyle={{ backgroundColor: colors.white }}
Expand Down
5 changes: 2 additions & 3 deletions app/components/UI/DrawerView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ScrollView,
InteractionManager
} from 'react-native';
import SvgImage from 'react-native-remote-svg';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Share from 'react-native-share'; // eslint-disable-line import/default
Expand Down Expand Up @@ -725,8 +724,8 @@ class DrawerView extends PureComponent {
},
paymentChannelsEnabled && {
name: strings('drawer.insta_pay'),
icon: <SvgImage source={instapay_logo} style={styles.instapayLogo} />,
selectedIcon: <SvgImage source={instapay_logo_selected} style={styles.instapayLogo} />,
icon: <Image source={instapay_logo} style={styles.instapayLogo} />,
selectedIcon: <Image source={instapay_logo_selected} style={styles.instapayLogo} />,
action: this.goToPaymentChannel
},
{
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"fuse.js": "3.4.4",
"gaba": "1.8.2",
"https-browserify": "0.0.1",
"jsc-android": "236355.1.1",
"lottie-react-native": "git+ssh://git@github.com/brunobar79/lottie-react-native.git#7ce6a78ac4ac7b9891bc513cb3f12f8b9c9d9106",
"multihashes": "0.4.14",
"number-to-bn": "1.7.0",
Expand Down Expand Up @@ -120,15 +119,15 @@
"react-native-qrcode-svg": "5.1.2",
"react-native-randombytes": "3.5.2",
"react-native-reanimated": "1.3.0",
"react-native-remote-svg": "git+ssh://git@github.com/brunobar79/react-native-remote-svg.git#6f071a1cefe25e9a9d56570a74523741bae65a8b",
"react-native-screens": "1.0.0-alpha.23",
"react-native-scrollable-tab-view": "git+ssh://git@github.com/estebanmino/react-native-scrollable-tab-view.git#f954274c6260a07c956e2185c611aed24b2f1526",
"react-native-search-api": "1.2.0",
"react-native-sensors": "5.3.0",
"react-native-share": "git+ssh://git@github.com/brunobar79/react-native-share.git#androidx",
"react-native-svg": "9.3.3",
"react-native-svg": "9.13.3",
"react-native-swipe-gestures": "1.0.3",
"react-native-tcp": "3.3.0",
"react-native-v8": "0.59.10-patch.4",
"react-native-vector-icons": "6.4.2",
"react-native-view-shot": "git+ssh://git@github.com/brunobar79/react-native-view-shot.git#androidx",
"react-native-webview": "git+ssh://git@github.com/brunobar79/react-native-webview.git#1ba21595a484e2713319a54e01aa78743fe92f56",
Expand Down
Loading