Skip to content

Commit

Permalink
RN: Workaround for ReactNativeART on Android
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Jul 12, 2018
1 parent b5f027d commit d756d94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions Libraries/ART/ReactNativeART.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

const Color = require('art/core/color');
const Path = require('ARTSerializablePath');
const Platform = require('Platform');
const Transform = require('art/core/transform');

const React = require('React');
Expand Down Expand Up @@ -150,11 +151,14 @@ class Surface extends React.Component {
}

render() {
const props = this.props;
const w = extractNumber(props.width, 0);
const h = extractNumber(props.height, 0);
const height = extractNumber(this.props.height, 0);
const width = extractNumber(this.props.width, 0);

// WORKAROUND: Android bug in which canvas does not reflect size changes.
const key = Platform.OS === 'android' ? height + ',' + width : null;

return (
<NativeSurfaceView style={[props.style, {width: w, height: h}]}>
<NativeSurfaceView key={key} style={[this.props.style, {height, width}]}>
{this.props.children}
</NativeSurfaceView>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ public class ReactViewGroup extends ViewGroup implements

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

private static final int ARRAY_CAPACITY_INCREMENT = 12;
private static final int DEFAULT_BACKGROUND_COLOR = Color.TRANSPARENT;
Expand Down

0 comments on commit d756d94

Please sign in to comment.