Code Monkey home page Code Monkey logo

krpano-exp's People

Contributors

safecat avatar

Watchers

 avatar  avatar

krpano-exp's Issues

Krpano 在 iPhone 闪退问题

在 iOS 设备中有一些 iPhone 闪退的情况,这里总结一些调优的经验,尽量提高 krpano 运行的稳定性。

在 iOS 中,所有功能都是经过调优并测试通过的,但在一些第三方应用或浏览器中,由于第三方应用的实现方式不同,可能导致一些问题,例如横纵显示错误,这是由于第三方应用的错误实现导致的。

根据本文调试前,请确认你的 krpano 已经升级到较新的版本(1.17.2+),并且确认你的闪退问题是偶然的,如果你的闪退是由某个固定操作触发的,或者固定在某个时间点触发,则并非本文描述的问题。

iOS 版本对应的功能

  • 推荐使用 iOS 7.1 及以上的版本
  • iOS 7.0 的内存泄露较为严重
  • 运行 multires 的最低版本是 5.1
  • 全景显示的最低版本是 4.1

避免使用multires

加载多重资源会导致更多的内存占用,可以使用下面的代码以保证在 iPhone 上只加载一套资源图片。

<image multires="true" devices="!iphone" ...>
    <level tiledimagewidth="3402" tiledimageheight="3402"><cube url="..." /></level>
    <level tiledimagewidth="1702" tiledimageheight="1702"><cube url="..." /></level>
    <mobile><cube url="..." /></mobile>
</image>

<image devices="iphone" ...>
    <cube url="..." />
</image>

对于设备的识别,如果想做的更精细,可以参考 http://krpano.com/docu/xml/#devices-notes

XML方面的优化

<memory maxmem="$LOW_VALUE" />

http://krpano.com/docu/xml/#memory

cube模式下,每一面图片的像素大小,决定了该场景的内存占用大小,计算公式为

'tile-image-width * tile-image-height * 4 / 1024 / 1024'

例如,当每一面的图片为 512 * 512 时,单张图片占用的内存为 1M 大小,六张图占用的是 6M。1024 * 1024 的全景场景,就会占用到 24M。

当使用 multires 功能时,一个场景占用的内存将会是所有资源级别的和,前面关于 multires 的 demo xml,如果在浏览器中加载,内存将会达到 330M。

在 iOS 设备(包括iPad)上,请尽量避免 tilesize > 1024 * 1024。

<display hardwarelimit="$LOW_VALUE" />

http://krpano.com/docu/xml/#display.hardwarelimit

该属性会强制限制每一面的像素大小,该属性建议和 device 属性一起使用。

<image multiresthreshold="$HIGH_VALUE">

http://krpano.com/docu/xml/#image.multiresthreshold

如果你非使用 multires 不可,那么可以降低 multires 切换的灵敏度,但是这样做在大部分场景会出现较多的马赛克。

iOS 7.0 和 iOS 7.1

iOS 7.0 存在一些内存泄露的问题,在 iOS 7.1 及以上的版本情况有很大改善。

降低 JPEG 质量带来的影响

全景展示的内存占用由图片的像素尺寸决定,不论是 75% 质量的 JPG 图片,还是 100%,只要其像素尺寸一样,则占用的内存大小都一样,所以降低 JPEG 质量并不能减少 krpano 的内存占用。

还需要注意些什么

在 skin 或 xml中其它层 的图片也属于krpano的内存占用范围,注意它们的像素大小。

最后,当操作系统确实存在内存控制上的问题时,不论 krpano 方面如何努力,都无法完全避免此类问题。

iPhone 各机型的内存大小

  • iPhone4、iPhone4S:512M
  • iPhone5 ~ iPhone6 Plus:1G

参考资料

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.