Skip to content

Commit

Permalink
Support view allocation counters with Venice
Browse files Browse the repository at this point in the history
Summary:
Venice uses `SurfaceHandler` abstraction which start/stops surfaces independently from `Binding.cpp`, so previous `onSurfaceStart/Stop` callback would not be triggered.

On Android, each surface is used exactly once at the time of writing, so we can use `register/unregister` callbacks to create/clear remembered views for the surface.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33845685

fbshipit-source-id: 8de4204c7498176fdbe8d44fbc5f2e4079212a1c
  • Loading branch information
Andrei Shikov authored and facebook-github-bot committed Feb 2, 2022
1 parent fbb9d33 commit 65df2f3
Showing 1 changed file with 26 additions and 2 deletions.
Expand Up @@ -266,13 +266,37 @@ void Binding::stopSurface(jint surfaceId) {
}

void Binding::registerSurface(SurfaceHandlerBinding *surfaceHandlerBinding) {
auto const &surfaceHandler = surfaceHandlerBinding->getSurfaceHandler();
auto scheduler = getScheduler();
scheduler->registerSurface(surfaceHandlerBinding->getSurfaceHandler());
if (!scheduler) {
LOG(ERROR) << "Binding::registerSurface: scheduler disappeared";
return;
}
scheduler->registerSurface(surfaceHandler);

auto mountingManager =
verifyMountingManager("FabricUIManagerBinding::registerSurface");
if (!mountingManager) {
return;
}
mountingManager->onSurfaceStart(surfaceHandler.getSurfaceId());
}

void Binding::unregisterSurface(SurfaceHandlerBinding *surfaceHandlerBinding) {
auto const &surfaceHandler = surfaceHandlerBinding->getSurfaceHandler();
auto scheduler = getScheduler();
scheduler->unregisterSurface(surfaceHandlerBinding->getSurfaceHandler());
if (!scheduler) {
LOG(ERROR) << "Binding::unregisterSurface: scheduler disappeared";
return;
}
scheduler->unregisterSurface(surfaceHandler);

auto mountingManager =
verifyMountingManager("FabricUIManagerBinding::unregisterSurface");
if (!mountingManager) {
return;
}
mountingManager->onSurfaceStop(surfaceHandler.getSurfaceId());
}

void Binding::setConstraints(
Expand Down

0 comments on commit 65df2f3

Please sign in to comment.