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

NPE when loading the duration result to Flutter #1371

Closed
snipd-min opened this issue Dec 2, 2024 · 2 comments
Closed

NPE when loading the duration result to Flutter #1371

snipd-min opened this issue Dec 2, 2024 · 2 comments
Assignees
Labels
1 backlog bug Something isn't working

Comments

@snipd-min
Copy link

snipd-min commented Dec 2, 2024

Which API doesn't behave as documented, and how does it misbehave?
In the - (void)load:(NSDictionary *)source initialPosition:(CMTime)initialPosition initialIndex:(NSNumber *)initialIndex result:(FlutterResult)result method, the _loadResult(@{@"duration": @([self getDurationMicroseconds])}); at line 693 could throw a NPE when the _loadResult is already reported via observeValueForKeyPath at line 814.

if (_indexedAudioSources.count == 0 || !_player.currentItem ||
            _player.currentItem.status == AVPlayerItemStatusReadyToPlay) {
        _processingState = ready;
        _loadResult(@{@"duration": @([self getDurationMicroseconds])});      // <--- the NPE happened here
        _loadResult = nil;
    } else {
        // We send result after the playerItem is ready in observeValueForKeyPath.
    }

I'm not sure if observeValueForKeyPath should ever report the duration before the load method, but here in theory the _loadResult could be set to nil and should probably check for it before calling.

Here I attached the crash log trace from xcode via the Organizer > Crashes:

image

Minimal reproduction project
Unfortunately I couldn't find a way to reproduce this after a lot of tries. I still feel like I should report it as it's quite clear what actually happened here (or should have happened). This only happens to a very small fraction of users that we have.

Error messages

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010

Crashed: com.apple.main-thread
0  just_audio                     0x74cc -[AudioPlayer load:initialPosition:initialIndex:result:] + 1900
1  just_audio                     0x47ec -[AudioPlayer handleMethodCall:result:] + 524
2  just_audio                     0x45a8 __70-[AudioPlayer initWithRegistrar:playerId:loadConfiguration:userAgent:]_block_invoke + 72
3  Flutter                        0x5c0a8c InternalFlutterGpu_Texture_AsImage + 6316
4  Flutter                        0x43d0c (Missing UUID 4c4c44ef55553144a1c675e6577e3daa)
5  libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
6  libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
7  libdispatch.dylib              0x125a4 _dispatch_main_queue_drain + 988
8  libdispatch.dylib              0x121b8 _dispatch_main_queue_callback_4CF + 44
9  CoreFoundation                 0x56710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
10 CoreFoundation                 0x53914 __CFRunLoopRun + 1996
11 CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
12 GraphicsServices               0x11a8 GSEventRunModal + 164
13 UIKitCore                      0x40aae8 -[UIApplication _run] + 888
14 UIKitCore                      0x4bed98 UIApplicationMain + 340
15 Runner                         0x97a8 main + 8 (AppDelegate.swift:8)
16 ???                            0x1c1f47154 (Missing)

Expected behavior
In case the duration is already reported via observeValueForKeyPath, the _loadResult doesn't need to be called and should just move on.

Screenshots
N/A

Smartphone (please complete the following information):

  • Device: iOS
  • OS: iOS 15-18

Flutter SDK version
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.1.1 24B91 darwin-arm64, locale
en-US)
• Flutter version 3.24.3 on channel stable at
/Users/minzhao/fvm/versions/3.24.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2663184aa7 (3 months ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/minzhao/Library/Android/sdk
• Platform android-34, build-tools 33.0.1
• ANDROID_HOME = /Users/minzhao/Library/Android/sdk
• ANDROID_SDK_ROOT = /Users/minzhao/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16B40
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.95.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.98.0

[✓] Network resources
• All expected network resources are available.

@snipd-min snipd-min added 1 backlog bug Something isn't working labels Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

Oops, it appears that your issue did not follow the template and is missing one or more required sections. Please open a new issue, and provide all required sections and information.

FAQ:

  1. Do I really need to submit a minimal reproduction project for a bug? A: Yes. I prioritise bugs secondarily on how many people are affected, and primarily on whether the bug report is complete, in the sense that it enables me to immediately reproduce it and start working on a fix. If a bug is important to you, the best thing you can do is to provide all requested information ASAP so that I can start looking into it ASAP.

  2. I think I supplied all required information, so did the bot make a mistake? A: The bot only checks the section headings, so when you post a new issue, make sure you leave the section headings intact. (Note that because of this, it is even possible to trick the bot by including only the section headings, and then not providing the requested information under each heading. This is frowned upon, and the issue will be closed manually.)

@github-actions github-actions bot closed this as completed Dec 2, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants