safe_device
safe_device copied to clipboard
Experiencing Frame Skipping Issue When Initializing safe_device in Flutter Project
Adding the safe_device dependency (dependencies: safe_device: ^1.1.6) to my Flutter project results in significant frame skipping issues when initializing it according to the provided example code. The frame skipping issue manifests as "I/Choreographer(25265): Skipped 1806 frames! The application may be doing too much work on its main thread." in the logs. However, removing the safe_device dependency resolves the issue.
Steps to Reproduce:
Add safe_device dependency to pubspec.yaml. yaml Copy code dependencies: safe_device: ^1.1.6 Initialize safe_device using the example code provided here. Run the Flutter project on an Android emulator (API 34). Expected Behavior: The application should run smoothly without any frame skipping issues after initializing the safe_device package.
Actual Behavior:
The application experiences significant frame skipping, and the log displays "I/Choreographer(25265): Skipped 1806 frames! The application may be doing too much work on its main thread." whenever safe_device is initialized.
Environment Information:
- Flutter 3.19.2 • channel stable • GitHub Repo
- Framework: revision 7482962148 (7 weeks ago) • 2024-02-27 16:51:22 -0500
- Engine: revision 04817c99c9
- Tools: Dart 3.3.0 • DevTools 2.31.1 Device/Emulator: SDK gphone64 x86 64 (mobile) • emulator-5554 • Android-x64 • Android 14 (API 34) (emulator) Operating System: [Specify your operating system]
Additional Information:
Other dependencies/plugins in the project do not seem to be causing similar issues. The issue persists across multiple attempts and devices/emulators. I'm open to alternative packages with similar functionalities.
Logs:
I/RootBeer(26952): LOOKING FOR BINARY: /data/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /dev/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /product/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /apex/com.android.runtime/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /apex/com.android.art/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system_ext/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /odm/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /vendor/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /vendor/xbin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /data/local/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /data/local/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /data/local/xbin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /sbin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /su/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system/bin/.ext/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system/bin/failsafe/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system/sd/xbin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system/usr/we-need-root/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system/xbin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /cache/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /data/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /dev/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /product/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /apex/com.android.runtime/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /apex/com.android.art/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /system_ext/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /odm/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /vendor/bin/su Absent :(
I/RootBeer(26952): LOOKING FOR BINARY: /vendor/xbin/su Absent :(
W/Settings(26952): Setting development_settings_enabled has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
D/EGL_emulation(26952): app_time_stats: avg=59202.94ms min=27871.63ms max=90534.24ms count=2
Priority:
High
Hello, did you try build release apk and try again ?
can you share your device info ?
did you try other one device ?
same here with 1.1.7 and flutter 3.22.2
Facing the same issue on my end as well.
Linked Issue: https://github.com/flutter/flutter/issues/151369
If I don't start LocationAssistantListener at the onAttachedToEngine function it works and I reduced initialization from 1 min to 8 seconds.
If you don't use isMockLocation
I recommend just forking the lib and removing every part of it, as @tulioccalazans did here.
An alternative is to run LocationAssistantListener not at the Main thread or implementing like the location package did.
You can detect if it is a mock location with location package
Same problem here, in android, the app skips a lot of frames, and I tried removing the safe_device and it works, I have the following information:
Steps to Reproduce:
Add safe_device dependency to pubspec.yaml. yaml Copy code
dependencies:
safe_device: ^1.1.7 Initialize safe_device using the example code provided here. Run the Flutter project on an Android emulator (API 34).
Expected Behavior:
The application should run smoothly without any frame skipping issues after initializing the safe_device package.
Actual behavior:
when the app is opened, it takes 8 seconds aprox to open, then sometimes appears the message "app not responding".
Flutter doctor
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.2.1 23C71 darwin-arm64, locale en-PY) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] VS Code (version 1.85.1) [✓] Connected device (4 available) [✓] Network resources
Logs from the console:
/FLTFireContextHolder( 6517): received application context.
D/FlutterGeolocator( 6517): Geolocator foreground service connected
D/FlutterGeolocator( 6517): Initializing Geolocator services
D/FlutterGeolocator( 6517): Flutter engine connected. Connected engine count 2
D/eglCodecCommon( 6517): setVertexArrayObject: set vao to 0 (0) 1 0
I/TRuntime.CctTransportBackend( 6517): Status Code: 200
I/Choreographer( 6517): Skipped 1799 frames! The application may be doing too much work on its main thread.
D/EGL_emulation( 6517): eglMakeCurrent: 0x7931952a80: ver 3 0 (tinfo 0x791929b400)
D/eglCodecCommon( 6517): setVertexArrayObject: set vao to 0 (0) 1 2
I/OpenGLRenderer( 6517): Davey! duration=30043ms; Flags=0, IntendedVsync=202387139974443, Vsync=202417123306577, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=202417133937946, AnimationStart=202417134003280, PerformTraversalsStart=202417134004488, DrawStart=202417138283571, SyncQueued=202417146619196, SyncStart=202417147295363, IssueDrawCommandsStart=202417147479155, SwapBuffers=202417162041113, FrameCompleted=202417184199905, DequeueBufferDuration=921000, QueueBufferDuration=2049000,
I/FLTFireMsgService( 6517): FlutterFirebaseMessagingBackgroundService started!
E/FirebaseMessaging( 6517): Topic operation failed: SERVICE_NOT_AVAILABLE. Will retry Topic operation.
I/Choreographer( 6517): Skipped 1800 frames! The application may be doing too much work on its main thread.
Notes:
I found this issue in geolocator package, and they mention something about safe_device, https://github.com/Baseflow/flutter-geolocator/issues/1296