Skip to content

Fix video setPosition call on Android#447

Merged
jperedadnr merged 1 commit into
gluonhq:masterfrom
jperedadnr:446-video-position
Jun 4, 2026
Merged

Fix video setPosition call on Android#447
jperedadnr merged 1 commit into
gluonhq:masterfrom
jperedadnr:446-video-position

Conversation

@jperedadnr

Copy link
Copy Markdown
Contributor

Fixes #446

Copilot AI review requested due to automatic review settings June 4, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes the Android JNI bridge for AndroidVideoService.setPosition(...) by invoking the correct Dalvik method ID, resolving the reported JNI “bad arguments” crash (Issue #446).

Changes:

  • Switch Java_com_gluonhq_attach_video_impl_AndroidVideoService_setPosition to call jVideoPositionMethod instead of jVideoPlaylistMethod.
  • Update the file header copyright year.
Comments suppressed due to low confidence (1)

modules/video/src/main/native/android/c/video.c:217

  • GetStringUTFChars results for jalignmentH / jalignmentV are never released (the ReleaseStringUTFChars calls are commented out), which can leak/pin memory across repeated setPosition calls. Also, the dalignmentH / dalignmentV local refs created on the Dalvik env should be deleted before detaching to avoid growing the local-ref table if the thread stays attached.
    const char *alignmentHChars = (*env)->GetStringUTFChars(env, jalignmentH, NULL);
    const char *alignmentVChars = (*env)->GetStringUTFChars(env, jalignmentV, NULL);
    if (isDebugAttach()) {
        ATTACH_LOG_FINE("Video Alignment H: %s, V: %s", alignmentHChars, alignmentVChars);
    }
    ATTACH_DALVIK();
    jstring dalignmentH = (*dalvikEnv)->NewStringUTF(dalvikEnv, alignmentHChars);
    jstring dalignmentV = (*dalvikEnv)->NewStringUTF(dalvikEnv, alignmentVChars);
    (*dalvikEnv)->CallVoidMethod(dalvikEnv, jDalvikVideoService, jVideoPositionMethod,
                   dalignmentH, dalignmentV, jtopPadding, jrightPadding, jbottomPadding, jleftPadding);
    DETACH_DALVIK();
    // (*env)->ReleaseStringUTFChars(env, jalignmentH, alignmentHChars);
    // (*env)->ReleaseStringUTFChars(env, jalignmentV, alignmentVChars);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jperedadnr jperedadnr merged commit 698a17e into gluonhq:master Jun 4, 2026
1 check passed
@jperedadnr jperedadnr deleted the 446-video-position branch June 4, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VideoService on Android throws Exception when using setPosition(...)

2 participants