Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Freezes when going back and forth between activites #2018

Closed
erf opened this issue Aug 9, 2015 · 55 comments
Closed

Freezes when going back and forth between activites #2018

erf opened this issue Aug 9, 2015 · 55 comments
Assignees
Labels
Android Mapbox Maps SDK for Android bug

Comments

@erf
Copy link
Contributor

erf commented Aug 9, 2015

If you add a button to the main view in the test app, and open an arbitrary activity on a click event and then closes it, moves the map and click the button again, the app freezes on my nexus 7 (2012).
I made a simple test case here:
https://github.com/erf/mapbox-gl-native/tree/freezes

@1ec5 1ec5 added the Android Mapbox Maps SDK for Android label Aug 9, 2015
@ljbade ljbade added the bug label Aug 10, 2015
@erf
Copy link
Contributor Author

erf commented Aug 12, 2015

This also seem to happen if i moved the map first and then click on a button which opens the new activity. I don't see any information in the Log regarding this. I suspected this may be a memory issue when opening the map several times, so i even tried to make the mapview static, but with same result. I suspect now that some state is getting set when you move the map, but i have no idea what causes the crash.

@erf
Copy link
Contributor Author

erf commented Aug 12, 2015

I just made a simple example now on latest 4025da6 and this seem to work now! I close this for now.

@erf erf closed this as completed Aug 12, 2015
@erf erf reopened this Aug 12, 2015
@erf
Copy link
Contributor Author

erf commented Aug 12, 2015

This issue is back after i added loading mapView as a fragment described in #2042

@tobrun
Copy link
Member

tobrun commented Aug 17, 2015

Was able to reproduce this occasionally with following setup:
Genymotion - Google Nexus 5.0.0 image - 0.0.1-SNAPSHOT

Actions:
Open activity with MapView, scroll-zoom actions like a maniac, open other Activity containing a MapView. Application becomes unresponsive and screens turns black. Only option is to kill-app by swiping it from recents.

Used Activities:
StyledMapActivity - SearchMapActivity

Full stacktrace - code

@erf
Copy link
Contributor Author

erf commented Aug 17, 2015

I think the app crashes when trying to open a new activity whilst the MapView is still loading tiles.

Threading issue?

@ljbade
Copy link
Contributor

ljbade commented Aug 17, 2015

I also wonder if it is related to state saving.

@ljbade
Copy link
Contributor

ljbade commented Aug 17, 2015

@kkaefer Is there anything in the C++ layer to be aware of when there are multiple instances of a map?

@kkaefer
Copy link
Contributor

kkaefer commented Aug 17, 2015

@ljbade it should be possible and I'm not aware of an issues, but of course there could be bugs when using multiple instances.

@incanus
Copy link
Contributor

incanus commented Aug 18, 2015

We are handling multiple maps in iOS ok right now.

@ljbade
Copy link
Contributor

ljbade commented Aug 18, 2015

Hmm going to have to create a simple test app to see if I can reproduce it.

@incanus Do you recall if there were any specific fixes/changes that perhaps did not make it to Android to enable multiple maps?

@tobrun
Copy link
Member

tobrun commented Aug 18, 2015

@ljbade a simple test app can be found here

@ljbade
Copy link
Contributor

ljbade commented Aug 18, 2015

Thanks @tobrunvannuland

@bleege bleege added this to the android-v0.1.0 milestone Sep 1, 2015
@erf
Copy link
Contributor Author

erf commented Sep 2, 2015

Simple test case:
Try to have a map in both activity A and B. Open activity B from A and click in the map before all the tiles are loaded.

@ljbade
Copy link
Contributor

ljbade commented Sep 3, 2015

I done some reading at it appears the Android system does not support two SurfaceViews active at the same time.

So this bug might be due to limitations as a result of using SurfaceView.

Perhaps we will need to switch to TextureView to support more complex layouts.

@ljbade ljbade mentioned this issue Sep 3, 2015
@ljbade
Copy link
Contributor

ljbade commented Sep 4, 2015

We are pushing TextureView to 0.2.0 so we should wait to fix this bug then?

@bleege ?

@ljbade ljbade modified the milestones: android-v0.2.0, android-v0.1.0 Sep 4, 2015
@bleege
Copy link
Contributor

bleege commented Sep 4, 2015

Perhaps we will need to switch to TextureView to support more complex layouts.

@ljbade Thanks for looking into this. Before we can make a decision on milestone can you provide more detail as to why you believe TextureView would solve this issue? If there's a firm reason why you believe it should then we can definitely look to include #2244 in 0.1.0.

@ljbade
Copy link
Contributor

ljbade commented Sep 5, 2015

@bleege Basically we use SurfaceView. It is well documented the Android system does not support two SurfaceViews on the screen at the same time. This would include two different Activitiy where there might be some sort of transition or delay between the new MapView being created and the old MapView getting deleted.

TextureView does not have this limitation.

@ljbade
Copy link
Contributor

ljbade commented Sep 5, 2015

Although we also need to test if TextureView will fix this bug, in case it is something related to the native layer.

@ljbade
Copy link
Contributor

ljbade commented Sep 5, 2015

@erf Do you mind recreating the bug against the TextureView implementation in https://github.com/mapbox/mapbox-gl-native/tree/2244-texture-view branch?

I would like to know if this is a solution.

@erf
Copy link
Contributor Author

erf commented Sep 5, 2015

Will do. Just really busy right now..

@ljbade ljbade assigned ljbade and unassigned bleege Sep 16, 2015
@ljbade
Copy link
Contributor

ljbade commented Sep 16, 2015

@bleege Can you give https://github.com/mapbox/mapbox-gl-native/tree/2018-shared-sqlite a test drive?

Testing on the Samsung S6 I don't get the database lock errors. But I still get the freeze on rotation and the occasional crash.

@erf
Copy link
Contributor Author

erf commented Sep 16, 2015

Exited for this progress! Cheering =)

@kkaefer
Copy link
Contributor

kkaefer commented Sep 16, 2015

@ljbade can we use a uv_once/pthread_once?

@kkaefer
Copy link
Contributor

kkaefer commented Sep 16, 2015

Actually never mind, the existing code looks good.

@zugaldia
Copy link
Member

I'm adding a SecondMapActivityTest class to the Espresso test suite to help troubleshoot this.

@bleege
Copy link
Contributor

bleege commented Sep 16, 2015

I'm looking into the 2018-shared-sqlite branch, but ran into an issue with make android now from #2288. I'm going to undo it in this branch to test it out.

@bleege
Copy link
Contributor

bleege commented Sep 16, 2015

Ok, I've done my time in C++ land and can test this out now.

@bleege
Copy link
Contributor

bleege commented Sep 16, 2015

\o/ The database lock errors are now gone. I was able to rotate the test device from portrait to landscape and back again several times without any problems.! Great job @ljbade!

Will discuss the NPM issue with @lucaswoj before merging in though. Hopefully later today.

@incanus
Copy link
Contributor

incanus commented Sep 16, 2015

To round this out, we should probably get rid of iOS's MGLFileCache and move to this lower-level C++ implementation. I can look at that.

@incanus
Copy link
Contributor

incanus commented Sep 16, 2015

To be clear: it's not a blocker and we can ticket off the iOS refactor separately.

@bleege
Copy link
Contributor

bleege commented Sep 16, 2015

The plan is to remove 3764b051e4c9944ddbc3bcc9c8fd1beb8a28451e from 2018-shared-sqlite and then merge @ljbade's fix into master. We can then cherrypick that commit into release-android-0.1.0 so that both master and release-android-0.1.0 have it and a SNAPSHOT can be rolled because release-android-0.1.0 does not have the geojsonvt stuff.

Concurrently @lucaswoj @mikemorris will work on getting geojsonvt working again so that regular Android development can continue on master.

/cc @jfirebaugh

@incanus
Copy link
Contributor

incanus commented Sep 16, 2015

Refs #2344 re: geojsonvt problems introduced.

@bleege
Copy link
Contributor

bleege commented Sep 16, 2015

Merged. Now the cherrypick to release-android-0.1.0.

@incanus
Copy link
Contributor

incanus commented Sep 16, 2015

Speculatively fixed in #2345.

@erf
Copy link
Contributor Author

erf commented Sep 16, 2015

Awsome work !! I would like to test this out but i get the following build error:

deps/run_gyp geojsonvt.gyp -Iconfig.gypi --depth=. -Goutput_dir=. --generator-output=./build -f make
make -C build install
  CXX(target) Release/obj.target/geojsonvt/src/geojsonvt.o
  CXX(target) Release/obj.target/geojsonvt/src/geojsonvt_clip.o
  CXX(target) Release/obj.target/geojsonvt/src/geojsonvt_convert.o
  CXX(target) Release/obj.target/geojsonvt/src/geojsonvt_simplify.o
  CXX(target) Release/obj.target/geojsonvt/src/geojsonvt_tile.o
  LIBTOOL-STATIC Release/libgeojsonvt.a
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/geojsonvt/src/geojsonvt.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/geojsonvt/src/geojsonvt_clip.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/geojsonvt/src/geojsonvt_convert.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/geojsonvt/src/geojsonvt_simplify.o is not an object file (not allowed in a library)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: Release/obj.target/geojsonvt/src/geojsonvt_tile.o is not an object file (not allowed in a library)
make[3]: *** [Release/libgeojsonvt.a] Error 1
make[2]: *** [install] Error 2
make[1]: *** [config/android-arm-v7.gypi] Error 2
make: *** [android-lib] Error 2

@incanus
Copy link
Contributor

incanus commented Sep 16, 2015

@erf We are tracking that in #2348. For now you can test out the release-android-v0.1.0 branch, where we cherry-picked the fix, to essentially be based off of an older version of master that builds fine.

@erf
Copy link
Contributor Author

erf commented Sep 16, 2015

Ok, thanks!

@erf
Copy link
Contributor Author

erf commented Sep 17, 2015

i checked out the 'release-android-v0.1.0' branch, built it and tried it with my test app here: https://github.com/erf/mapbox-drawer-glitch/tree/open-activity-whilst-scrolling
It seems to work much better now, however i experienced a crash after going back and forth between the activites a few times, in the log i only got these:

09-17 12:21:23.961  32460-32671/? A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x3c in tid 32671 (sm-v1/2/2/1.pbf)
09-17 12:28:04.231    3204-3483/? A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x3c in tid 3483 (-v1/6/33/16.pbf)

AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug
Projects
None yet
Development

No branches or pull requests

9 participants