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

Widget inspector is not working #16

Open
Ramzes5614 opened this issue Dec 6, 2023 · 3 comments
Open

Widget inspector is not working #16

Ramzes5614 opened this issue Dec 6, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Ramzes5614
Copy link

Ramzes5614 commented Dec 6, 2023

Hi! Thanks for the plugin!
There is an error with widget inspector. It does not start when the project has a custom ContentProvider.

On your example_provider it's also not working. How can we solve this problem?

Снимок экрана 2023-12-06 в 19 38 00

@pragma('vm:entry-point')
void exampleContentProviderEntrypoint() {
  MyAndroidContentProvider(
    'com.nt4f04und.android_content_provider_example.MyAndroidContentProvider',
  );
}
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.84.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!```
@Ramzes5614
Copy link
Author

@nt4f04uNd, We also tried to run on Flutter version 3.13. To no avail

@nt4f04uNd
Copy link
Owner

Hi

This is bug a in Flutter SDK
flutter/devtools#6640

When AndroidContentProvider is created, it first creates its own engine.
The engine for FlutterAcivity is created the after that, and is not picked up by flutter_tools (supposedly).
Therefore what you see in devtools is Flutter tree tied to AndroidContentProvider isolate (which doesn't draw anything).

I digged a bit, but I don't think there is an easy way to properly fix this on our side.

But there is a workaround for it, which you can use when you need to access devtools.

package com.nt4f04und.android_content_provider_example

import android.os.Handler
import android.os.Looper
import com.nt4f04und.android_content_provider.AndroidContentProvider

class MyAndroidContentProvider : AndroidContentProvider() {
    override val authority: String = "com.nt4f04und.android_content_provider_example.MyAndroidContentProvider"
    override val entrypointName = "exampleContentProviderEntrypoint"

    override fun onCreate(): Boolean {
        Handler(Looper.getMainLooper()).postDelayed({
            super.onCreate()
        }, 2000)
        return true
    }
}

Let me know if that works for you and I could put that into README

@YoungPotato
Copy link

Hi

This is bug a in Flutter SDK flutter/devtools#6640

When AndroidContentProvider is created, it first creates its own engine. The engine for FlutterAcivity is created the after that, and is not picked up by flutter_tools (supposedly). Therefore what you see in devtools is Flutter tree tied to AndroidContentProvider isolate (which doesn't draw anything).

I digged a bit, but I don't think there is an easy way to properly fix this on our side.

But there is a workaround for it, which you can use when you need to access devtools.

package com.nt4f04und.android_content_provider_example

import android.os.Handler
import android.os.Looper
import com.nt4f04und.android_content_provider.AndroidContentProvider

class MyAndroidContentProvider : AndroidContentProvider() {
    override val authority: String = "com.nt4f04und.android_content_provider_example.MyAndroidContentProvider"
    override val entrypointName = "exampleContentProviderEntrypoint"

    override fun onCreate(): Boolean {
        Handler(Looper.getMainLooper()).postDelayed({
            super.onCreate()
        }, 2000)
        return true
    }
}

Let me know if that works for you and I could put that into README

Thanks for the quick response.
It works. It's enough for the provider to be created asynchronously, while DevTools are initialized synchronously (not sure). So, you can skip the delay and use 0 instead of 2000

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

3 participants