• <bdo id='39xht'></bdo><ul id='39xht'></ul>

    1. <tfoot id='39xht'></tfoot>

      <small id='39xht'></small><noframes id='39xht'>

      <i id='39xht'><tr id='39xht'><dt id='39xht'><q id='39xht'><span id='39xht'><b id='39xht'><form id='39xht'><ins id='39xht'></ins><ul id='39xht'></ul><sub id='39xht'></sub></form><legend id='39xht'></legend><bdo id='39xht'><pre id='39xht'><center id='39xht'></center></pre></bdo></b><th id='39xht'></th></span></q></dt></tr></i><div id='39xht'><tfoot id='39xht'></tfoot><dl id='39xht'><fieldset id='39xht'></fieldset></dl></div>
        <legend id='39xht'><style id='39xht'><dir id='39xht'><q id='39xht'></q></dir></style></legend>
      1. iPhone 应用程序在 WebThread MPVolumeSlider 上崩溃

        时间:2023-10-22
      2. <legend id='zDh2P'><style id='zDh2P'><dir id='zDh2P'><q id='zDh2P'></q></dir></style></legend>

          <small id='zDh2P'></small><noframes id='zDh2P'>

              <i id='zDh2P'><tr id='zDh2P'><dt id='zDh2P'><q id='zDh2P'><span id='zDh2P'><b id='zDh2P'><form id='zDh2P'><ins id='zDh2P'></ins><ul id='zDh2P'></ul><sub id='zDh2P'></sub></form><legend id='zDh2P'></legend><bdo id='zDh2P'><pre id='zDh2P'><center id='zDh2P'></center></pre></bdo></b><th id='zDh2P'></th></span></q></dt></tr></i><div id='zDh2P'><tfoot id='zDh2P'></tfoot><dl id='zDh2P'><fieldset id='zDh2P'></fieldset></dl></div>

                <bdo id='zDh2P'></bdo><ul id='zDh2P'></ul>

                <tfoot id='zDh2P'></tfoot>
                  <tbody id='zDh2P'></tbody>
                1. 本文介绍了iPhone 应用程序在 WebThread MPVolumeSlider 上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  问一个问题似乎很宽泛,但这很烦人,而且很难修复这个错误.

                  It seems like very broad to ask a question, but this is very annoying and difficult to fix the bug.

                  这是我从 Crashlytics 获得的 WebThread 崩溃日志.

                  Here's the crash log for WebThread which I got from Crashlytics.

                  Thread : Crashed: WebThread
                  0  libobjc.A.dylib                0x0000000193e97bd0 objc_msgSend + 16
                  1  UIKit                          0x0000000187f65dd8 +[UIViewAnimationState  popAnimationState] + 332
                  2  MediaPlayer                    0x0000000185953358 -[MPVolumeSlider volumeController:volumeValueDidChange:] + 92
                  3  MediaPlayer                    0x00000001859c5fc4 -[MPVolumeController updateVolumeValue] + 260
                  4  MediaPlayer                    0x0000000185952cb0 -[MPVolumeSlider didMoveToSuperview] + 144
                  5  UIKit                          0x0000000187f2c1dc -[UIView(Hierarchy) _postMovedFromSuperview:] + 484
                  6  UIKit                          0x0000000187f37cbc -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1764
                  7  MediaPlayer                    0x0000000185955f54 -[MPVolumeView _createSubviews] + 264
                  8  MediaPlayer                    0x00000001859549d4 -[MPVolumeView _initWithStyle:] + 240
                  9  MediaPlayer                    0x0000000185954a60 -[MPVolumeView initWithFrame:style:] + 88
                  10 WebCore                        0x0000000191ba4684 -[WebMediaSessionHelper initWithCallback:] + 132
                  11 WebCore                        0x0000000191ba3db8 WebCore::MediaSessionManageriOS::MediaSessionManageriOS() + 96
                  12 WebCore                        0x0000000191ba3d28 WebCore::MediaSessionManager::sharedManager() + 56
                  13 WebCore                        0x0000000191ba2890 WebCore::MediaSession::MediaSession(WebCore::MediaSessionClient&) + 44
                  14 WebCore                        0x00000001916e8604 WebCore::HTMLMediaSession::create(WebCore::MediaSessionClient&) + 36
                  15 WebCore                        0x00000001916d0fb0 WebCore::HTMLMediaElement::HTMLMediaElement(WebCore::QualifiedName const&, WebCore::Document&, bool) + 1100
                  16 WebCore                        0x000000019170a2b4 WebCore::HTMLVideoElement::create(WebCore::QualifiedName const&, WebCore::Document&, bool) + 68
                  17 WebCore                        0x00000001916bdd9c WebCore::videoConstructor(WebCore::QualifiedName const&, WebCore::Document&, WebCore::HTMLFormElement*, bool) + 92
                  

                  我在开发过程中从未见过这种崩溃(如果我能用断点和控制台日志捕获它,我会很高兴),但只有在它上线时才会出现在用户面前.

                  I never seen this kind of crash during development(I would be very happy when I can catch it with breakpoint and console log), but only appears to users when it is on live.

                  只能由 crashlytics 报告.

                  Can be only reported by crashlytics.

                  可能的原因;

                  应用程序在启动时使用 MagicalRecord 并在后台从服务器获取数据.这使用多线程,当 webkit 使用 UIKit 部分和锁定时,另一个主线程似乎可以访问它.因此,我尝试删除所有 dispatch_sync 并将其更改为 dispatch_async 但在进行了几次功能调用后再次发生崩溃.

                  App uses MagicalRecord and get data from server in background when start up. This uses multi-thread, and when webkit is using UIKit part and locking, another main thread seems like access it. So I have tried to remove all dispatch_sync and changed it to dispatch_async but the crashes happens again after proceeding a few functional calls.

                  我想知道的是,为什么 WebCore 正在运行,而我从未在 UIWebView 上请求 MPVolumeController.

                  What I want to know is, why WebCore is running, and I never requested MPVolumeController on UIWebView.

                  即使出于某种原因它们可以在后台运行,为什么会崩溃?它经常发生,用户抱怨.

                  Even they can run on background for some reason, why it crashes? It is happening frequently and users complaint.

                  其他人有同样的问题吗?

                  Any others have same problem?

                  推荐答案

                  这个bug从iOS 8开始出现.

                  This bug occurred since iOS 8.

                  加载包含 audiovideo 元素的 HTML 的 UIWebView 会随机崩溃.

                  UIWebView that loads HTML containing audio or video elements will crash randomly.

                  我是这样解决的:

                  @interface H5WebKitBugsManager : NSObject
                  
                  + (void)fixAllBugs;
                  
                  @end
                  
                  
                  #import "H5WebKitBugsManager.h"
                  #import <objc/runtime.h>
                  
                  void H5Swizzle(Class c, SEL orig, SEL new)
                  {
                      Method origMethod = class_getInstanceMethod(c, orig);
                      Method newMethod = class_getInstanceMethod(c, new);
                      if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) {
                          class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
                      } else {
                          method_exchangeImplementations(origMethod, newMethod);
                      }
                  }
                  
                  @implementation H5WebKitBugsManager
                  
                  + (void)fixAllBugs
                  {
                      [self fixBug_MediaPlayerVolumeView];
                  }
                  
                  + (void)fixBug_MediaPlayerVolumeView
                  {
                      CGFloat systemVersion = [UIDevice currentDevice].systemVersion.floatValue;
                  
                      if (systemVersion < 8.0f || systemVersion > 9.1) {
                      // below ios version 8.0 has no VolumeView
                          return;
                      }
                  
                      Class cls = NSClassFromString(@"WebMediaSessionHelper");
                      NSString *allocateVolumeView = @"allocateVolumeView";
                      SEL orig = NSSelectorFromString(allocateVolumeView);
                      SEL new = @selector(H5WKBMAllocateVolumeView);
                      Method newMethod = class_getInstanceMethod(self, new);
                  
                      if(class_addMethod(cls, new, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) {
                          H5Swizzle(cls, orig, new);
                      }
                  }
                  
                  - (void)H5WKBMAllocateVolumeView
                  {
                      // WebKit's MediaSessionManageriOS is a singleton,in MediaSessionManageriOS.m. svn version181,859.
                      static dispatch_once_t onceToken;
                      dispatch_once(&onceToken, ^{
                          dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 
                              // must be dispatch in background thread
                              [self H5WKBMAllocateVolumeView];
                          });
                      });
                  }
                  
                  @end
                  

                  这篇关于iPhone 应用程序在 WebThread MPVolumeSlider 上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Webview 中的 PDF 性能 下一篇:如何检测 UIWebView 上的触摸

                  相关文章

                  <tfoot id='IOTlQ'></tfoot>
                    • <bdo id='IOTlQ'></bdo><ul id='IOTlQ'></ul>

                    <small id='IOTlQ'></small><noframes id='IOTlQ'>

                    <i id='IOTlQ'><tr id='IOTlQ'><dt id='IOTlQ'><q id='IOTlQ'><span id='IOTlQ'><b id='IOTlQ'><form id='IOTlQ'><ins id='IOTlQ'></ins><ul id='IOTlQ'></ul><sub id='IOTlQ'></sub></form><legend id='IOTlQ'></legend><bdo id='IOTlQ'><pre id='IOTlQ'><center id='IOTlQ'></center></pre></bdo></b><th id='IOTlQ'></th></span></q></dt></tr></i><div id='IOTlQ'><tfoot id='IOTlQ'></tfoot><dl id='IOTlQ'><fieldset id='IOTlQ'></fieldset></dl></div>
                      <legend id='IOTlQ'><style id='IOTlQ'><dir id='IOTlQ'><q id='IOTlQ'></q></dir></style></legend>