Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,17 @@ private void onPreEngineRestart() {
listener.onPreEngineRestart();
}
}

@SuppressWarnings("unused")
@UiThread
public void onEndFrame() {
ensureRunningOnMainThread();
if (platformViewsController == null) {
throw new RuntimeException(
"platformViewsController must be set before attempting to end the frame");
}
platformViewsController.onEndFrame();
}
// ----- End Engine Lifecycle Support ----

// @SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private void flushAllViews() {
vdControllers.clear();
}

public void onDisplayPlatformView(int viewId, int x, int y, int width, int height) {
public void onEndFrame() {
Comment thread
cg021 marked this conversation as resolved.
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
}
}
21 changes: 11 additions & 10 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,9 @@ void FlutterViewOnPreEngineRestart(JNIEnv* env, jobject obj) {
FML_CHECK(CheckException(env));
}

static jmethodID g_on_display_platform_view_method = nullptr;
void FlutterViewOnDisplayPlatformView(JNIEnv* env,
jobject obj,
jint view_id,
jint x,
jint y,
jint width,
jint height) {
env->CallVoidMethod(obj, g_on_display_platform_view_method, view_id, x, y,
width, height);
static jmethodID g_on_end_frame_method = nullptr;
void FlutterViewEndFrame(JNIEnv* env, jobject obj) {
env->CallVoidMethod(obj, g_on_end_frame_method);
FML_CHECK(CheckException(env));
}

Expand Down Expand Up @@ -778,6 +771,14 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
return false;
}

g_on_end_frame_method =
env->GetMethodID(g_flutter_jni_class->obj(), "onEndFrame", "()V");

if (g_on_end_frame_method == nullptr) {
FML_LOG(ERROR) << "Could not locate onEndFrame method";
return false;
}

g_attach_to_gl_context_method = env->GetMethodID(
g_surface_texture_class->obj(), "attachToGLContext", "(I)V");

Expand Down
8 changes: 1 addition & 7 deletions shell/platform/android/platform_view_android_jni.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ void FlutterViewOnFirstFrame(JNIEnv* env, jobject obj);

void FlutterViewOnPreEngineRestart(JNIEnv* env, jobject obj);

void FlutterViewOnDisplayPlatformView(JNIEnv* env,
jobject obj,
jint view_id,
jint x,
jint y,
jint width,
jint height);
void FlutterViewEndFrame(JNIEnv* env, jobject obj);

void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,17 @@ public void onFlutterUiNoLongerDisplayed() {}
}

@Test
public void onDisplayPlatformView__callsPlatformViewsController() {
public void onEndFrame__callsPlatformViewsController() {
PlatformViewsController platformViewsController = mock(PlatformViewsController.class);

// --- Test Setup ---
FlutterJNI flutterJNI = new FlutterJNI();
flutterJNI.setPlatformViewsController(platformViewsController);

// --- Execute Test ---
flutterJNI.onDisplayPlatformView(
/*viewId=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
flutterJNI.onEndFrame();

// --- Verify Results ---
verify(platformViewsController, times(1))
.onDisplayPlatformView(
/*viewId=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
verify(platformViewsController, times(1)).onEndFrame();
}
}