zyzdev / flutter_street_view

10 stars 32 forks source link

Problem using "onPanoramaChangeListener" #28

Closed davoutuk closed 1 year ago

davoutuk commented 1 year ago

I have been trying to use "onPanoramaChangeListener" as a way of capturing whether a street exists for a given LatLng, but I'm finding that this causing an uncaptured exception inside your package.

Here's the code

  Widget _buildStreetView(MapInfo aDetailMapInfo) {
    try {
      return _streetViewAvailable ? gs.FlutterGoogleStreetView(
          initPos: gs.LatLng(aDetailMapInfo.position.latitude,aDetailMapInfo.position.longitude),
          initRadius: 250.0,
          initSource: gs.StreetViewSource.outdoor,
          // onPanoramaChangeListener: (location,e) {
          //   setState(() {
          //     _streetViewAvailable = (e == null);
          //   });
          // },
        ) : const Center(child: Text('Street view not available for this location'));
    } on Exception catch (e) {
      return Center(child: Text('Street view failed with error: ${e.toString()}'));
    }
  }

If I run it as shown above with 'onPanoramaChangeListener' commented out, then I get a black screen displayed for the screen view and the following log output

I/SurfaceView@5a86955(11721): updateSurface: mSurfaceCreated = false surfaceChanged = true visibleChanged = true
I/SurfaceView@5a86955(11721): surfaceCreated 1 #8 com.google.maps.api.android.lib6.streetview.d{5a86955 VFE...C.. ........ 0,0-985,1348}
I/SurfaceView@5a86955(11721): surfaceChanged (985,1348) 1 #8 com.google.maps.api.android.lib6.streetview.d{5a86955 VFE...C.. ........ 0,0-985,1348}
I/ViewRootImpl@4fb686[MainActivity](11721): [DP] dp(1) 1 android.view.SurfaceView.updateSurface:1375 android.view.SurfaceView.lambda$new$1$SurfaceView:254 android.view.SurfaceView$$ExternalSyntheticLambda2.onPreDraw:2 
I/SurfaceView@5a86955(11721): uSP: rtp = Rect(47, 771 - 1032, 2119) rtsw = 985 rtsh = 1348
I/SurfaceView@5a86955(11721): onSSPAndSRT: pl = 47 pt = 771 sx = 1.0 sy = 1.0
I/SurfaceView@5a86955(11721): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@8e3da0a fN = 189 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged:319 
I/SurfaceView@5a86955(11721): aOrMT: vR.mWNT, vR = ViewRootImpl@4fb686[MainActivity]
I/ViewRootImpl@4fb686[MainActivity](11721): mWNT: t = android.view.SurfaceControl$Transaction@8e3da0a fN = 189 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 
I/ViewRootImpl@4fb686[MainActivity](11721): mWNT: merge t to BBQ
I/ViewRootImpl@4fb686[MainActivity](11721): [DP] pdf(0) 1 android.view.SurfaceView.notifyDrawFinished:599 android.view.SurfaceView.performDrawFinished:586 android.view.SurfaceView.$r8$lambda$st27mCkd9jfJkTrN_P3qIGKX6NY:0 
I/ViewRootImpl@4fb686[MainActivity](11721): [DP] rdf()
D/ViewRootImpl@4fb686[MainActivity](11721): reportDrawFinished (fn: -1) 

If I activate the 'onPanoramaChangeListener' event handler as shown below...

try {
  return _streetViewAvailable ? gs.FlutterGoogleStreetView(
      initPos: gs.LatLng(aDetailMapInfo.position.latitude,aDetailMapInfo.position.longitude),
      initRadius: 250.0,
      initSource: gs.StreetViewSource.outdoor,
      onPanoramaChangeListener: (location,e) {
        setState(() {
          _streetViewAvailable = (e == null);
        });
      },
    ) : const Center(child: Text('Street view not available for this location'));
} on Exception catch (e) {
  return Center(child: Text('Street view failed with error: ${e.toString()}'));
}

... then this for the same location generates the following exception...

I/ViewRootImpl@3d72ee0[MainActivity](13397): ViewPostIme pointer 0
I/ViewRootImpl@3d72ee0[MainActivity](13397): ViewPostIme pointer 1
I/zzbz    (13397): Making Creator dynamically
I/DynamiteModule(13397): Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:203115000
I/DynamiteModule(13397): Selected remote version of com.google.android.gms.maps_dynamite, version >= 203115000
V/DynamiteModule(13397): Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/eis.lejog.lejo(13397): ClassLoaderContext classpath element mismatch. expected=/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk, found=/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk (DLC[];PCL[/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk*2243878517:/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk!classes2.dex*2668200297:/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk!classes3.dex*334745928:/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk!classes4.dex*3476986656:/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk!classes5.dex*3073106838:/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk!classes6.dex*1474399738:/data/app/~~eWQyNIV4t9iP1LVf-GxFgQ==/com.fitbit.FitbitMobile-ONVjv_mZvaX1TRcqrfZUjg==/base.apk!classes7.dex*2719920584]{PCL[/system/framework/org.apache.http.legacy.jar*128607898]} | DLC[];PCL[/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk*1247502066:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes2.dex*3187687016:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes3.dex*1702229643:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes4.dex*437907607:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes5.dex*3765254733:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes6.dex*3225362172:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes7.dex*2301088448]{PCL[/system/framework/org.apache.http.legacy.jar*128607898]})
I/Google Maps Android API(13397): Google Play services client version: 12451000
I/Google Maps Android API(13397): Google Play services package version: 232414044
I/Google Maps Android API(13397): Google Play services maps renderer version(legacy): 203115000
I/PlatformViewsController(13397): Using hybrid composition for platform view: 0
I/bb      (13397): Successfully registered with Phenotype.
I/SurfaceView@9e09836(13397): onWindowVisibilityChanged(0) true com.google.maps.api.android.lib6.streetview.d{9e09836 VFE...C.. ......I. 0,0-0,0} of ViewRootImpl@3d72ee0[MainActivity]
I/SurfaceView@9e09836(13397): pST: sr = Rect(47, 771 - 1032, 2119) sw = 985 sh = 1348
I/SurfaceView@9e09836(13397): onSSPAndSRT: pl = 47 pt = 771 sx = 1.0 sy = 1.0
I/SurfaceView@9e09836(13397): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@ca914e9
I/SurfaceView@9e09836(13397): updateSurface: mVisible = true mSurface.isValid() = true
I/SurfaceView@9e09836(13397): updateSurface: mSurfaceCreated = false surfaceChanged = true visibleChanged = true
I/SurfaceView@9e09836(13397): surfaceCreated 1 #8 com.google.maps.api.android.lib6.streetview.d{9e09836 VFE...C.. ......ID 0,0-985,1348}
I/SurfaceView@9e09836(13397): surfaceChanged (985,1348) 1 #8 com.google.maps.api.android.lib6.streetview.d{9e09836 VFE...C.. ......ID 0,0-985,1348}
I/ViewRootImpl@3d72ee0[MainActivity](13397): [DP] dp(1) 1 android.view.SurfaceView.updateSurface:1375 android.view.SurfaceView.lambda$new$1$SurfaceView:254 android.view.SurfaceView$$ExternalSyntheticLambda2.onPreDraw:2 
I/SurfaceView@9e09836(13397): uSP: rtp = Rect(47, 771 - 1032, 2119) rtsw = 985 rtsh = 1348
I/SurfaceView@9e09836(13397): onSSPAndSRT: pl = 47 pt = 771 sx = 1.0 sy = 1.0
I/SurfaceView@9e09836(13397): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@d93156e fN = 2 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged:319 
I/SurfaceView@9e09836(13397): aOrMT: vR.mWNT, vR = ViewRootImpl@3d72ee0[MainActivity]
I/ViewRootImpl@3d72ee0[MainActivity](13397): mWNT: t = android.view.SurfaceControl$Transaction@d93156e fN = 2 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1728 
I/ViewRootImpl@3d72ee0[MainActivity](13397): mWNT: merge t to BBQ
I/ViewRootImpl@3d72ee0[MainActivity](13397): [DP] pdf(0) 1 android.view.SurfaceView.notifyDrawFinished:599 android.view.SurfaceView.performDrawFinished:586 android.view.SurfaceView.$r8$lambda$st27mCkd9jfJkTrN_P3qIGKX6NY:0 
I/ViewRootImpl@3d72ee0[MainActivity](13397): [DP] rdf()
D/ViewRootImpl@3d72ee0[MainActivity](13397): reportDrawFinished (fn: -1) 
I/SurfaceView@9e09836(13397): onWindowVisibilityChanged(8) false com.google.maps.api.android.lib6.streetview.d{9e09836 VFE...C.. ........ 0,0-985,1348} of ViewRootImpl@3d72ee0[MainActivity]
I/SurfaceView@9e09836(13397): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@ca914e9
I/SurfaceView@9e09836(13397): surfaceDestroyed callback.size 1 #2 com.google.maps.api.android.lib6.streetview.d{9e09836 VFE...C.. ........ 0,0-985,1348}
I/SurfaceView@9e09836(13397): updateSurface: mVisible = false mSurface.isValid() = true
I/SurfaceView@9e09836(13397): tryReleaseSurfaces: set mRtReleaseSurfaces = true
I/SurfaceView@9e09836(13397): onDetachedFromWindow: tryReleaseSurfaces()
I/SurfaceView@9e09836(13397): tryReleaseSurfaces: set mRtReleaseSurfaces = true
I/SurfaceView@9e09836(13397): 196086940 wPL, frameNr = 4
I/SurfaceView@9e09836(13397): remove() from RT android.view.SurfaceView$SurfaceViewPositionUpdateListener@bb00c9c Surface(name=SurfaceView - com.eis.lejog.lejog/com.eis.lejog.lejog.MainActivity@9e09836@0)/@0xa7516a5
I/SurfaceView@9e09836(13397): remove() com.google.maps.api.android.lib6.streetview.d{9e09836 VFE...C.. ........ 0,0-985,1348} Surface(name=SurfaceView - com.eis.lejog.lejog/com.eis.lejog.lejog.MainActivity@9e09836@0)/@0xa7516a5
I/SurfaceView@9e09836(13397): aOrMT: uB = false t = android.view.SurfaceControl$Transaction@6ff5688 fN = 4 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785 android.graphics.RenderNode$CompositePositionUpdateListener.positionLost:326 
I/SurfaceView@9e09836(13397): aOrMT: t.apply
W/DynamiteModule(13397): Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule(13397): Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:7
I/DynamiteModule(13397): Selected remote version of com.google.android.gms.googlecertificates, version >= 7
W/eis.lejog.lejo(13397): ClassLoaderContext type mismatch. expected=PCL, found=DLC (PCL[] | DLC[];PCL[/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk*1247502066:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes2.dex*3187687016:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes3.dex*1702229643:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes4.dex*437907607:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes5.dex*3765254733:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes6.dex*3225362172:/data/app/~~aKCLY37Fel0LYZ8WK9L5zg==/com.eis.lejog.lejog-XrtftY21Ru9zYmUR6iMngg==/base.apk!classes7.dex*2301088448]{PCL[/system/framework/org.apache.http.legacy.jar*128607898]})
I/SnapshotHandler(13397): Unable to retrieve flag snapshot for com.google.android.libraries.consentverifier#com.eis.lejog.lejog, using defaults.
W/MobStoreFlagStore(13397): Unable to update local snapshot for com.google.android.libraries.consentverifier#com.eis.lejog.lejog, may result in stale flags.
W/MobStoreFlagStore(13397): java.util.concurrent.ExecutionException: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.eis.lejog.lejog, sha256=[cf712b5da7a865ec27ce35698f601b49a5b0a8c7d1246750082d43b9916d2142], atk=false, ver=232414044.true (go/gsrlt)
W/MobStoreFlagStore(13397):     at m.ajx.s(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):3)
W/MobStoreFlagStore(13397):     at m.ajx.get(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):2)
W/MobStoreFlagStore(13397):     at m.alh.g(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):2)
W/MobStoreFlagStore(13397):     at m.yz.c(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):1)
W/MobStoreFlagStore(13397):     at m.zb.run(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):0)
W/MobStoreFlagStore(13397):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
W/MobStoreFlagStore(13397):     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/MobStoreFlagStore(13397):     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
W/MobStoreFlagStore(13397):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/MobStoreFlagStore(13397):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/MobStoreFlagStore(13397):     at java.lang.Thread.run(Thread.java:920)
W/MobStoreFlagStore(13397): Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.eis.lejog.lejog, sha256=[cf712b5da7a865ec27ce35698f601b49a5b0a8c7d1246750082d43b9916d2142], atk=false, ver=232414044.true (go/gsrlt)
W/MobStoreFlagStore(13397):     at android.os.Parcel.createExceptionOrNull(Parcel.java:2438)
W/MobStoreFlagStore(13397):     at android.os.Parcel.createException(Parcel.java:2422)
W/MobStoreFlagStore(13397):     at android.os.Parcel.readException(Parcel.java:2405)
W/MobStoreFlagStore(13397):     at android.os.Parcel.readException(Parcel.java:2347)
W/MobStoreFlagStore(13397):     at m.fe.c(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):2)
W/MobStoreFlagStore(13397):     at m.ry.a(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):4)
W/MobStoreFlagStore(13397):     at m.jl.e(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):2)
W/MobStoreFlagStore(13397):     at m.kj.t(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):2)
W/MobStoreFlagStore(13397):     at m.kj.u(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):3)
W/MobStoreFlagStore(13397):     at m.kj.e(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):2)
W/MobStoreFlagStore(13397):     at m.kn.handleMessage(:com.google.android.gms.dynamite_mapsdynamite@232414044@23.24.14 (190400-0):78)
W/MobStoreFlagStore(13397):     at android.os.Handler.dispatchMessage(Handler.java:102)
W/MobStoreFlagStore(13397):     at android.os.Looper.loopOnce(Looper.java:226)
W/MobStoreFlagStore(13397):     at android.os.Looper.loop(Looper.java:313)
W/MobStoreFlagStore(13397):     at android.os.HandlerThread.run(HandlerThread.java:67)
davoutuk commented 1 year ago

Drilling down further on this. I think I have found the underlying cause.

In my app I am using the "connectivity_plus" package to monitor internet/wifi connectivity. This manifests itself as a stream builder and I have this set a controlling function around the call to build the main view window. Hence, if the internet connection is lost the normal main window is replaced with another page display to explain loss of connectivity

It seems that whenever I call the Flutter_street_view widget for the first time this is triggering some "ConnectionState.waiting" changes that are being picked up by the "connectivity_plus". Hence, clicking on an icon that is meant to display the street view ends up repainting the whole app again

Note that this problem only occurs on the first time that the flutter street view is asked to paint itself. This generates a situation where:

  1. I log into my app
  2. The connectivity_plus package determines if there is internet connectivity
  3. If there is connectivity it displays the app main page
  4. On the main page is an icon that when when clicked will change part of the main page to display the Google Street view
  5. The user clicks on the 'street view' icon
  6. The connectivity_plus detects some internet connection status changes, and re paints the whole main page
  7. The user clicks on the 'street view' icon for the second time, and on this occasion the street view image is displayed

Any suggestions on how to fix this?

davoutuk commented 1 year ago

One additional finding... Even if I take out the 'connectivity_plus' code, the first time I click to show the street view something is causing the whole main page to redraw. Again, it works fine on all secondary clicks

davoutuk commented 1 year ago

Resolved

yogi1610 commented 1 week ago

@davoutuk App keeps crashing when using flutter_google_street_view: ^3.1.4. There are too many issues are already opened, please make it to close soon so that users can use the package