Skip to content

imporvement fixes#8546

Merged
jigar-f merged 4 commits intomainfrom
jigar/imporvement-fixes
Mar 20, 2026
Merged

imporvement fixes#8546
jigar-f merged 4 commits intomainfrom
jigar/imporvement-fixes

Conversation

@jigar-f
Copy link
Contributor

@jigar-f jigar-f commented Mar 19, 2026

This pull request introduces several improvements and refactors across the codebase, focusing mainly on service initialization, platform abstraction, and reliability enhancements. The most important changes are grouped below by theme.

Service Initialization & Dependency Injection:

  • Refactored injectServices in lib/core/services/injection_container.dart to initialize services more robustly and asynchronously, with improved error handling and logging. Services are now registered as singletons after successful initialization, and Stripe/notification services are handled together for Android.
  • Added an init method to the LanternCoreService interface and implemented it in LanternFFIService, MockLanternFFIService, LanternPlatformService, and LanternService to ensure proper initialization of platform and FFI services. Initialization is now lazy and avoids blocking UI rendering. [1] [2] [3] [4] [5] [6]

Platform Abstraction & Method Refactoring:

  • Refactored method signatures in LanternService for payment, split tunnel, and login methods to use named parameters for clarity and consistency. [1] [2] [3] [4] [5] [6]

Updater Logic & Feature Flags:

  • Updated Updater logic to fetch feature flags directly from LanternService, parse them from JSON, and respect the autoUpdateEnabled flag with a default value. Improved error handling and logging for update checks. [1] [2]

Reliability Improvements (Android VPN Service):

  • Improved VPN teardown logic in LanternVpnService.kt to only call Mobile.stopVPN() if Radiance IPC is connected, preventing misleading errors and unnecessary calls. Also, ensured Radiance setup is retried before starting the VPN tunnel if it was killed by the OS. [1] [2]
  • Added a check in stopVPNTunnel to skip stopping the VPN if it is not connected, improving robustness.

Logging Enhancements:

  • Improved warning logging in LanternLogger.kt to include stack traces for better debugging and visibility.

These changes collectively improve reliability, maintainability, and clarity in service initialization, platform abstraction, and error handling throughout the application.

Copilot AI review requested due to automatic review settings March 19, 2026 07:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors app/service initialization and platform abstractions, updates the desktop auto-updater to be feature-flag driven, improves Android VPN lifecycle robustness, and removes Sentry from the project.

Changes:

  • Removed sentry_flutter dependency and its generated platform registrations (Windows/Linux/macOS/iOS).
  • Reworked initialization flow: LanternCoreService now has an init() contract; injectServices() performs more structured async setup; timezone init is moved off the critical path.
  • Updated desktop Updater to fetch/parse feature flags via LanternService and respect autoUpdateEnabled; improved Android VPN teardown/startup checks and warning logging.

Reviewed changes

Copilot reviewed 18 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
windows/flutter/generated_plugins.cmake Drops Sentry/jni entries from generated Windows plugin lists.
windows/flutter/generated_plugin_registrant.cc Removes Sentry plugin registration on Windows.
linux/flutter/generated_plugins.cmake Drops Sentry/jni entries from generated Linux plugin lists.
linux/flutter/generated_plugin_registrant.cc Removes Sentry plugin registration on Linux.
macos/Podfile.lock Removes Sentry CocoaPods entries for macOS.
ios/Podfile.lock Removes Sentry CocoaPods entries for iOS.
macos/Flutter/GeneratedPluginRegistrant.swift Removes Sentry (and currently also PathProvider) registration from macOS registrant.
pubspec.yaml Removes sentry_flutter dependency.
pubspec.lock Removes sentry_flutter, sentry, and jni packages.
lib/main.dart Moves timezone config to background; simplifies startup and updater init call flow.
lib/lantern_app.dart Removes deep link debug logging noise.
lib/lantern/lantern_core_service.dart Adds init() to the core service interface.
lib/lantern/lantern_service.dart Implements init() delegating to FFI vs platform service; refactors method formatting/signatures.
lib/lantern/lantern_platform_service.dart Adjusts init behavior (no eager enabled-app snapshot refresh).
lib/lantern/lantern_ffi_service.dart Adds init() override marker and provides no-op init for the mock service.
lib/core/services/injection_container.dart Refactors DI/service initialization ordering, concurrency, and logging.
lib/core/updater/updater.dart Fetches feature flags from LanternService, parses JSON, and gates auto-updater by flag.
lib/core/models/feature_flags.dart Removes Sentry flag; reorders/retains update flag.
lib/core/common/app_secrets.dart Removes Sentry DSN configuration helper.
android/app/src/main/kotlin/org/getlantern/lantern/utils/LanternLogger.kt Includes stack traces in WARN log persistence.
android/app/src/main/kotlin/org/getlantern/lantern/service/LanternVpnService.kt Hardens VPN teardown/start logic around Radiance/VPN connection checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jigar-f jigar-f self-assigned this Mar 19, 2026
sl.registerSingleton<LanternService>(lanternService);
} catch (e) {
appLogger.error('LanternService init failed', e);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn’t the safer pattern here to register LanternService first, then call init()?

With the current flow, if init() fails, LanternService is never registered and later sl() lookups can hard-crash startup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Now, if even if init fails, we still register services

@jigar-f jigar-f merged commit a146b40 into main Mar 20, 2026
8 checks passed
@jigar-f jigar-f deleted the jigar/imporvement-fixes branch March 20, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants