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

Two ReactART TODOs implemented on Android #9486

Closed
wants to merge 34 commits into from
Closed
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b00f700
[0.32.0-rc.0] Bump version numbers
grabbou Aug 5, 2016
d402a91
Implemented TODO 7255985: ReactART Surface rendering via TextureView …
tepamid Aug 17, 2016
0ecb47a
Merge pull request #1 from facebook/master
tepamid Aug 18, 2016
9d73091
TODO(6352067) implemented: support for dashes in React ART on Android
tepamid Aug 19, 2016
4733329
TODO(7255985): implemented ARTSurface via TextureView in Android
tepamid Aug 19, 2016
163dcaa
Merge branch 'master' into master
tepamid Aug 19, 2016
b368f4b
Merge branch 'master' into master
tepamid Aug 19, 2016
97dfe1b
Merge branch 'master' into master
tepamid Aug 19, 2016
ff0047b
Merge branch 'master' into master
tepamid Aug 20, 2016
a76dbc5
Should be R.string, not R.strings
geof90 Aug 6, 2016
c732ca4
Fix params patch
geof90 Aug 19, 2016
be92179
Use React 15.3.0 instead of 15.3.0-rc.2
ide Aug 8, 2016
01c78be
Unbreak upgrade to React 15.3.0
javache Aug 8, 2016
0d5fa74
Specify React dependency correctly
javache Aug 8, 2016
4f5fe81
Have React only as a peer dependency
javache Aug 9, 2016
ff1c6f9
[0.32.0] Bump version numbers
grabbou Aug 21, 2016
ac9622f
Merge branch 'master' into master
tepamid Aug 23, 2016
9dad980
TODO(7255985): refactoring of ARTSurface
tepamid Aug 23, 2016
8a1de61
Merge branch 'master' into master
tepamid Aug 23, 2016
c516125
Merge branch 'master' into master
tepamid Aug 24, 2016
2a5c9a1
Don't clear queue in ProxyExecutor
lexs Aug 24, 2016
37a05ed
Bring back missing android command
grabbou Aug 23, 2016
fa660c6
Revert "[0.32.0] Bump version numbers"
grabbou Aug 25, 2016
96877a0
[0.32.0] Bump version numbers
grabbou Aug 25, 2016
e721814
Fixes paths to robolectric when they are downloaded from maven into b…
bestander Aug 22, 2016
3a3ecc4
Make sure layout happens after setFrame:forView:
javache Aug 8, 2016
7a1410a
[0.32.1] Bump version numbers
bestander Sep 7, 2016
1311c45
WebSocket onError fix; Dashes in Android; ARTSurface via TextureView
tepamid Sep 9, 2016
4b80730
Fixed: CSSNodeAPI instad of CSSNode
tepamid Sep 9, 2016
dc97901
Added IllegalStateException in ArtSurfaceViewShadowNode
tepamid Sep 19, 2016
09a22fc
Removed throwing exception "Cannot send a message. Unknown WebSocket id"
tepamid Sep 5, 2016
945322c
Merge branch 'master' into master
tepamid Oct 12, 2016
bacce99
TODO 7255985: added exception handling to drawing in ARTSurfaceView
tepamid Oct 12, 2016
fd49719
Merge branch 'master' into master
tepamid Oct 13, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import android.graphics.SurfaceTexture;
import android.view.TextureView;

import com.facebook.common.logging.FLog;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.UIViewOperationQueue;
import com.facebook.react.uimanager.ReactShadowNode;
Expand Down Expand Up @@ -47,39 +49,48 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiUpdater) {
}

private void drawOutput() {
if (mSurface == null) {
if (mSurface == null || !mSurface.isValid()) {
markChildrenUpdatesSeen(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do not markUpdateSeen each child in the entire Surface subtree, then ARTSurface's method onCollectExtraUpdates is called ONLY ONCE right after the app start. As I understood from the react-native sources when a child is updated it is marked "update not seen" (i.e. some ARTShape on a ARTSurface) and also it tries to mark its parent as "update not seen" only if parent doesn't have any pending updates. Otherwise if parent itself is already marked "update not seen", then an update is not propagated further to even more distant ancestors and obviously to the ultimate ancestor ARTSurface.

That's why I need to mark all ARTSurface's children as "UpdateSeen" even if TextureView's Android.Surface is not ready for drawing.

Or is there a pre-built method in ReactNative for this?

return;
}

Canvas canvas = mSurface.lockCanvas(null);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
try {
Canvas canvas = mSurface.lockCanvas(null);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

Paint paint = new Paint();
for (int i = 0; i < getChildCount(); i++) {
ARTVirtualNode child = (ARTVirtualNode) getChildAt(i);
child.draw(canvas, paint, 1f);
child.markUpdateSeen();
}
Paint paint = new Paint();
for (int i = 0; i < getChildCount(); i++) {
ARTVirtualNode child = (ARTVirtualNode) getChildAt(i);
child.draw(canvas, paint, 1f);
child.markUpdateSeen();
}

mSurface.unlockCanvasAndPost(canvas);
if (mSurface == null) {
return;
}

mSurface.unlockCanvasAndPost(canvas);
} catch(IllegalArgumentException | IllegalStateException e) {
FLog.e(ReactConstants.TAG, e.getClass().getSimpleName() + " in Surface.unlockCanvasAndPost");
}
}

private void markChildrenUpdatesSeen(ReactShadowNode shadowNode) {
for (int i = 0; i < shadowNode.getChildCount(); i++) {
ReactShadowNode child = (ReactShadowNode) shadowNode.getChildAt(i);
child.markUpdateSeen();
markChildrenUpdatesSeen(child);
}
ReactShadowNode child = (ReactShadowNode) shadowNode.getChildAt(i);
child.markUpdateSeen();
markChildrenUpdatesSeen(child);
}
}

public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
mSurface = new Surface(surface);
mSurface = new Surface(surface);
}

public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mSurface = null;
return true;
mSurface.release();
mSurface = null;
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit: only two spaces of indentation please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I'll fix it.


public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {}
Expand Down