Skip to content

Commit d756d94

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Workaround for ReactNativeART on Android
Summary: Brings back the fix for `overflow: hidden` on Android by implementing a workaround for a bug with `ReactNativeART`. The ReactNativeART bug is that changes in the canvas due to a resize of the `Surface` are not properly reflected on Android. I have verified that the correct props are being computed and passed to the shadow nodes and that the `ARTSurfaceView`'s canvas is indeed updated. But for some reason, the paint is not updated. This workaround is to simply unmount and remount `Surface` on Android. It sucks and we should eventually fix it. Reviewed By: achen1 Differential Revision: D8818010 fbshipit-source-id: 71d1927580b6bde7263fd241797d4655140b5f34
1 parent b5f027d commit d756d94

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Libraries/ART/ReactNativeART.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
const Color = require('art/core/color');
1313
const Path = require('ARTSerializablePath');
14+
const Platform = require('Platform');
1415
const Transform = require('art/core/transform');
1516

1617
const React = require('React');
@@ -150,11 +151,14 @@ class Surface extends React.Component {
150151
}
151152

152153
render() {
153-
const props = this.props;
154-
const w = extractNumber(props.width, 0);
155-
const h = extractNumber(props.height, 0);
154+
const height = extractNumber(this.props.height, 0);
155+
const width = extractNumber(this.props.width, 0);
156+
157+
// WORKAROUND: Android bug in which canvas does not reflect size changes.
158+
const key = Platform.OS === 'android' ? height + ',' + width : null;
159+
156160
return (
157-
<NativeSurfaceView style={[props.style, {width: w, height: h}]}>
161+
<NativeSurfaceView key={key} style={[this.props.style, {height, width}]}>
158162
{this.props.children}
159163
</NativeSurfaceView>
160164
);

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ public class ReactViewGroup extends ViewGroup implements
5151

5252
/**
5353
* Kill switch to make overflow hidden by default. This flag will eventually be removed.
54-
* TODO (T31096050): Sets this back to `false` until ReactNativeARTSurface issue is resolved.
5554
*/
56-
public static boolean sDefaultOverflowHidden = true;
55+
public static boolean sDefaultOverflowHidden;
5756

5857
private static final int ARRAY_CAPACITY_INCREMENT = 12;
5958
private static final int DEFAULT_BACKGROUND_COLOR = Color.TRANSPARENT;

0 commit comments

Comments
 (0)