Giter VIP home page Giter VIP logo

Comments (5)

sergejsha avatar sergejsha commented on September 24, 2024

Just added a stetho scope dumper able to print out something like this.

sergej: scripts (master) $ ./dumpapp magnet scope
    [1] magnet.internal.MagnetScope@cc668bd
       BOUND android.app.Application de.halfbit.a3.A3App@3925eb2
       BOUND android.content.ContentResolver android.app.ContextImpl$ApplicationContentResolver@dd8be03
       BOUND android.content.Context/application de.halfbit.a3.A3App@3925eb2
       BOUND android.content.res.Resources/application android.content.res.Resources@8800180
       INJECTED TOPMOST de.halfbit.a3.MainPageProvider de.halfbit.a3.catalog.CatalogPageProvider@7f5d3b9
       INJECTED TOPMOST de.halfbit.a3.catalog.CatalogPage de.halfbit.a3.catalog.device.DeviceCatalogPage@443b3fe
       INJECTED TOPMOST de.halfbit.a3.catalog.CatalogPage de.halfbit.a3.catalog.library.LibraryCatalogPage@61f375f
       INJECTED TOPMOST de.halfbit.a3.catalog.device.commons.permissions.MediaPermissions de.halfbit.a3.catalog.device.commons.permissions.DefaultMediaPermissions@a3b5ac
       INJECTED TOPMOST de.halfbit.a3.catalog.device.commons.scanner.CharsetCorrector de.halfbit.a3.catalog.device.commons.scanner.DefaultCharsetCorrector@616f275
       INJECTED TOPMOST de.halfbit.a3.catalog.device.commons.scanner.DeviceScanner de.halfbit.a3.catalog.device.commons.scanner.DefaultDeviceMediaScanner@123120a
       INJECTED TOPMOST de.halfbit.a3.catalog.device.commons.scanner.resolvers.ResolverAlbumScanner de.halfbit.a3.catalog.device.commons.scanner.resolvers.ResolverAlbumScanner@929ea7b
       INJECTED TOPMOST de.halfbit.a3.catalog.device.commons.scanner.resolvers.ResolverMediaScanner de.halfbit.a3.catalog.device.commons.scanner.resolvers.ResolverMediaScanner@26c8098
       INJECTED TOPMOST de.halfbit.a3.database.A3Database de.halfbit.a3.database.A3Database_Impl@4f140f1
       INJECTED TOPMOST de.halfbit.a3.database.asset.AssetDao de.halfbit.a3.database.asset.AssetDao_Impl@7e844d6
       INJECTED TOPMOST de.halfbit.commons.eventus.Eventus de.halfbit.commons.eventus.DefaultEventus@662b357
       INJECTED TOPMOST magnetx.AppExtension$Delegate magnetx.AppExtension$Delegate@6f50e44
       [2] magnet.internal.MagnetScope@d47fb2d
          BOUND android.content.Context de.halfbit.a3.MainActivity@7b22855
          BOUND android.content.res.Resources android.content.res.Resources@7fbd862
          BOUND android.view.LayoutInflater com.android.internal.policy.PhoneLayoutInflater@ff52df3
          BOUND androidx.fragment.app.FragmentActivity de.halfbit.a3.MainActivity@7b22855
          BOUND androidx.fragment.app.FragmentManager FragmentManager{c56cab0 in HostCallbacks{6d61d29}}
          BOUND androidx.lifecycle.LifecycleOwner de.halfbit.a3.MainActivity@7b22855
          [3] magnet.internal.MagnetScope@cc318ae
             BOUND android.view.View androidx.constraintlayout.motion.widget.MotionLayout{52ab64f V.E...... ........ 0,0-1080,1794 #7f080057 app:id/catalogContainer}
             BOUND androidx.fragment.app.Fragment CatalogFragment{6d5e1dc (a7dd3904-42c8-427e-8c32-b4a30e27c8e4) id=0x7f0800c0}
             BOUND androidx.lifecycle.LifecycleOwner CatalogFragment{6d5e1dc (a7dd3904-42c8-427e-8c32-b4a30e27c8e4) id=0x7f0800c0}
             INJECTED TOPMOST de.halfbit.a3.catalog.CatalogView de.halfbit.a3.catalog.DefaultCatalogView@a62e5
             INJECTED TOPMOST de.halfbit.a3.catalog.CatalogViewBinder de.halfbit.a3.catalog.DefaultCatalogViewBinder@ac11ba
          [3] magnet.internal.MagnetScope@686686b
             BOUND android.view.View androidx.swiperefreshlayout.widget.SwipeRefreshLayout{8cd3fc8 V.ED..... ........ 1080,0-2160,1437 #7f08007b app:id/deviceFragmentContainer}
             BOUND androidx.fragment.app.Fragment DeviceFragment{5834861 (657a8240-52c4-44e2-b65f-44d3e5cf7cb4) id=0x7f08015e}
             BOUND androidx.fragment.app.FragmentManager FragmentManager{4f98f86 in DeviceFragment{5834861}}
             BOUND androidx.lifecycle.LifecycleOwner DeviceFragment{5834861 (657a8240-52c4-44e2-b65f-44d3e5cf7cb4) id=0x7f08015e}
             BOUND de.halfbit.knot.CompositeKnot de.halfbit.knot.DefaultCompositeKnot@fa12047
             BOUND magnetx.lifecycle.BindableViewModelProvider magnetx.lifecycle.FragmentBindableViewModelProvider@d5a9074
             INJECTED TOPMOST de.halfbit.a3.catalog.device.DeviceView de.halfbit.a3.catalog.device.DefaultDeviceView@54b099d
             INJECTED TOPMOST de.halfbit.a3.catalog.device.DeviceViewBinder de.halfbit.a3.catalog.device.DeviceViewBinder@a4f1e12

Numbers in brackets are depth levels of scopes. After looking at the dump I thought that adding a name field to scopes might be helpful here. Although even without it the dump gives a good overview on what's happening. What do you think @realdadfish?

from magnet.

realdadfish avatar realdadfish commented on September 24, 2024

TIL about dumpapp, up until now I thought Stetho could only be used in conjunction with a Chrome instance... nice!

Yes, I think named scopes become a thing with this, even if you can probably depict the scope's name also by looking at the bound instances, but still. INJECTED could be TOPMOST or DIRECT, since UNSCOPED means that a created instance is not added to any particular scope, right?

Other than that I think it is pretty complete. One could debate if it would be useful to have a "short output" option which would skip repetition (shortening package names to single characters, skipping the output of the type class if the injected type is of the exact same type), but this is completely optional. As is it would already solve a lot of headaches and struggles we have today. Nice job!

from magnet.

sergejsha avatar sergejsha commented on September 24, 2024

Yeah, dumpapp is a command line tool. Just learned how it works today too. It's pretty simple and cool.

Yes, I think named scopes become a thing with this, even if you can probably depict the scope's name also by looking at the bound instances, but still.

I will let naming out for now then.

INJECTED could be TOPMOST or DIRECT, since UNSCOPED means that a created instance is not added to any particular scope, right?

Good point. INJECTED can be replaced by one of those. I'll replace it. You will never see UNSCOPED, because they never added to any scope.

Other than that I think it is pretty complete. One could debate if it would be useful to have a "short output" option which would skip repetition (shortening package names to single characters, skipping the output of the type class if the injected type is of the exact same type), but this is completely optional.

In the first version I unintentionally used simple names instead of full names and I liked it. Now, when you say the same, I will use it by default. Full names can be enforce via an option too.

As is it would already solve a lot of headaches and struggles we have today. Nice job!

Sorry to hear you experience that. I should be able to make the first RC in the beginning of next week. If you already use magnetx-app then to enable this feature you will need to add two debugImplementation dependencies. No code changes would be needed. If not, you will need to copy code from the new magnetx extension I'll release.

from magnet.

realdadfish avatar realdadfish commented on September 24, 2024

Take your time - your response times are awesome already :) After all I cannot sponsor you with this. Having a hard time persuading my current company to have an Open Source Policy that allows some upstream work at all. It might have sounded more drastic than it actually is, but usually issues that are introduced through Magnet like the unwanted top-most scoping get unnoticed for quite some time, until you start extensive (manual) testing. That's why I think having a tool to verify that your scope tree looks sane at development time is such an important proposition.

from magnet.

sergejsha avatar sergejsha commented on September 24, 2024

No probs. Not each company can profit from going open source. Some of them will even harm themselves. Google, for instance, has to make some products open source to spread and better sell their technologies. I think they do it not because they believe in "open source spirit", but rather because of pragmatical reasons. Apple, on the other hand, do not sell technologies, but end-products. They have no advantage in making their products open source. If they do, they will loose competitive advantage. Thus I can kind of understand your company :)

from magnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.