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

BufferoverflowException with ZoomSurfaceView #195

Open
enel1989 opened this issue Dec 23, 2020 · 3 comments
Open

BufferoverflowException with ZoomSurfaceView #195

enel1989 opened this issue Dec 23, 2020 · 3 comments
Labels

Comments

@enel1989
Copy link

Describe the bug

  • Library version: 1.8.0
  • Reproducible in official demo app: no
  • Device / Android version: Based on the crash reports mostly Android10 but it happens on other OS versions as well.

Screen Shot 2020-12-23 at 16 02 22

Screen Shot 2020-12-23 at 16 02 28

To Reproduce

I tried to reproduce locally without any success.

Expected behavior

The ZoomSurfaceView doesn't crash with BufferOverflowException.

XML layout

  <FrameLayout
        android:id="@+id/video_zoom_layout"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.otaliastudios.zoom.ZoomSurfaceView
            android:id="@+id/surface_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:horizontalPanEnabled="true"
            app:verticalPanEnabled="true"
            app:zoomEnabled="true" />

        <com.google.android.exoplayer2.ui.PlayerControlView
            android:id="@+id/player_control_view"
            android:layout_gravity="bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </FrameLayout>

Logs

Fatal Exception: java.nio.BufferOverflowException
       at java.nio.Buffer.nextPutIndex(Buffer.java:536)
       at java.nio.ByteBufferAsFloatBuffer.put(ByteBufferAsFloatBuffer.java:109)
       at com.otaliastudios.opengl.draw.GlRect.setRect(GlRect.java:61)
       at com.otaliastudios.opengl.draw.GlRect.setRect(GlRect.java:44)
       at com.otaliastudios.zoom.ZoomSurfaceView.onContentOrContainerSizeChanged(ZoomSurfaceView.java:238)
       at com.otaliastudios.zoom.ZoomSurfaceView.onMeasure(ZoomSurfaceView.java:215)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:26415)
       at android.widget.RelativeLayout.measureChild(RelativeLayout.java:696)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:499)
       at android.view.View.measure(View.java:26415)
       at androidx.drawerlayout.widget.DrawerLayout.onMeasure(DrawerLayout.java:1119)
       at android.view.View.measure(View.java:26415)
       at androidx.drawerlayout.widget.DrawerLayout.onMeasure(DrawerLayout.java:1119)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7845)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1013)
       at android.view.View.measure(View.java:26415)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3609)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2352)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2644)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2204)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9003)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:996)
       at android.view.Choreographer.doCallbacks(Choreographer.java:794)
       at android.view.Choreographer.doFrame(Choreographer.java:729)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:7948)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Example usage

private void initVideoPlayer() {
       player = new SimpleExoPlayer.Builder(requireContext()).build();
       player.setRepeatMode(Player.REPEAT_MODE_ALL);
       player.addVideoListener(new VideoListener() {
           @Override
           public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
               surface.setContentSize(width, height);
               surface.setMaxZoom(Math.max(surface.getEngine().getContainerWidth() / (float) width, surface.getEngine().getContainerHeight() / (float) height) + 2.0f);
               surface.setMinZoom(Math.max(surface.getEngine().getContainerWidth() / (float) width, surface.getEngine().getContainerHeight() / (float) height));
               surface.moveTo(surface.getZoom(), 0.0f, 0.0f, false);
           }
       });
       //surface.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white));
       surface.addCallback(new ZoomSurfaceView.Callback() {
           @Override
           public void onZoomSurfaceCreated(@NotNull ZoomSurfaceView view) {
               player.setVideoSurface(view.getSurface());
           }

           @Override
           public void onZoomSurfaceDestroyed(@NotNull ZoomSurfaceView view) {
               player.setVideoSurface(null);
           }
       });
       surface.setPreserveEGLContextOnPause(false);
       controls.setPlayer(player);
       controls.setShowTimeoutMs(0);
       controls.setShowNextButton(false);
       controls.setShowPreviousButton(false);
       controls.show();
   }
private void setUpVideoPlayer(String videoUrl) {
        if (videoUrl == null) {
            return;
        }
        Factory dataSourceFactory = new DefaultDataSourceFactory(requireContext(),
                Util.getUserAgent(requireContext(), "Idokep"));
        Uri videoUri = Uri.parse(videoUrl);
        MediaSource videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
                .createMediaSource(MediaItem.fromUri(videoUri));
        player.setPlayWhenReady(true);
        player.setMediaSource(videoSource);
        player.prepare();
    }
@Anatolf
Copy link

Anatolf commented Feb 7, 2022

I get the same error:

GlRect.kt line 61
com.otaliastudios.opengl.draw.GlRect.setRect

Log:
Fatal Exception: java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:536)
at java.nio.ByteBufferAsFloatBuffer.put(ByteBufferAsFloatBuffer.java:109)
at com.otaliastudios.opengl.draw.GlRect.setRect(GlRect.kt:61)
at com.otaliastudios.opengl.draw.GlRect.setRect(GlRect.kt:44)
at com.otaliastudios.zoom.ZoomSurfaceView.onContentOrContainerSizeChanged(ZoomSurfaceView.kt:238)
at com.otaliastudios.zoom.ZoomSurfaceView.onMeasure(ZoomSurfaceView.kt:215)
at android.view.View.measure(View.java:25777)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7036)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25777)

@Anatolf
Copy link

Anatolf commented Mar 16, 2023

I managed to catch this error when turning the screen frequently. Haven't found a solution yet

@dachev
Copy link

dachev commented Jun 6, 2023

This get the same error. It usually happens after screen rotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants