Coder Social home page Coder Social logo

Comments (4)

ZiZasaurus avatar ZiZasaurus commented on June 11, 2024 1

@paulVulog thank you for reporting, I will transfer this ticket to the appropriate repo.

from mapbox-gl-native-android.

devmobile-vulog avatar devmobile-vulog commented on June 11, 2024

@ZiZasaurus any status on this ? It is really impacting. Where did you transfer this issue to ?

from mapbox-gl-native-android.

KnIfER avatar KnIfER commented on June 11, 2024

Hi, similiar backtrace here appxmod/diodict-decompiled@7199009

If I filter out ACTION_POINTER_DOWN,the native crash will become the “pointerIndex out of range” Exception:

if (actionMasked!=MotionEvent.ACTION_POINTER_DOWN) {
	try {
		boolean flingEvent = this.flingDetector.onTouchEvent(event);
		if (flingEvent) {
			// this.flingDetector = new GestureDetector(getContext(), this);
			return flingEvent;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}

from mapbox-gl-native-android.

ankiimation avatar ankiimation commented on June 11, 2024

I resolved this issue by create new Flutter Engine with custom MyPlatformViewController extend PlatformViewController
flutter/engine@991471b

MyPlatformViewController:

class MyPlatformViewsController : PlatformViewsController() {
    override fun toMotionEvent(
        density: Float,
        touch: PlatformViewsChannel.PlatformViewTouch?,
        usingVirtualDiplays: Boolean
    ): MotionEvent {
        val motionEventId = MotionEventId.from(touch!!.motionEventId)
        val trackedEvent = MotionEventTracker.getInstance().pop(motionEventId)

        // Pointer coordinates in the tracked events are global to FlutterView
        // framework converts them to be local to a widget, given that
        // motion events operate on local coords, we need to replace these in the tracked
        // event with their local counterparts.

        // Pointer coordinates in the tracked events are global to FlutterView
        // framework converts them to be local to a widget, given that
        // motion events operate on local coords, we need to replace these in the tracked
        // event with their local counterparts.
        val pointerProperties = parsePointerPropertiesList(
            touch!!.rawPointerPropertiesList
        ).toTypedArray()
        val pointerCoords = parsePointerCoordsList(
            touch!!.rawPointerCoords, density
        )
            .toTypedArray()

        return if (!usingVirtualDiplays && trackedEvent != null) {
            MotionEvent.obtain(
                trackedEvent.downTime,
                trackedEvent.eventTime,
                touch!!.action,
                touch!!.pointerCount,
                pointerProperties,
                pointerCoords,
                trackedEvent.metaState,
                trackedEvent.buttonState,
                trackedEvent.xPrecision,
                trackedEvent.yPrecision,
                trackedEvent.deviceId,
                trackedEvent.edgeFlags,
                trackedEvent.source,
                trackedEvent.flags
            )
        } else MotionEvent.obtain(
            touch!!.downTime.toLong(),
            touch!!.eventTime.toLong(),
            touch!!.action,
            touch!!.pointerCount,
            pointerProperties,
            pointerCoords,
            touch!!.metaState,
            touch!!.buttonState,
            touch!!.xPrecision,
            touch!!.yPrecision,
            touch!!.deviceId,
            touch!!.edgeFlags,
            touch!!.source,
            touch!!.flags
        )

    }

    private fun parsePointerPropertiesList(rawPropertiesList: Any): List<PointerProperties> {
        val rawProperties = rawPropertiesList as List<Any>
        val pointerProperties: MutableList<PointerProperties> = java.util.ArrayList()
        for (o in rawProperties) {
            pointerProperties.add(parsePointerProperties(o))
        }
        return pointerProperties
    }

    private fun parsePointerProperties(rawProperties: Any): PointerProperties {
        val propertiesList = rawProperties as List<Any>
        val properties = PointerProperties()
        properties.id = propertiesList[0] as Int
        properties.toolType = propertiesList[1] as Int
        return properties
    }

    private fun parsePointerCoordsList(rawCoordsList: Any, density: Float): List<PointerCoords> {
        val rawCoords = rawCoordsList as List<Any>
        val pointerCoords: MutableList<PointerCoords> = ArrayList()
        for (o in rawCoords) {
            pointerCoords.add(parsePointerCoords(o, density))
        }
        return pointerCoords
    }

    private fun parsePointerCoords(rawCoords: Any, density: Float): PointerCoords {
        val coordsList = rawCoords as List<Any>
        val coords = PointerCoords()
        coords.orientation = (coordsList[0] as Double).toFloat()
        coords.pressure = (coordsList[1] as Double).toFloat()
        coords.size = (coordsList[2] as Double).toFloat()
        coords.toolMajor = (coordsList[3] as Double * density).toFloat()
        coords.toolMinor = (coordsList[4] as Double * density).toFloat()
        coords.touchMajor = (coordsList[5] as Double * density).toFloat()
        coords.touchMinor = (coordsList[6] as Double * density).toFloat()
        coords.x = (coordsList[7] as Double * density).toFloat()
        coords.y = (coordsList[8] as Double * density).toFloat()
        return coords
    }
}

In MainActivity (your main flutter activity):

    override fun provideFlutterEngine(context: Context): FlutterEngine? {
        return FlutterEngine(
            context,
            null,
            FlutterJNI(),
            MyCustomFlutterEngine(),
            Companion.flutterShellArgs.toArray(),
            false
        )
    }

from mapbox-gl-native-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.