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

DTB-Can't catch an error on the TagProcessor().getTagsFromByteArray #28

Open
moda20 opened this issue Oct 20, 2020 · 5 comments
Open

DTB-Can't catch an error on the TagProcessor().getTagsFromByteArray #28

moda20 opened this issue Oct 20, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@moda20
Copy link

moda20 commented Oct 20, 2020

Describe the bug
an error happens when reading tags from byteArray and I can't catch it, it will always crash my code and stop everything I am doing.
The error is when decoding comments, see exact error below

Environment

  • Platform Flutter Android
  • Library version 0.3.1
  • Tag type I don't know, can't get there

To Reproduce
Steps to reproduce the behavior:

  1. Nothing, I just passed bytes from a file ( an existing file )
  2. See error

Expected behavior
The error might happen, but I need to be able to catch it.

Additional context

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: RangeError (end): Invalid value: Not in inclusive range 3..20: 0
E/flutter (26269): #0      RangeError.checkValidRange (dart:core/errors.dart:357:9)
E/flutter (26269): #1      _TypedIntListMixin.sublist (dart:typed_data-patch/typed_data_patch.dart:462:31)
E/flutter (26269): #2      COMMFrame.decodeBody (package:dart_tags/src/frames/id3v2/comm_frame.dart:35:47)
E/flutter (26269): #3      ID3V2Frame.decode (package:dart_tags/src/frames/id3v2/id3v2_frame.dart:57:39)
E/flutter (26269): #4      ID3V2Reader.parseValues (package:dart_tags/src/readers/id3v2.dart:71:23)
E/flutter (26269): #5      Reader.read.<anonymous closure> (package:dart_tags/src/readers/reader.dart:13:23)
E/flutter (26269): #6      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (26269): #7      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (26269): #8      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (26269): #9      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (26269): #10     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (26269): #11     Future._addListener.<anonymous closure> (dart:async/future_impl.dart:393:9)
E/flutter (26269): #12     _rootRun (dart:async/zone.dart:1190:13)
E/flutter (26269): #13     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (26269): #14     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (26269): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (26269): #16     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (26269): #17     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (26269): 
@moda20 moda20 added the bug Something isn't working label Oct 20, 2020
@NiKoTron
Copy link
Owner

NiKoTron commented Oct 20, 2020

Thanx for the report I'll investigate it. and add the possibility to catch errors.

@plyoung
Copy link

plyoung commented Dec 11, 2020

I've just encountered something similar, where I can not handle the error in my code, with a NoSuchMethodError exception in id3v2.dart.

frame, in the code below could be null it seems.

final frame = ff.getFrame(fr);
final m = frame.decode(fr);
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      ID3V2Reader.parseValues
package:dart_tags/…/readers/id3v2.dart:71
#2      Reader.read.<anonymous closure>
package:dart_tags/…/readers/reader.dart:13
#3      _rootRunUnary (dart:async/zone.dart:1194:47)
#4      _CustomZone.runUnary (dart:async/zone.dart:1097:19)
#5      _FutureListener.handleValue (dart:async/future_impl.dart:150:18)
#6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:703:45)
#7      Future._propagateToListeners (dart:async/future_impl.dart:732:32)
#8      Future._addListener.<anonymous closure> (dart:async/future_impl.dart:400:9)
#9      _rootRun (dart:async/zone.dart:1186:13)
#10     _CustomZone.run (dart:async/zone.dart:1090:19)
#11     _CustomZone.runGuarded (dart:async/zone.dart:994:7)
#12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1034:23)
#13     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#14     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

@plyoung
Copy link

plyoung commented Dec 11, 2020

Another problem I found is that tags might be broken. In the one case the tag name was the actual description and that caused an error too. I wrapped that block at line 71 in a try/catch and it seems to now get through without problems.

      final frame = ff.getFrame(fr);
      final m = frame?.decode(fr);

      try {
        if (m?.key != null && m?.value != null) {
          if (m?.value is KeyEntity) {
            if (tags[m.key] == null) {
              tags[m.key] = {m.value.key: m.value};
            } else {
              tags[m.key][m.value.key] = m.value;
            }
          } else {
            tags[m.key] = m.value;
          }
        }
      } catch (ex) {}

@moritz-weber
Copy link

I encounter the same error as moda20 in a specific scenario in src/frames/id3v2/comm_frame.dart decodeBody:

  • enc is not UTF16
  • first 4 bytes of the frame are 0x00
  • therefore splitIndex is 0
    => sublist(3, splitIndex) crashes

My guess is that data.indexOf(0x00) would need the start parameter set to 3.
Is there any chance that this will be fixed? I could send you the mp3 file for debugging.

@luccasmaso
Copy link

Same here as all of you. Also cannot catch any exceptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants