Navideck / universal_ble

A cross-platform Android/iOS/macOS/Windows/Linux/Web Bluetooth Low Energy (BLE) plugin for Flutter
https://pub.dev/packages/universal_ble
Other
19 stars 2 forks source link

MSIX "release" package returns different manufacturerData than "debug" package does #21

Closed BikeBr0 closed 1 month ago

BikeBr0 commented 2 months ago

A strange error is occuring when I try to package my application into an MSIX installer for Windows using the flutter recommended msix plugin. I don't receive any errors when packaging and the app installs fine. However, when running the app, I don't receive any BleScanResults (but it doesn't throw an error). This same app running through VSCode or packaged as a debug build does work. Do you have any ideas why this is behaving this way? Sounds like a possible race condition if slower debug builds do work.

Performing the same test with a trivial app that only includes UniversalBle works fine as an MSIX package built in "release" mode.

rohitsangwan01 commented 2 months ago

@BikeBr0 example app seems to be working fine with MSIX, can you cross check with example app, if example app works for you then its hard to tell the exact issue, but you can share a minimal project which replicates this bug

BikeBr0 commented 2 months ago

It does work with my simple test app too @rohitsangwan01 . I've tracked it down to a behaviourly difference in the BleScanResult stream. I am getting results but they are not appearing until the scanner is stopped (but this behaviour is limited to my actual app and not my simple test app). It's very strange as it does not occur in the DEBUG Build, only the RELEASE build. Joys of programming...

rohitsangwan01 commented 2 months ago

@BikeBr0 strange, again a test app which can replicate this behaviour will be helpful, also are you running something else with StartScan and StopScan methods, which might stop the ui thread, or do you notice any ui freeze while scan in progress ?

BikeBr0 commented 2 months ago

I think I have tracked down the bug @rohitsangwan01 . It seems the Company ID within the manufacturerData is not being set in the MSIX Release package. In my very simple test code, I only see [0,0,1] whereas my dev or debug build contains our actual Company ID.

fotiDim commented 1 month ago

@BikeBr0 can you please try flutter run -d windows --release and see if it works? I am not sure the issue is msix related.

fotiDim commented 1 month ago

@BikeBr0 I made a PR about it. Can you please try the code from the fix-wrong-manufacturer-data-in-release-mode branch and let me know if it works?

BikeBr0 commented 1 month ago

Will do. I'm away from my computer for a couple days but will check it as soon as I can.

BikeBr0 commented 1 month ago

flutter run -d windows --release

I can confirm that this reproduces the bug

BikeBr0 commented 1 month ago

@BikeBr0 I made a PR about it. Can you please try the code from the fix-wrong-manufacturer-data-in-release-mode branch and let me know if it works?

This has fixed the issue in my simple test app.