espresso3389 / pdfrx

pdfrx is yet another PDF viewer implementation that built on the top of pdfium. The plugin currently supports Android, iOS, Windows, macOS, Linux, and Web.
MIT License
78 stars 42 forks source link

Selecting text sometimes throws exception #185

Open dineshnaikb opened 1 week ago

dineshnaikb commented 1 week ago
The following _TypeError was thrown while handling a gesture:
Null check operator used on a null value

When the exception was thrown, this was the stack:
#0      SelectableRegionState._handleSelectionEndHandleDragUpdate (package:flutter/src/widgets/selectable_region.dart:839:22)
selectable_region.dart:839
#1      SelectionOverlay._handleEndHandleDragUpdate (package:flutter/src/widgets/text_selection.dart:1211:28)
text_selection.dart:1211
#2      DragGestureRecognizer._checkUpdate.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:806:55)
monodrag.dart:806
#3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:344:24)
recognizer.dart:344
#4      DragGestureRecognizer._checkUpdate (package:flutter/src/gestures/monodrag.dart:806:7)
monodrag.dart:806
#5      DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:652:11)
monodrag.dart:652
#6      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
pointer_router.dart:98
#7      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
pointer_router.dart:143
#8      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
compact_hash.dart:633
#9      PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
pointer_router.dart:141
#10     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
pointer_router.dart:127
#11     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:495:19)
binding.dart:495
#12     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:475:22)
binding.dart:475
#13     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:425:11)
binding.dart:425
#14     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:420:7)
binding.dart:420
#15     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:383:5)
binding.dart:383
#16     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:330:7)
binding.dart:330
#17     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:299:9)
binding.dart:299
#18     _invoke1 (dart:ui/hooks.dart:328:13)
hooks.dart:328

user action

trying long press and dragged the text for select and crashed

crash point


_selectionOverlay!.updateMagnifier(_buildInfoForMagnifier(
                           ^
  details.globalPosition,
  _selectionDelegate.value.endSelectionPoint!,
));

file

selectable_region.dart:839

@espresso3389

espresso3389 commented 1 week ago

This is a known issue but it is inside the Flutter code. I don't know what is the actual cause because it's too difficult to debug the issue correctly. But it seems that Flutter's text selection system does not expect scrolling/zooming of the selection coordinates.

Anyway, the exception causes selection loss but it actually causes no critical issues.

espresso3389 commented 1 week ago

Related: #4