-
Notifications
You must be signed in to change notification settings - Fork 73
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
double byte strings are not handled correctly #5
Comments
The crash occurred in SingalR.shouldHandleRequest the data is not null, I changed the SignalR.swift to print out the error: looks like NSJSONSerialization.JSONObjectWithData has some issue. |
here is the content of data: |
Original string received from the wire: String removed the swiftR prefix After webView.stringByEvaluatingJavaScriptFromString, the string is like below |
Support unicode messages from web view.
Thanks for noticing this. I've changed the way messages are passed from the web view to Swift to support unicode characters. This works with the Chinese characters in your example. Let me know how it works out for you. |
great, the issue is fixed. I can send and receive Chinese characters successfully. thanks a lot for the quick turn around ! |
Run the SwiftR iOS sample, for ASCII text, it works great with a browser client. But for double byte strings (e.g. Chinese characters), the browser client shows the strings correctly, but the iOS client does not handled correctly.
Repro 1:
Send from the browser client with some Chinese characters "你好“, the iOS cilent shows garbage string like this: `}
Repro 2:
Send from the browser client with some other Chinese characters "你好吗", the iOS client crashed with below error.
OnDisconnected e835293b-1df2-4b3d-b995-1d6a0d619ec3
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb) bt
frame #0: 0x000000010021d474 libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () + 44
frame Add cookie container #1: 0x00000001000ed148 SwiftR`SwiftR.SignalR.shouldHandleRequest (request=0x0000000170009640, self=0x00000001700d9280)(ObjectiveC.NSURLRequest) -> Swift.Bool + 2328 at SwiftR.swift:128
frame Converting existing Javascript SignalR to SwiftR #2: 0x00000001000ef160 SwiftR`SwiftR.SignalR.webView (webView=0x000000013f5146b0, request=0x0000000170009640, navigationType=Other, self=0x00000001700d9280)(ObjectiveC.UIWebView, shouldStartLoadWithRequest : ObjectiveC.NSURLRequest, navigationType : C.UIWebViewNavigationType) -> Swift.Bool + 120 at SwiftR.swift:180
frame Use the main bundle by default #3: 0x00000001000ef200 SwiftR`@objc SwiftR.SignalR.webView (SwiftR.SignalR)(ObjectiveC.UIWebView, shouldStartLoadWithRequest : ObjectiveC.NSURLRequest, navigationType : C.UIWebViewNavigationType) -> Swift.Bool + 100 at SwiftR.swift:0
frame use more performant WKWebview #4: 0x000000018aa9a0ac UIKit`-[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:] + 332
frame double byte strings are not handled correctly #5: 0x0000000185e36100 CoreFoundation
__invoking___ + 144 frame #6: 0x0000000185d322fc CoreFoundation
-[NSInvocation invoke] + 296frame On, Invoke does not return #7: 0x0000000185d36e30 CoreFoundation
-[NSInvocation invokeWithTarget:] + 68 frame #8: 0x000000019559c898 WebKitLegacy
-[_WebSafeForwarder forwardInvocation:] + 172frame How can i disconnect the connection? #9: 0x0000000185e33f6c CoreFoundation
___forwarding___ + 440 frame #10: 0x0000000185d36ccc CoreFoundation
_CF_forwarding_prep_0 + 92frame invoke server method,how get return value,eg string #11: 0x0000000185e36100 CoreFoundation
**invoking_** + 144 frame #12: 0x0000000185d322fc CoreFoundation
-[NSInvocation invoke] + 296frame Connection is automatically closed when the App enter foreground from background #13: 0x0000000194742efc WebCore
HandleDelegateSource(void*) + 120 frame #14: 0x0000000185de8240 CoreFoundation
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24frame Using WKWebView does not work #15: 0x0000000185de74e4 CoreFoundation
__CFRunLoopDoSources0 + 264 frame #16: 0x0000000185de5594 CoreFoundation
__CFRunLoopRun + 712frame exception in shouldHandleRequest #17: 0x0000000185d112d4 CoreFoundation
CFRunLoopRunSpecific + 396 frame #18: 0x000000018f5276fc GraphicsServices
GSEventRunModal + 168frame How to connect to a remote server #19: 0x000000018a8d6fac UIKit
UIApplicationMain + 1488 frame #20: 0x000000010003d294 SwiftR iOS Demo
main + 164 at AppDelegate.swift:12frame critical files saved in tmp folder #21: 0x0000000197cdaa08 libdyld.dylib`start + 4
The text was updated successfully, but these errors were encountered: