OsmSharp / ui

The UI components.
http://osmsharp.com/
GNU General Public License v2.0
138 stars 91 forks source link

Both Android and iOS sample stopped with error #181

Closed kochizufan closed 9 years ago

kochizufan commented 10 years ago

OsmSharp.Android.UI.Sample stopped with error.

Position of error: Utilities.cs line 620

            // deserialize.
            return model.Deserialize(cappedStream, value, type); <= Here

Error messages:

ProtoBuf.ProtoException: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354
  at at ProtoBuf.ProtoReader.SkipField () <IL 0x001b3, 0x00708>
  at at ProtoBuf.Meta.TypeModel.TryDeserializeAuxiliaryType (ProtoBuf.ProtoReader,ProtoBuf.DataFormat,int,System.Type,object&,bool,bool,bool,bool) <IL 0x000c2, 0x00637>
  at at ProtoBuf.Meta.TypeModel.TryDeserializeList (ProtoBuf.Meta.TypeModel,ProtoBuf.ProtoReader,ProtoBuf.DataFormat,int,System.Type,System.Type,object&) <IL 0x000b7, 0x00753>
  at at ProtoBuf.Meta.TypeModel.TryDeserializeAuxiliaryType (ProtoBuf.ProtoReader,ProtoBuf.DataFormat,int,System.Type,object&,bool,bool,bool,bool) <IL 0x00079, 0x0040f>
  at at ProtoBuf.Meta.TypeModel.DeserializeCore (ProtoBuf.ProtoReader,System.Type,object,bool) <IL 0x0002b, 0x001df>
  at at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream,object,System.Type,ProtoBuf.SerializationContext) <IL 0x00026, 0x001af>
  at at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream,object,System.Type) <IL 0x00005, 0x00067>
  at OsmSharp.Utilities.DeserializeWithSize (ProtoBuf.Meta.RuntimeTypeModel,System.IO.Stream,object,System.Type) [0x0002c] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp/Utilities.cs:620
  at OsmSharp.Collections.Tags.Serializer.TagsCollectionSerializer.DeserializeWithSize (System.IO.Stream) [0x00026] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp/Collections/Tags/Serializer/TagsCollectionSerializer.cs:57
  at OsmSharp.UI.Renderer.Scene.Storage.SceneSerializer.Deserialize (System.IO.Stream,bool,OsmSharp.Collections.Tags.TagsCollectionBase&) [0x0000e] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.UI/Renderer/Scene/Storage/SceneSerializer.cs:202
  at OsmSharp.UI.Renderer.Scene.Scene2D.Deserialize (System.IO.Stream,bool,OsmSharp.Collections.Tags.TagsCollectionBase&) [0x0000e] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.UI/Renderer/Scene/Scene2D.cs:651
  at OsmSharp.UI.Renderer.Scene.Scene2D.Deserialize (System.IO.Stream,bool) [0x00005] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.UI/Renderer/Scene/Scene2D.cs:663
  at OsmSharp.Android.UI.Sample.MainActivity.OnCreate (Android.OS.Bundle) [0x0003e] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.Android.UI.Sample/MainActivity.cs:101
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/1131/2a7b6821/source/monodroid/src/Mono.Android/platforms/android-12/src/generated/Android.App.Activity.cs:1917
  at at (wrapper dynamic-method) object.aba828a9-bef9-4335-abfb-664eb5358115 (intptr,intptr,intptr) <IL 0x00017, 0x00043>

Environment: Xamarin Studio 5.3 Xamatin.Android 4.16.0 Tested device: Samsung Galaxy S5 with Android 4.4

kochizufan commented 10 years ago

Similar error also occured in iOS sample:

Error position: same with Android

Error messages:

ProtoBuf.ProtoException: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354
  at ProtoBuf.ProtoReader.SkipField () [0x00000] in <filename unknown>:0
  at ProtoBuf.Meta.TypeModel.TryDeserializeAuxiliaryType (ProtoBuf.ProtoReader reader, DataFormat format, Int32 tag, System.Type type, System.Object& value, Boolean skipOtherFields, Boolean asListItem, Boolean autoCreate, Boolean insideList) [0x00000] in <filename unknown>:0
  at ProtoBuf.Meta.TypeModel.TryDeserializeList (ProtoBuf.Meta.TypeModel model, ProtoBuf.ProtoReader reader, DataFormat format, Int32 tag, System.Type listType, System.Type itemType, System.Object& value) [0x00000] in <filename unknown>:0
  at ProtoBuf.Meta.TypeModel.TryDeserializeAuxiliaryType (ProtoBuf.ProtoReader reader, DataFormat format, Int32 tag, System.Type type, System.Object& value, Boolean skipOtherFields, Boolean asListItem, Boolean autoCreate, Boolean insideList) [0x00000] in <filename unknown>:0
  at ProtoBuf.Meta.TypeModel.DeserializeCore (ProtoBuf.ProtoReader reader, System.Type type, System.Object value, Boolean noAutoCreate) [0x00000] in <filename unknown>:0
  at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type, ProtoBuf.SerializationContext context) [0x00000] in <filename unknown>:0
  at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type) [0x00000] in <filename unknown>:0
  at OsmSharp.Utilities.DeserializeWithSize (ProtoBuf.Meta.RuntimeTypeModel model, System.IO.Stream source, System.Object value, System.Type type) [0x0002c] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp/Utilities.cs:620
  at OsmSharp.Collections.Tags.Serializer.TagsCollectionSerializer.DeserializeWithSize (System.IO.Stream stream) [0x00026] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp/Collections/Tags/Serializer/TagsCollectionSerializer.cs:57
  at OsmSharp.UI.Renderer.Scene.Storage.SceneSerializer.Deserialize (System.IO.Stream stream, Boolean compress, OsmSharp.Collections.Tags.TagsCollectionBase& metaData) [0x0000e] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.UI/Renderer/Scene/Storage/SceneSerializer.cs:202
  at OsmSharp.UI.Renderer.Scene.Scene2D.Deserialize (System.IO.Stream stream, Boolean compress, OsmSharp.Collections.Tags.TagsCollectionBase& metaData) [0x0000e] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.UI/Renderer/Scene/Scene2D.cs:651
  at OsmSharp.UI.Renderer.Scene.Scene2D.Deserialize (System.IO.Stream stream, Boolean compress) [0x00005] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.UI/Renderer/Scene/Scene2D.cs:663
  at OsmSharp.iOS.UI.Sample.SampleViewController.LoadView () [0x00034] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.iOS.UI.Sample/SampleViewController.cs:110
  at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00008] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIWindow.g.cs:215
  at OsmSharp.iOS.UI.Sample.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00038] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.iOS.UI.Sample/AppDelegate.cs:23
  at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:39
  at OsmSharp.iOS.UI.Sample.Application.Main (System.String[] args) [0x00008] in /Users/kokogiko/Projects/MapApp/OsmSharp/OsmSharp.iOS.UI.Sample/Main.cs:35

Environment: Xamarin Studio 5.3 Xamatin.iOS 7.4.0.108 Tested device: iPhone5S with iOS 7.1.2

SMavr commented 9 years ago

I get exactly the same exception in the Android.Routing.Offline project on a tap event. Inside the Router.cs

var fromResolved = router.Resolve(Vehicle.Car, from); // Line 52

xivk commented 9 years ago

Thanks, is on the TODO-list this one!

SMavr commented 9 years ago

The OsmSharp.Android.UI.Sample works prefectly when I test the sample .map files (default.map or blue.map).

var sceneStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"OsmSharp.Android.UI.Sample.default.map"); map.AddLayer(new LayerScene(Scene2D.Deserialize(sceneStream, true)));

But when I am trying to test it with .map sample files from mapsforge (http://download.mapsforge.org/maps/) I am getting a ProtoBuf.ProtoException: Invalid field in source data: 0 in Utilities.cs inside SerializeWithSize:

return model.Deserialize(cappedStream, value, type);

Any idea how I could fix that? Is it something that I am doing wrong?

xivk commented 9 years ago

The maps from mapsforge are not compatible with the maps generated by OsmSharp, sorry about that.

And all the samples should work again. Feel free to reopen this issue if there are still problems.